Menu

[r19]: / Source CLR V2 / Webstensible / Widgets / XWidgetHelp.vb  Maximize  Restore  History

Download this file

156 lines (127 with data), 6.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
' Webstensible- THE Extensible Application Layer Development Toolset - http://www.webstensible.com
' Copyright (c) 2005 - SDC Solutions, Inc. ( http://www.sdcsol.com ) - All rights reserved.
' Support: support@webstensible.com
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
Public Class XWidgetHelp
Inherits XWidget
Private sWidgetKey As String
Public Sub New(ByVal Source As String, ByRef xp As XParser)
MyBase.New(Source, xp)
objKey = "XWidgetHelp"
End Sub
Public Sub New(ByVal Source As Hashtable, ByRef xp As XParser)
MyBase.New(Source, xp)
objKey = "XWidgetHelp"
End Sub
''' <summary>
''' Draw the widget to the UI
''' </summary>
''' <returns>Boolean to indicate whether it is successful</returns>
''' <remarks></remarks>
Public Overrides Function Draw() As Boolean
Try
sWidgetKey = Me.GetProperty("widgetkey")
Me.PaintWidgetHelp(sWidgetKey)
Return True
Catch ex As Exception
RaiseNotifyEvent(Me, Me._Section, XEventTypes.xetError, ex.Message)
Return False
End Try
End Function
''' <summary>
''' Register Parms this widget takes
''' </summary>
''' <remarks></remarks>
Public Overrides Sub RegisterWidgetParms()
Me.RegisterWidgetParm("widgetkey", True, XWidgetTypes.wtString, "The widget you wish to display syntax help for.<br />Use 'All' - for all widgets - OR - a specific widget name as defined in the webstensible/widgets config section.")
Me.RegisterWidgetParm("tablebodyclass", False, XWidgetTypes.wtString, "The CSS class name used to format the display of parameter table information.")
Me.RegisterWidgetParm("titleclass", False, XWidgetTypes.wtString, "The CSS Class name to use for the title of each widget displayed.")
Me.RegisterWidgetParm("displayseperator", False, XWidgetTypes.wtBoolean, "Yes/No indicating whether a horizontal line seperator should paint at the bottom of the help table of each widget. Default=Yes")
End Sub
''' <summary>
''' Paint the widget help specified
''' </summary>
''' <param name="widgetkey">Widget key value to display help for</param>
''' <remarks>'All' will display help for all widgets</remarks>
Private Sub PaintWidgetHelp(ByVal widgetkey As String)
Dim htWidgets As Hashtable = Nothing
Dim de As DictionaryEntry = Nothing
Dim sl As SortedList
Try
htWidgets = DirectCast(ConfigurationManager.GetSection("Webstensible/Widgets"), Hashtable)
If Not htWidgets Is Nothing Then
sl = New SortedList(htWidgets)
For Each de In sl
If widgetkey.TrimEnd.ToLower = "all" Then
PaintWidgetItemHelp(de.Key)
Else
If widgetkey.TrimEnd.ToLower = de.Key.ToString.TrimEnd.ToLower Then
PaintWidgetItemHelp(de.Key)
End If
End If
Next
Else
Throw New Exception("There are no widgets to display help for - confirm you web config file has a webstensible/widgets section and that widget definitions are defined there.")
End If
Catch ex As Exception
xErr = New XError(objKey, "PaintWidgetHelp", ex, False)
Me.RaiseNotifyEvent(Me, Me._Section, XEventTypes.xetError, ex.Message)
End Try
End Sub
''' <summary>
''' Paint the help for a specific widget
''' </summary>
''' <param name="widgetkey">The string key of the widget to paint</param>
''' <returns>True is the painting occurred OK else false</returns>
''' <remarks></remarks>
Private Function PaintWidgetItemHelp(ByVal widgetkey As String) As Boolean
Dim w As XWidget = Nothing
Dim doc As Object = Nothing
Dim xcomp As xComponent
Try
xcomp = New xComponent
w = xcomp.GetWidget(widgetkey.TrimEnd, Me.SourceString, xp)
w.RegisterWidgetParms()
w.SetProperty("titleclass", Me.GetProperty("titleclass", ""))
w.SetProperty("tablebodyclass", Me.GetProperty("tablebodyclass", ""))
' by default the xwidget implementation will create a table and add it to placeholder control XPlaceHolder
doc = w.Documentation(widgetkey.ToUpper & " Parameters")
If TypeOf (doc) Is PlaceHolder Then
Me.Controls.Add(CType(doc, PlaceHolder))
Else
If TypeOf (doc) Is String Then
Dim lbl As Label = New Label
lbl.Text = CType(doc, String)
If Me.GetProperty("tablebodyclass", "") = "" Then
lbl.Attributes.Add("style", "font-size: 10pt; color: black; font-family: arial, verdana")
Else
lbl.CssClass = Me.GetProperty("parameteritemclass", "")
End If
Me.Controls.Add(lbl)
End If
End If
' show horizonal line
If Me.GetProperty("displayseperator", "yes") = "yes" Then
Me.Controls.Add(New HtmlGenericControl("hr"))
End If
Return True
Catch ex As Exception
xErr = New XError(objKey, "PaintWidgetHelp", ex, False)
RaiseNotifyEvent(Me, Me._Section, XEventTypes.xetError, ex.Message)
Return False
End Try
End Function
End Class
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.