分享
 
 
 

类QQ的XP BUTTON控件

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Imports System

Imports System.Enum

Imports System.Collections

Imports System.ComponentModel

Imports System.Drawing

Imports System.Data

Imports System.Windows.Forms

Imports System.Drawing.Drawing2D

Imports System.Drawing.Design

Namespace LandlordAspx_xpctrl

Public Class emunType

Public Enum XPStyle

Default1

Blue

OliveGreen

Silver

End Enum

Public Enum BtnShape

Rectangle

Ellipse

End Enum

End Class

Friend NotInheritable Class ControlPaint

Private Sub New()

End Sub

Public Shared ReadOnly Property BorderColor() As Color

Get

Return Color.FromArgb(127, 157, 185)

End Get

End Property

Public Shared ReadOnly Property DisabledBorderColor() As Color

Get

Return Color.FromArgb(201, 199, 186)

End Get

End Property

Public Shared ReadOnly Property ButtonBorderColor() As Color

Get

Return Color.FromArgb(28, 81, 128)

End Get

End Property

Public Shared ReadOnly Property DisabledButtonBorderColor() As Color

Get

Return Color.FromArgb(202, 200, 187)

End Get

End Property

Public Shared ReadOnly Property DisabledBackColor() As Color

Get

Return Color.FromArgb(236, 233, 216)

End Get

End Property

Public Shared ReadOnly Property DisabledForeColor() As Color

Get

Return Color.FromArgb(161, 161, 146)

End Get

End Property

Public Shared Function GetStringFormat(ByVal contentAlignment As ContentAlignment) As StringFormat

If Not System.Enum.IsDefined(GetType(ContentAlignment), CType(contentAlignment, Integer)) Then

Throw New System.ComponentModel.InvalidEnumArgumentException("contentAlignment", CType(contentAlignment, Integer), GetType(ContentAlignment))

End If

Dim stringFormat As StringFormat = New StringFormat

Select Case contentAlignment

Case contentAlignment.MiddleCenter

stringFormat.LineAlignment = StringAlignment.Center

stringFormat.Alignment = StringAlignment.Center

' break

Case contentAlignment.MiddleLeft

stringFormat.LineAlignment = StringAlignment.Center

stringFormat.Alignment = StringAlignment.Near

' break

Case contentAlignment.MiddleRight

stringFormat.LineAlignment = StringAlignment.Center

stringFormat.Alignment = StringAlignment.Far

' break

Case contentAlignment.TopCenter

stringFormat.LineAlignment = StringAlignment.Near

stringFormat.Alignment = StringAlignment.Center

' break

Case contentAlignment.TopLeft

stringFormat.LineAlignment = StringAlignment.Near

stringFormat.Alignment = StringAlignment.Near

' break

Case contentAlignment.TopRight

stringFormat.LineAlignment = StringAlignment.Near

stringFormat.Alignment = StringAlignment.Far

' break

Case contentAlignment.BottomCenter

stringFormat.LineAlignment = StringAlignment.Far

stringFormat.Alignment = StringAlignment.Center

' break

Case contentAlignment.BottomLeft

stringFormat.LineAlignment = StringAlignment.Far

stringFormat.Alignment = StringAlignment.Near

' break

Case contentAlignment.BottomRight

stringFormat.LineAlignment = StringAlignment.Far

stringFormat.Alignment = StringAlignment.Far

' break

End Select

Return stringFormat

End Function

Public Shared Sub DrawRoundedRectangle(ByVal g As Graphics, ByVal p As Pen, ByVal rc As Rectangle, ByVal size As Size)

Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode

g.SmoothingMode = SmoothingMode.AntiAlias

g.DrawLine(p, CType(rc.Left + size.Width / 2, Single), rc.Top, CType(rc.Right - size.Width / 2, Single), rc.Top)

g.DrawArc(p, rc.Right - size.Width, rc.Top, size.Width, size.Height, 270, 90)

g.DrawLine(p, rc.Right, CType(rc.Top + size.Height / 2, Single), rc.Right, CType(rc.Bottom - size.Height / 2, Single))

g.DrawArc(p, rc.Right - size.Width, rc.Bottom - size.Height, size.Width, size.Height, 0, 90)

g.DrawLine(p, CType(rc.Right - size.Width / 2, Single), rc.Bottom, CType(rc.Left + size.Width / 2, Single), rc.Bottom)

g.DrawArc(p, rc.Left, rc.Bottom - size.Height, size.Width, size.Height, 90, 90)

g.DrawLine(p, rc.Left, CType(rc.Bottom - size.Height / 2, Single), rc.Left, CType(rc.Top + size.Height / 2, Single))

g.DrawArc(p, rc.Left, rc.Top, size.Width, size.Height, 180, 90)

g.SmoothingMode = oldSmoothingMode

End Sub

Public Shared Sub DrawBorder(ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)

g.DrawRectangle(New Pen(ControlPaint.BorderColor, 0), x, y, width, height)

End Sub

Public Shared Sub EraseExcessOldDropDown(ByVal g As Graphics, ByVal newButton As Rectangle)

g.FillRectangle(New SolidBrush(SystemColors.Window), newButton.X - 2, newButton.Y, 2, newButton.Height + 1)

End Sub

End Class

Public Class XP_Button

Inherits System.Windows.Forms.Button

Public Enum ControlState

Normal

Hover

Pressed

Default1

Disabled

End Enum

Private components As System.ComponentModel.Container

Public Sub New()

MyBase.New()

InitializeComponent()

Me.SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer, True)

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

'

'XPButton

'

Me.Name = "XPButton"

End Sub

#Region "Static members"

Private Shared ReadOnly sizeBorderPixelIndent As Size = New Size(4, 4)

Dim clrOuterShadow1 As Color = Color.FromArgb(64, 164, 164, 164)

Dim clrOuterShadow2 As Color = Color.FromArgb(64, Color.White)

Dim clrBackground1 As Color = Color.FromArgb(250, 250, 248)

Dim clrBackground2 As Color = Color.FromArgb(240, 240, 234)

Dim clrBorder As Color = Color.FromArgb(0, 60, 116)

Dim clrInnerShadowBottom1 As Color = Color.FromArgb(236, 235, 230)

Dim clrInnerShadowBottom2 As Color = Color.FromArgb(226, 223, 214)

Dim clrInnerShadowBottom3 As Color = Color.FromArgb(214, 208, 197)

Dim clrInnerShadowRight1a As Color = Color.FromArgb(128, 236, 234, 230)

Dim clrInnerShadowRight1b As Color = Color.FromArgb(128, 224, 220, 212)

Dim clrInnerShadowRight2a As Color = Color.FromArgb(128, 234, 228, 218)

Dim clrInnerShadowRight2b As Color = Color.FromArgb(128, 212, 208, 196)

Dim clrInnerShadowBottomPressed1 As Color = Color.FromArgb(234, 233, 227)

Dim clrInnerShadowBottomPressed2 As Color = Color.FromArgb(242, 241, 238)

Dim clrInnerShadowTopPressed1 As Color = Color.FromArgb(209, 204, 193)

Dim clrInnerShadowTopPressed2 As Color = Color.FromArgb(220, 216, 207)

Dim clrInnerShadowLeftPressed1 As Color = Color.FromArgb(216, 213, 203)

Dim clrInnerShadowLeftPressed2 As Color = Color.FromArgb(222, 220, 211)

#End Region

#Region "Constructors"

'Shared EDButton()

'sizeBorderPixelIndent = New Size(4, 4)

'clrOuterShadow1 = Color.FromArgb(64, 164, 164, 164)

'clrOuterShadow2 = Color.FromArgb(64, Color.White)

'clrBackground1 = Color.FromArgb(250, 250, 248)

'clrBackground2 = Color.FromArgb(240, 240, 234)

'clrBorder = Color.FromArgb(0, 60, 116)

' clrInnerShadowBottom1 = Color.FromArgb(236, 235, 230)

'clrInnerShadowBottom2 = Color.FromArgb(226, 223, 214)

'clrInnerShadowBottom3 = Color.FromArgb(214, 208, 197)

'clrInnerShadowRight1a = Color.FromArgb(128, 236, 234, 230)

'clrInnerShadowRight1b = Color.FromArgb(128, 224, 220, 212)

'clrInnerShadowRight2a = Color.FromArgb(128, 234, 228, 218)

' clrInnerShadowRight2b = Color.FromArgb(128, 212, 208, 196)

' clrInnerShadowBottomPressed1 = Color.FromArgb(234, 233, 227)

'clrInnerShadowBottomPressed2 = Color.FromArgb(242, 241, 238)

'clrInnerShadowTopPressed1 = Color.FromArgb(209, 204, 193)

'clrInnerShadowTopPressed2 = Color.FromArgb(220, 216, 207)

' clrInnerShadowLeftPressed1 = Color.FromArgb(216, 213, 203)

'clrInnerShadowLeftPressed2 = Color.FromArgb(222, 220, 211)

'End Sub

#End Region

#Region "Properties"

Dim enmState As ControlState = ControlState.Normal

Dim bCanClick As Boolean = False

Dim m_btnStyle As emunType.XPStyle = emunType.XPStyle.Default1

Dim m_btnShape As emunType.BtnShape = emunType.BtnShape.Rectangle

Dim locPoint As Point

Public Shadows Property FlatStyle() As FlatStyle

Get

Return MyBase.FlatStyle

End Get

Set(ByVal Value As FlatStyle)

MyBase.FlatStyle = FlatStyle.Standard

End Set

End Property

Public Property BtnShape() As emunType.BtnShape

Get

Return m_btnShape

End Get

Set(ByVal Value As emunType.BtnShape)

m_btnShape = Value

MyBase.Invalidate()

End Set

End Property

<DefaultValue("Blue"), System.ComponentModel.RefreshProperties(RefreshProperties.Repaint)> _

Public Property BtnStyle() As emunType.XPStyle

Get

Return m_btnStyle

End Get

Set(ByVal Value As emunType.XPStyle)

m_btnStyle = Value

Me.Invalidate()

End Set

End Property

Public Property AdjustImageLocation() As Point

Get

Return locPoint

End Get

Set(ByVal Value As Point)

locPoint = Value

Me.Invalidate()

End Set

End Property

Private ReadOnly Property BorderRectangle() As Rectangle

Get

Dim rc As Rectangle = Me.ClientRectangle

Return New Rectangle(1, 1, rc.Width - 3, rc.Height - 3)

End Get

End Property

#End Region

#Region "Methods"

Protected Overloads Overrides Sub OnClick(ByVal ea As EventArgs)

Me.Capture = False

bCanClick = False

If Me.ClientRectangle.Contains(Me.PointToClient(Control.MousePosition)) Then

enmState = ControlState.Hover

Else

enmState = ControlState.Normal

End If

Me.Invalidate()

MyBase.OnClick(ea)

End Sub

Protected Overloads Overrides Sub OnMouseEnter(ByVal ea As EventArgs)

MyBase.OnMouseEnter(ea)

enmState = ControlState.Hover

Me.Invalidate()

End Sub

Protected Overloads Overrides Sub OnMouseDown(ByVal mea As MouseEventArgs)

MyBase.OnMouseDown(mea)

If mea.Button = MouseButtons.Left Then

bCanClick = True

enmState = ControlState.Pressed

Me.Invalidate()

End If

End Sub

Protected Overloads Overrides Sub OnMouseMove(ByVal mea As MouseEventArgs)

MyBase.OnMouseMove(mea)

If ClientRectangle.Contains(mea.X, mea.Y) Then

If enmState = ControlState.Hover AndAlso Me.Capture AndAlso Not bCanClick Then

bCanClick = True

enmState = ControlState.Pressed

Me.Invalidate()

End If

Else

If enmState = ControlState.Pressed Then

bCanClick = False

enmState = ControlState.Hover

Me.Invalidate()

End If

End If

End Sub

Protected Overloads Overrides Sub OnMouseLeave(ByVal ea As EventArgs)

MyBase.OnMouseLeave(ea)

enmState = ControlState.Normal

Me.Invalidate()

End Sub

Protected Overloads Overrides Sub OnPaint(ByVal pea As PaintEventArgs)

Me.OnPaintBackground(pea)

Select Case enmState

Case ControlState.Normal

If Me.Enabled Then

If Me.Focused OrElse Me.IsDefault Then

Select Case m_btnShape

Case emunType.BtnShape.Rectangle

OnDrawDefault(pea.Graphics)

' break

Case emunType.BtnShape.Ellipse

OnDrawDefaultEllipse(pea.Graphics)

' break

End Select

Else

Select Case m_btnShape

Case emunType.BtnShape.Rectangle

OnDrawNormal(pea.Graphics)

' break

Case emunType.BtnShape.Ellipse

OnDrawNormalEllipse(pea.Graphics)

' break

End Select

End If

Else

OnDrawDisabled(pea.Graphics)

End If

' break

Case ControlState.Hover

Select Case m_btnShape

Case emunType.BtnShape.Rectangle

OnDrawHover(pea.Graphics)

' break

Case emunType.BtnShape.Ellipse

OnDrawHoverEllipse(pea.Graphics)

' break

End Select

' break

Case ControlState.Pressed

Select Case m_btnShape

Case emunType.BtnShape.Rectangle

OnDrawPressed(pea.Graphics)

' break

Case emunType.BtnShape.Ellipse

OnDrawPressedEllipse(pea.Graphics)

' break

End Select

' break

End Select

OnDrawTextAndImage(pea.Graphics)

End Sub

Protected Overloads Overrides Sub OnEnabledChanged(ByVal ea As EventArgs)

MyBase.OnEnabledChanged(ea)

enmState = ControlState.Normal

Me.Invalidate()

End Sub

Private Sub OnDrawNormal(ByVal g As Graphics)

DrawNormalButton(g)

End Sub

Private Sub OnDrawHoverEllipse(ByVal g As Graphics)

DrawNormalEllipse(g)

DrawEllipseHoverBorder(g)

DrawEllipseBorder(g)

End Sub

Private Sub OnDrawHover(ByVal g As Graphics)

DrawNormalButton(g)

Dim rcBorder As Rectangle = Me.BorderRectangle

Dim penTop1 As Pen = New Pen(Color.FromArgb(255, 240, 207))

Dim penTop2 As Pen = New Pen(Color.FromArgb(253, 216, 137))

g.DrawLine(penTop1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)

g.DrawLine(penTop2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)

penTop1.Dispose()

penTop2.Dispose()

Dim penBottom1 As Pen = New Pen(Color.FromArgb(248, 178, 48))

Dim penBottom2 As Pen = New Pen(Color.FromArgb(229, 151, 0))

g.DrawLine(penBottom1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)

g.DrawLine(penBottom2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)

penBottom1.Dispose()

penBottom2.Dispose()

Dim rcLeft As Rectangle = New Rectangle(rcBorder.Left + 1, rcBorder.Top + 3, 2, rcBorder.Height - 5)

Dim rcRight As Rectangle = New Rectangle(rcBorder.Right - 2, rcBorder.Top + 3, 2, rcBorder.Height - 5)

Dim brushSide As LinearGradientBrush = New LinearGradientBrush(rcLeft, Color.FromArgb(254, 221, 149), Color.FromArgb(249, 180, 53), LinearGradientMode.Vertical)

g.FillRectangle(brushSide, rcLeft)

g.FillRectangle(brushSide, rcRight)

brushSide.Dispose()

End Sub

Private Sub OnDrawPressedEllipse(ByVal g As Graphics)

DrawPressedEllipse(g)

DrawEllipseBorder(g)

End Sub

Private Sub DrawPressedEllipse(ByVal g As Graphics)

Dim rcBorder As Rectangle = Me.BorderRectangle

Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)

Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(226, 225, 218))

g.FillEllipse(brushBackground, rcBackground)

End Sub

Private Sub OnDrawPressed(ByVal g As Graphics)

Dim rcBorder As Rectangle = Me.BorderRectangle

DrawOuterShadow(g)

Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)

Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(226, 225, 218))

g.FillRectangle(brushBackground, rcBackground)

brushBackground.Dispose()

DrawBorder(g)

Dim penInnerShadowBottomPressed1 As Pen = New Pen(clrInnerShadowBottomPressed1)

Dim penInnerShadowBottomPressed2 As Pen = New Pen(clrInnerShadowBottomPressed2)

g.DrawLine(penInnerShadowBottomPressed1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)

g.DrawLine(penInnerShadowBottomPressed2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)

penInnerShadowBottomPressed1.Dispose()

penInnerShadowBottomPressed2.Dispose()

Dim penInnerShadowTopPressed1 As Pen = New Pen(clrInnerShadowTopPressed1)

Dim penInnerShadowTopPressed2 As Pen = New Pen(clrInnerShadowTopPressed2)

g.DrawLine(penInnerShadowTopPressed1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)

g.DrawLine(penInnerShadowTopPressed2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)

penInnerShadowTopPressed1.Dispose()

penInnerShadowTopPressed2.Dispose()

Dim penInnerShadowLeftPressed1 As Pen = New Pen(clrInnerShadowLeftPressed1)

Dim penInnerShadowLeftPressed2 As Pen = New Pen(clrInnerShadowLeftPressed2)

g.DrawLine(penInnerShadowLeftPressed1, rcBorder.Left + 1, rcBorder.Top + 3, rcBorder.Left + 1, rcBorder.Bottom - 3)

g.DrawLine(penInnerShadowLeftPressed2, rcBorder.Left + 2, rcBorder.Top + 3, rcBorder.Left + 2, rcBorder.Bottom - 3)

penInnerShadowLeftPressed1.Dispose()

penInnerShadowLeftPressed2.Dispose()

End Sub

Private Sub OnDrawNormalEllipse(ByVal g As Graphics)

DrawNormalEllipse(g)

DrawEllipseBorder(g)

End Sub

Private Sub OnDrawDefaultEllipse(ByVal g As Graphics)

DrawNormalEllipse(g)

DrawEllipseDefaultBorder(g)

DrawEllipseBorder(g)

End Sub

Private Sub OnDrawDefault(ByVal g As Graphics)

DrawNormalButton(g)

Dim rcBorder As Rectangle = Me.BorderRectangle

Dim penTop1 As Pen = New Pen(Color.FromArgb(206, 231, 255))

Dim penTop2 As Pen = New Pen(Color.FromArgb(188, 212, 246))

g.DrawLine(penTop1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)

g.DrawLine(penTop2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)

penTop1.Dispose()

penTop2.Dispose()

Dim penBottom1 As Pen = New Pen(Color.FromArgb(137, 173, 228))

Dim penBottom2 As Pen = New Pen(Color.FromArgb(105, 130, 238))

g.DrawLine(penBottom1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)

g.DrawLine(penBottom2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)

penBottom1.Dispose()

penBottom2.Dispose()

Dim rcLeft As Rectangle = New Rectangle(rcBorder.Left + 1, rcBorder.Top + 3, 2, rcBorder.Height - 5)

Dim rcRight As Rectangle = New Rectangle(rcBorder.Right - 2, rcBorder.Top + 3, 2, rcBorder.Height - 5)

Dim brushSide As LinearGradientBrush = New LinearGradientBrush(rcLeft, Color.FromArgb(186, 211, 245), Color.FromArgb(137, 173, 228), LinearGradientMode.Vertical)

g.FillRectangle(brushSide, rcLeft)

g.FillRectangle(brushSide, rcRight)

brushSide.Dispose()

End Sub

Private Sub OnDrawDisabled(ByVal g As Graphics)

Dim rcBorder As Rectangle = Me.BorderRectangle

Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)

Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(245, 244, 234))

g.FillRectangle(brushBackground, rcBackground)

brushBackground.Dispose()

Dim penBorder As Pen = New Pen(Color.FromArgb(201, 199, 186))

ControlPaint.DrawRoundedRectangle(g, penBorder, rcBorder, sizeBorderPixelIndent)

penBorder.Dispose()

End Sub

Private Sub OnDrawTextAndImage(ByVal g As Graphics)

Dim brushText As SolidBrush

If Enabled Then

brushText = New SolidBrush(ForeColor)

Else

brushText = New SolidBrush(ControlPaint.DisabledForeColor)

End If

Dim sf As StringFormat = ControlPaint.GetStringFormat(Me.TextAlign)

sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show

If Not (Me.Image Is Nothing) Then

Dim rc As Rectangle = New Rectangle

Dim ImagePoint As Point = New Point(6, 4)

Select Case Me.ImageAlign

Case ContentAlignment.MiddleRight

rc.Width = Me.ClientRectangle.Width - Me.Image.Width - 8

rc.Height = Me.ClientRectangle.Height

rc.X = 0

rc.Y = 0

ImagePoint.X = rc.Width

ImagePoint.Y = Me.ClientRectangle.Height / 2 - Image.Height / 2

' break

Case ContentAlignment.TopCenter

ImagePoint.Y = 2

ImagePoint.X = (Me.ClientRectangle.Width - Me.Image.Width) / 2

rc.Width = Me.ClientRectangle.Width

rc.Height = Me.ClientRectangle.Height - Me.Image.Height - 4

rc.X = Me.ClientRectangle.X

rc.Y = Me.Image.Height

' break

Case ContentAlignment.MiddleCenter

ImagePoint.X = (Me.ClientRectangle.Width - Me.Image.Width) / 2

ImagePoint.Y = (Me.ClientRectangle.Height - Me.Image.Height) / 2

rc.Width = 0

rc.Height = 0

rc.X = Me.ClientRectangle.Width

rc.Y = Me.ClientRectangle.Height

' break

Case Else

ImagePoint.X = 6

ImagePoint.Y = Me.ClientRectangle.Height / 2 - Image.Height / 2

rc.Width = Me.ClientRectangle.Width - Me.Image.Width

rc.Height = Me.ClientRectangle.Height

rc.X = Me.Image.Width

rc.Y = 0

' break

End Select

ImagePoint.X += locPoint.X

ImagePoint.Y += locPoint.Y

If Me.Enabled Then

g.DrawImage(Me.Image, ImagePoint)

Else

System.Windows.Forms.ControlPaint.DrawImageDisabled(g, Me.Image, locPoint.X, locPoint.Y, Me.BackColor)

End If

If Not (ContentAlignment.MiddleCenter = Me.ImageAlign) Then

Dim rs As RectangleF

rs.X = rc.X

rs.Y = rc.Y

rs.Width = rc.Width

rs.Height = rc.Height

g.DrawString(Me.Text, Me.Font, brushText, rs, sf)

End If

Else

Dim rs As RectangleF

rs.X = Me.ClientRectangle.X

rs.Y = Me.ClientRectangle.Y

rs.Width = Me.ClientRectangle.Width

rs.Height = Me.ClientRectangle.Height

g.DrawString(Me.Text, Me.Font, brushText, rs, sf)

End If

brushText.Dispose()

sf.Dispose()

End Sub

Private Sub DrawNormalEllipse(ByVal g As Graphics)

Dim rcBackground As Rectangle = Me.BorderRectangle

Dim brushBackground As LinearGradientBrush = Nothing

Select Case m_btnStyle

Case emunType.XPStyle.Default1

brushBackground = New LinearGradientBrush(rcBackground, clrBackground1, clrBackground2, LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.Blue

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.OliveGreen

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.Silver

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical)

' break

End Select

Dim relativeIntensities() As Single = {0, 0.008, 1}

Dim relativePositions() As Single = {0, 0.22, 1}

Dim blend As Blend = New Blend

blend.Factors = relativeIntensities

blend.Positions = relativePositions

brushBackground.Blend = blend

g.FillEllipse(brushBackground, rcBackground)

End Sub

Private Sub DrawNormalButton(ByVal g As Graphics)

Dim rcBorder As Rectangle = Me.BorderRectangle

DrawOuterShadow(g)

Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)

Dim brushBackground As LinearGradientBrush = Nothing

Select Case m_btnStyle

Case emunType.XPStyle.Default1

brushBackground = New LinearGradientBrush(rcBackground, clrBackground1, clrBackground2, LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.Blue

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.OliveGreen

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical)

' break

Case emunType.XPStyle.Silver

brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical)

' break

End Select

Dim relativeIntensities() As Single = {0, 0.08, 1}

Dim relativePositions() As Single = {0, 0.32, 1}

Dim blend As Blend = New Blend

blend.Factors = relativeIntensities

blend.Positions = relativePositions

brushBackground.Blend = blend

g.FillRectangle(brushBackground, rcBackground)

brushBackground.Dispose()

DrawBorder(g)

If emunType.XPStyle.Default1 = m_btnStyle Then

Dim penInnerShadowBottom1 As Pen = New Pen(clrInnerShadowBottom1)

Dim penInnerShadowBottom2 As Pen = New Pen(clrInnerShadowBottom2)

Dim penInnerShadowBottom3 As Pen = New Pen(clrInnerShadowBottom3)

g.DrawLine(penInnerShadowBottom1, rcBorder.Left + 1, rcBorder.Bottom - 3, rcBorder.Right - 1, rcBorder.Bottom - 3)

g.DrawLine(penInnerShadowBottom2, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)

g.DrawLine(penInnerShadowBottom3, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)

penInnerShadowBottom1.Dispose()

penInnerShadowBottom2.Dispose()

penInnerShadowBottom3.Dispose()

Dim ptInnerShadowRight1a As Point = New Point(rcBorder.Right - 2, rcBorder.Top + 1)

Dim ptInnerShadowRight1b As Point = New Point(rcBorder.Right - 2, rcBorder.Bottom - 1)

Dim ptInnerShadowRight2a As Point = New Point(rcBorder.Right - 1, rcBorder.Top + 2)

Dim ptInnerShadowRight2b As Point = New Point(rcBorder.Right - 1, rcBorder.Bottom - 2)

Dim brushInnerShadowRight1 As LinearGradientBrush = New LinearGradientBrush(ptInnerShadowRight1a, ptInnerShadowRight1b, clrInnerShadowRight1a, clrInnerShadowRight1b)

Dim penInnerShadowRight1 As Pen = New Pen(brushInnerShadowRight1)

Dim brushInnerShadowRight2 As LinearGradientBrush = New LinearGradientBrush(ptInnerShadowRight2a, ptInnerShadowRight2b, clrInnerShadowRight2a, clrInnerShadowRight2b)

Dim penInnerShadowRight2 As Pen = New Pen(brushInnerShadowRight2)

g.DrawLine(penInnerShadowRight1, ptInnerShadowRight1a, ptInnerShadowRight1b)

g.DrawLine(penInnerShadowRight2, ptInnerShadowRight2a, ptInnerShadowRight2b)

penInnerShadowRight1.Dispose()

penInnerShadowRight2.Dispose()

brushInnerShadowRight1.Dispose()

brushInnerShadowRight2.Dispose()

Dim penTop As Pen = New Pen(Color.White)

g.DrawLine(penTop, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)

g.DrawLine(penTop, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)

g.DrawLine(penTop, rcBorder.Left + 1, rcBorder.Top + 3, rcBorder.Right - 1, rcBorder.Top + 3)

penTop.Dispose()

End If

End Sub

Private Sub DrawOuterShadow(ByVal g As Graphics)

Dim brushOuterShadow As LinearGradientBrush = New LinearGradientBrush(ClientRectangle, clrOuterShadow1, clrOuterShadow2, LinearGradientMode.Vertical)

g.FillRectangle(brushOuterShadow, ClientRectangle)

brushOuterShadow.Dispose()

End Sub

Private Sub DrawEllipseOuterShadow(ByVal g As Graphics)

Dim brushOuterShadow As LinearGradientBrush = New LinearGradientBrush(ClientRectangle, clrOuterShadow1, clrOuterShadow2, LinearGradientMode.Vertical)

g.FillRectangle(brushOuterShadow, ClientRectangle)

brushOuterShadow.Dispose()

End Sub

Private Sub DrawBorder(ByVal g As Graphics)

Dim penBorder As Pen = New Pen(clrBorder)

ControlPaint.DrawRoundedRectangle(g, penBorder, Me.BorderRectangle, sizeBorderPixelIndent)

penBorder.Dispose()

End Sub

Private Sub DrawEllipseBorder(ByVal g As Graphics)

Dim penBorder As Pen = New Pen(Color.FromArgb(0, 0, 0))

Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode

g.SmoothingMode = SmoothingMode.AntiAlias

g.DrawEllipse(penBorder, Me.BorderRectangle)

g.SmoothingMode = oldSmoothingMode

penBorder.Dispose()

End Sub

Private Sub DrawEllipseDefaultBorder(ByVal g As Graphics)

Dim penTop2 As Pen = New Pen(Color.FromArgb(137, 173, 228), 2)

Dim rcInFrame As Rectangle = New Rectangle(Me.BorderRectangle.X + 2, Me.BorderRectangle.Y + 1, Me.BorderRectangle.Width - 4, Me.BorderRectangle.Height - 2)

Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode

g.SmoothingMode = SmoothingMode.AntiAlias

g.DrawEllipse(penTop2, rcInFrame)

g.SmoothingMode = oldSmoothingMode

penTop2.Dispose()

End Sub

Private Sub DrawEllipseHoverBorder(ByVal g As Graphics)

Dim penTop2 As Pen = New Pen(Color.FromArgb(248, 178, 48), 2)

Dim rcInFrame As Rectangle = New Rectangle(Me.BorderRectangle.X + 2, Me.BorderRectangle.Y + 1, Me.BorderRectangle.Width - 4, Me.BorderRectangle.Height - 2)

Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode

g.SmoothingMode = SmoothingMode.AntiAlias

g.DrawEllipse(penTop2, rcInFrame)

g.SmoothingMode = oldSmoothingMode

penTop2.Dispose()

End Sub

#End Region

End Class

End Namespace

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有