使用 VB.NET 实现自定义特效动画按钮
Imports System.ComponentModel _
Public Class DSButton
Private _ButtonColor As Color = Color.White
Private SF As New System.Drawing.StringFormat
Private _Text As String
Public Property ButtonColor As Color
Get
Return _ButtonColor
End Get
Set(ByVal value As Color)
_ButtonColor = value
MakeRoundedRect(RoundRectValue, Me, Color.FromArgb(255, ButtonColor.R / 255 * 50, ButtonColor.G / 255 * 50, ButtonColor.B / 255 * 50))
End Set
End Property
Public Property RoundRectValue As Integer = 10
Private nIndex As Integer = 0
Private IsMouseEnter As Boolean = False
Public Property IsShowAnimate As Boolean = False
Public Property ButtonText As String
Get
Return _Text
End Get
Set(ByVal value As String)
_Text = value
MakeRoundedRect(RoundRectValue, Me, Color.FromArgb(255, ButtonColor.R / 255 * 50, ButtonColor.G / 255 * 50, ButtonColor.B / 255 * 50))
End Set
End Property
Private _TextColor As Color = Color.White
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(ByVal value As Color)
_TextColor = value
MakeRoundedRect(RoundRectValue, Me, Color.FromArgb(255, ButtonColor.R / 255 * 50, ButtonColor.G / 255 * 50, ButtonColor.B / 255 * 50))
End Set
End Property
' ... 其他代码 ...
End Class
这段代码展示了如何使用 VB.NET 创建一个自定义按钮类 DSButton
,并实现了以下功能:
- 自定义按钮颜色 (
ButtonColor
) - 圆角矩形按钮 (
RoundRectValue
) - 自定义按钮文本 (
ButtonText
) - 自定义文本颜色 (
TextColor
)
代码中使用了 MakeRoundedRect
函数来绘制圆角矩形按钮,并根据按钮颜色动态调整阴影效果。
圆角矩形.rar
预估大小:60个文件
圆角矩形
文件夹
圆角矩形.vbproj.user
143B
圆角矩形.vbproj
5KB
My Project
文件夹
Settings.settings
279B
AssemblyInfo.vb
1KB
Settings.Designer.vb
3KB
Application.Designer.vb
1KB
Resources.resx
5KB
Resources.Designer.vb
3KB
...
497.39KB
文件大小:
评论区