IssueVision的PaneCaption控件源码分析

作者查看了IssueVision的源代码,并将学习过程中的内容记录下来,以防遗忘。

 今天看了看IssueVision的源代码,把学习中的东西记录下来,以免忘掉了。

None.gif' Custom control that draws the caption for each pane. Contains an active 
None.gif'
 state and draws the caption different for each state. Caption is drawn
None.gif'
 with a gradient fill and antialias font.
None.gif

None.gif
None.gif
Imports System.Drawing.Drawing2D '使用GDI+绘制渐变背景和表面文字需要引用的类
None.gif
Imports System.ComponentModel
None.gif
ExpandedBlockStart.gifContractedBlock.gif
Public Class PaneCaptionClass PaneCaption
InBlock.gif    
Inherits System.Windows.Forms.UserControl
InBlock.gif
InBlock.gif    
' const values
InBlock.gif
    '用来控制控件表面文字绘制的属性和控件默认的缺省属性
ExpandedSubBlockStart.gifContractedSubBlock.gif
    Private Class ConstsClass Consts
InBlock.gif        
Public Const DefaultHeight As Integer = 26
InBlock.gif        
Public Const DefaultFontName As String = "Tahoma"
InBlock.gif
        Public Const DefaultFontSize As Integer = 12
InBlock.gif        
Public Const PosOffset As Integer = 4 '文字相对于容器的绘制坐标位移
ExpandedSubBlockEnd.gif
    End Class

InBlock.gif
InBlock.gif    
' internal members
InBlock.gif
    Private m_active As Boolean = False '控件激活和无效两种状态控制
InBlock.gif
    Private m_antiAlias As Boolean = True '用来控制控件表面文字的显示质量
InBlock.gif
    Private m_allowActive As Boolean = True
InBlock.gif    
Private m_text As String = ""
InBlock.gif

InBlock.gif
    '两种状态默认文字、背景渐变颜色
InBlock.gif
    Private m_colorActiveText As Color = Color.Black
InBlock.gif    
Private m_colorInactiveText As Color = Color.White
InBlock.gif
InBlock.gif    
Private m_colorActiveLow As Color = Color.FromArgb(25516578)
InBlock.gif    
Private m_colorActiveHigh As Color = Color.FromArgb(255225155)
InBlock.gif    
Private m_colorInactiveLow As Color = Color.FromArgb(355145)
InBlock.gif    
Private m_colorInactiveHigh As Color = Color.FromArgb(90135215)
InBlock.gif
InBlock.gif    
' gdi objects
InBlock.gif
    '绘制显示效果的笔刷
InBlock.gif
    Private m_brushActiveText As SolidBrush
InBlock.gif    
Private m_brushInactiveText As SolidBrush
InBlock.gif    
Private m_brushActive As LinearGradientBrush
InBlock.gif    
Private m_brushInactive As LinearGradientBrush
InBlock.gif    
Private m_format As StringFormat
InBlock.gif
InBlock.gif
InBlock.gif    
' public properties
InBlock.gif

InBlock.gif    
' the caption of the control
InBlock.gif
    '设置控件中的文本,并且在属性面板中可以选择
InBlock.gif
    <Description("Text displayed in the caption."), _
InBlock.gif    Category(
"Appearance"), DefaultValue("")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property Caption()Property Caption() As String
InBlock.gif        
Get
InBlock.gif            
Return m_text
InBlock.gif        
End Get
InBlock.gif
InBlock.gif        
Set(ByVal value As String)
InBlock.gif            m_text 
= value
InBlock.gif            Invalidate() 
'重会控件的显示
InBlock.gif
        End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
'两个同样的属性,但是在即使按照上边控制Caption属性的方式来控制Text属性,属性面板中也不显示Text属性,不知动为什么?
ExpandedSubBlockStart.gifContractedSubBlock.gif
    Public Overrides Property Text()Property Text() As String
InBlock.gif        
Get
InBlock.gif            
Return Me.Caption
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal Value As String)
InBlock.gif            Me.Caption 
= Value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
' if the caption is active or not
InBlock.gif
    <Description("The active state of the caption, draws the caption with different gradient colors."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(False)> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property Active()Property Active() As Boolean
InBlock.gif        
Get
InBlock.gif            
Return m_active
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Boolean)
InBlock.gif            m_active 
= value
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
' if should maintain an active and inactive state
InBlock.gif
    <Description("True always uses the inactive state colors, false maintains an active and inactive state."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(True)> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property AllowActive()Property AllowActive() As Boolean
InBlock.gif        
Get
InBlock.gif            
Return m_allowActive
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Boolean)
InBlock.gif            m_allowActive 
= value
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
' if the caption is active or not
InBlock.gif
    <Description("If should draw the text as antialiased."), _
InBlock.gif     Category(
"Appearance"), DefaultValue(True)> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property AntiAlias()Property AntiAlias() As Boolean
InBlock.gif        
Get
InBlock.gif            
Return m_antiAlias
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Boolean)
InBlock.gif            m_antiAlias 
= value
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif#Region 
" color properties "
InBlock.gif

InBlock.gif
    <Description("Color of the text when active."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(GetType(Color), "Black")> 
_
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property ActiveTextColor()Property ActiveTextColor() As Color
InBlock.gif        
Get
InBlock.gif            
Return m_colorActiveText
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal Value As Color)
InBlock.gif            
If Value.Equals(Color.Empty) Then Value = Color.Black
InBlock.gif            m_colorActiveText 
= Value
InBlock.gif            m_brushActiveText 
= New SolidBrush(m_colorActiveText)
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
<Description("Color of the text when inactive."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(GetType(Color), "White")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property InactiveTextColor()Property InactiveTextColor() As Color
InBlock.gif        
Get
InBlock.gif            
Return m_colorInactiveText
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal Value As Color)
InBlock.gif            
If Value.Equals(Color.Empty) Then Value = Color.White
InBlock.gif            m_colorInactiveText 
= Value
InBlock.gif            m_brushInactiveText 
= New SolidBrush(m_colorInactiveText)
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
<Description("Low color of the active gradient."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(GetType(Color), "255, 165, 78")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property ActiveGradientLowColor()Property ActiveGradientLowColor() As Color
InBlock.gif        
Get
InBlock.gif            
Return m_colorActiveLow
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal Value As Color)
InBlock.gif            
If Value.Equals(Color.Empty) Then Value = Color.FromArgb(25516578)
InBlock.gif            m_colorActiveLow 
= Value
InBlock.gif            CreateGradientBrushes()
InBlock.gif            Invalidate()
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
InBlock.gif    
<Description("High color of the active gradient."), _
InBlock.gif    Category(
"Appearance"), DefaultValue(GetType(Color), "255, 225, 155")> _
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property ActiveGradientHighColor()Property ActiveGradientHighColor() As Color
InBlock.gif        
Get
InBlock.gif            
Return m_colorActiveHigh
InBlock.gif        
End Get
InBlock.gif&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值