📄 colortypeeditor.vb
字号:
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Windows.Forms.Design
Namespace WroxDesignVB.Design
Public Class ColorTypeEditor : Inherits UITypeEditor
Public Overloads Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle
Return UITypeEditorEditStyle.DropDown
End Function
Public Overloads Overrides Function GetPaintValueSupported(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
'/ <summary>
'/ Painteger your custom drawing in the output Graphics object recieved.
'/ </summary>
Public Overloads Overrides Sub PaintValue(ByVal e As PaintValueEventArgs)
Dim control As WebControl = CType(e.Context.Instance, WebControl)
'Fills the left rectangle with a color.
e.Graphics.FillRegion(New SolidBrush(control.BackColor), New Region(e.Bounds))
'Draw a couple letters with the selected colors
Dim style As FontStyle = FontStyle.Regular Or _
IIf(control.Font.Bold, FontStyle.Bold, FontStyle.Regular) Or _
IIf(control.Font.Italic, FontStyle.Italic, FontStyle.Regular) Or _
IIf(control.Font.Underline, FontStyle.Underline, FontStyle.Regular)
Dim font = New Font("Tahoma", 8, style)
Dim brush = New SolidBrush(control.ForeColor)
e.Graphics.DrawString("ab", font, brush, e.Bounds.X, e.Bounds.Y)
End Sub
'/ <summary>
'/ Called upon edition of the property.
'/ </summary>
Public Overloads Overrides Function EditValue(ByVal context As ITypeDescriptorContext, _
ByVal provider As IServiceProvider, ByVal value As Object) As Object
Dim retvalue As Object = value
Dim srv As IWindowsFormsEditorService = Nothing
'IToolboxService tool
'System.ComponentModel.Design.ISelectionService sel
'Get the editor service from the provider, to perform the dropdown.
If Not (provider Is Nothing) Then
srv = CType(provider.GetService(GetType(IWindowsFormsEditorService)), _
IWindowsFormsEditorService)
End If
If Not (srv Is Nothing) Then
Dim editor As ColorTypeEditorControl = _
New ColorTypeEditorControl(CType(value, System.Drawing.Color), _
CType(context.Instance, WebControl))
srv.DropDownControl(editor)
Return editor.SelectedColor
End If
Return retvalue
End Function
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -