Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176599
  • 博文数量: 89
  • 博客积分: 30
  • 博客等级: 民兵
  • 技术积分: 565
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-24 10:16
文章分类

全部博文(89)

文章存档

2013年(1)

2012年(1)

2011年(8)

2010年(45)

2009年(34)

我的朋友

分类: C/C++

2009-09-18 11:28:57

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 PaneCaption
    
Inherits System.Windows.Forms.UserControl

    
' const values
    '用来控制控件表面文字绘制的属性和控件默认的缺省属性
    Private Class 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(25516578)
    
Private m_colorActiveHigh As Color = Color.FromArgb(255225155)
    
Private m_colorInactiveLow As Color = Color.FromArgb(355145)
    
Private m_colorInactiveHigh As Color = Color.FromArgb(90135215)

    
' 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() 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() 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() 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() 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日编辑了该文章文章。
-->
阅读(630) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~