IssueVision的PaneCaption控件源码分析
今天看了看IssueVision的源代码,把学习中的东西记录下来,以免忘掉了。
' Custom control that draws the caption for each pane. Contains an active
' state and draws the caption different for each state. Caption is drawn
' with a gradient fill and antialias font.
Imports System.Drawing.Drawing2D '使用GDI+绘制渐变背景和表面文字需要引用的类
Imports System.ComponentModel
Public Class PaneCaptionClass PaneCaption
Inherits System.Windows.Forms.UserControl
' const values
'用来控制控件表面文字绘制的属性和控件默认的缺省属性
Private Class ConstsClass Consts
Public Const DefaultHeight As Integer = 26
Public Const DefaultFontName As String = "Tahoma"
Public Const DefaultFontSize As Integer = 12
Public Const PosOffset As Integer = 4 '文字相对于容器的绘制坐标位移
End Class
' internal members
Private m_active As Boolean = False '控件激活和无效两种状态控制
Private m_antiAlias As Boolean = True '用来控制控件表面文字的显示质量
Private m_allowActive As Boolean = True
Private m_text As String = ""
'两种状态默认文字、背景渐变颜色
Private m_colorActiveText As Color = Color.Black
Private m_colorInactiveText As Color = Color.White
Private m_colorActiveLow As Color = Color.FromArgb(255, 165, 78)
Private m_colorActiveHigh As Color = Color.FromArgb(255, 225, 155)
Private m_colorInactiveLow As Color = Color.FromArgb(3, 55, 145)
Private m_colorInactiveHigh As Color = Color.FromArgb(90, 135, 215)
' gdi objects
'绘制显示效果的笔刷
Private m_brushActiveText As SolidBrush
Private m_brushInactiveText As SolidBrush
Private m_brushActive As LinearGradientBrush
Private m_brushInactive As LinearGradientBrush
Private m_format As StringFormat
' public properties
' the caption of the control
'设置控件中的文本,并且在属性面板中可以选择
<Description("Text displayed in the caption."), _
Category("Appearance"), DefaultValue("")> _
Public Property Caption()Property Caption() As String
Get
Return m_text
End Get
Set(ByVal value As String)
m_text = value
Invalidate() '重会控件的显示
End Set
End Property
'两个同样的属性,但是在即使按照上边控制Caption属性的方式来控制Text属性,属性面板中也不显示Text属性,不知动为什么?
Public Overrides Property Text()Property Text() As String
Get
Return Me.Caption
End Get
Set(ByVal Value As String)
Me.Caption = Value
End Set
End Property
' if the caption is active or not
<Description("The active state of the caption, draws the caption with different gradient colors."), _
Category("Appearance"), DefaultValue(False)> _
Public Property Active()Property Active() As Boolean
Get
Return m_active
End Get
Set(ByVal value As Boolean)
m_active = value
Invalidate()
End Set
End Property
' if should maintain an active and inactive state
<Description("True always uses the inactive state colors, false maintains an active and inactive state."), _
Category("Appearance"), DefaultValue(True)> _
Public Property AllowActive()Property AllowActive() As Boolean
Get
Return m_allowActive
End Get
Set(ByVal value As Boolean)
m_allowActive = value
Invalidate()
End Set
End Property
' if the caption is active or not
<Description("If should draw the text as antialiased."), _
Category("Appearance"), DefaultValue(True)> _
管理员在2009年8月13日编辑了该文章文章。
-->
' state and draws the caption different for each state. Caption is drawn
' with a gradient fill and antialias font.
Imports System.Drawing.Drawing2D '使用GDI+绘制渐变背景和表面文字需要引用的类
Imports System.ComponentModel
Public Class PaneCaptionClass PaneCaption
Inherits System.Windows.Forms.UserControl
' const values
'用来控制控件表面文字绘制的属性和控件默认的缺省属性
Private Class ConstsClass Consts
Public Const DefaultHeight As Integer = 26
Public Const DefaultFontName As String = "Tahoma"
Public Const DefaultFontSize As Integer = 12
Public Const PosOffset As Integer = 4 '文字相对于容器的绘制坐标位移
End Class
' internal members
Private m_active As Boolean = False '控件激活和无效两种状态控制
Private m_antiAlias As Boolean = True '用来控制控件表面文字的显示质量
Private m_allowActive As Boolean = True
Private m_text As String = ""
'两种状态默认文字、背景渐变颜色
Private m_colorActiveText As Color = Color.Black
Private m_colorInactiveText As Color = Color.White
Private m_colorActiveLow As Color = Color.FromArgb(255, 165, 78)
Private m_colorActiveHigh As Color = Color.FromArgb(255, 225, 155)
Private m_colorInactiveLow As Color = Color.FromArgb(3, 55, 145)
Private m_colorInactiveHigh As Color = Color.FromArgb(90, 135, 215)
' gdi objects
'绘制显示效果的笔刷
Private m_brushActiveText As SolidBrush
Private m_brushInactiveText As SolidBrush
Private m_brushActive As LinearGradientBrush
Private m_brushInactive As LinearGradientBrush
Private m_format As StringFormat
' public properties
' the caption of the control
'设置控件中的文本,并且在属性面板中可以选择
<Description("Text displayed in the caption."), _
Category("Appearance"), DefaultValue("")> _
Public Property Caption()Property Caption() As String
Get
Return m_text
End Get
Set(ByVal value As String)
m_text = value
Invalidate() '重会控件的显示
End Set
End Property
'两个同样的属性,但是在即使按照上边控制Caption属性的方式来控制Text属性,属性面板中也不显示Text属性,不知动为什么?
Public Overrides Property Text()Property Text() As String
Get
Return Me.Caption
End Get
Set(ByVal Value As String)
Me.Caption = Value
End Set
End Property
' if the caption is active or not
<Description("The active state of the caption, draws the caption with different gradient colors."), _
Category("Appearance"), DefaultValue(False)> _
Public Property Active()Property Active() As Boolean
Get
Return m_active
End Get
Set(ByVal value As Boolean)
m_active = value
Invalidate()
End Set
End Property
' if should maintain an active and inactive state
<Description("True always uses the inactive state colors, false maintains an active and inactive state."), _
Category("Appearance"), DefaultValue(True)> _
Public Property AllowActive()Property AllowActive() As Boolean
Get
Return m_allowActive
End Get
Set(ByVal value As Boolean)
m_allowActive = value
Invalidate()
End Set
End Property
' if the caption is active or not
<Description("If should draw the text as antialiased."), _
Category("Appearance"), DefaultValue(True)> _
管理员在2009年8月13日编辑了该文章文章。