MBGlassPanel 使用 VB.NET 2008






3.75/5 (7投票s)
MBGlassPanel 具有 Microsoft Office 功能区视觉风格
引言
为什么需要另一个Panel
?这是一个具有 Microsoft Office Ribbon 视觉风格的用户控件。它使用起来很简单,只需将其拖放到窗体上,并像使用普通的 Panel 一样使用它。
背景
MBPanel
是一个继承了简单 Panel 控件所有属性的 Panel。我在 MBPanel
中添加了类似 Microsoft Office Ribbon 的视觉效果。使用的语言是 VB.NET。要在您的应用程序或项目中使用的控制,只需添加 MBPanel.Dll
的引用,然后通过拖放来使用它。
使用代码
这个 MBPanel
的概念来自于 Microsoft Office Ribbon Panel。我将 MBPanel
的方法组织成如下层级:
以下方法负责渲染像 Microsoft Office Ribbon Panel 这样的简单 Panel。此方法渲染 MBPanel
的背景。
''' <summary>
''' Paint Backround Surface Of MBPanel
''' </summary />
Private Sub PaintBackgoundSurface(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
With e.Graphics
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
.CompositingQuality = CompositingQuality.HighQuality
End With
Dim brGlass As New SolidBrush(Color.FromArgb(CheckOpacity(Opacity), _
GlassColor.R, GlassColor.G, GlassColor.B))
e.Graphics.FillPath(brGlass, RoundSurface)
PaintHorizontalSurface(sender, e)
PaintGlowSurface(sender, e)
PaintReflectiveBands(sender, e)
PaintLightSource(sender, e)
End Sub
此方法为 MBPanel
绘制反射带。
''' <summary>
''' Paint ReflectiveBands for MBPanel
''' </summary />
Private Sub PaintReflectiveBands(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim brGlassReflect As New SolidBrush(Color.FromArgb(CheckOpacity(Opacity * 0.5), GlassColor.R, GlassColor.G, GlassColor.B))
Dim grpBand1 As GraphicsPath = CreateReflectiveBand(0.1!, 0.5!, 0.15!)
Dim grpBand2 As GraphicsPath = CreateReflectiveBand(0.4!, 0.8!, 0.1!)
e.Graphics.FillPath(brGlassReflect, grpBand1)
e.Graphics.FillPath(brGlassReflect, grpBand2)
End Sub
此方法为 MBPanel
绘制反射带。
''' <summary>
''' Paint ReflectiveBands for MBPanel
''' </summary />
Private Sub PaintReflectiveBands(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim brGlassReflect As New SolidBrush(Color.FromArgb(CheckOpacity(Opacity * 0.5), GlassColor.R, GlassColor.G, GlassColor.B))
Dim grpBand1 As GraphicsPath = CreateReflectiveBand(0.1!, 0.5!, 0.15!)
Dim grpBand2 As GraphicsPath = CreateReflectiveBand(0.4!, 0.8!, 0.1!)
e.Graphics.FillPath(brGlassReflect, grpBand1)
e.Graphics.FillPath(brGlassReflect, grpBand2)
End Sub
此方法为 MBPanel
绘制边框。
''' <summary>
''' Paint Border of MBPanel
''' </summary />
Private Sub PaintBorder(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
If _BorderStyle = MBBorderStyle.Rounded Then
e.Graphics.DrawPath(New Pen(Color.FromArgb(200, 255, 255, 255), 0.5!), RoundSurface)
e.Graphics.DrawPath(New Pen(Color.FromArgb(255, 0, 0, 0), 0.5!), RoundSurfaceInner)
End If
End Sub
如何使用
在您的应用程序中使用 MBPanel
非常容易。只需将提供的 DLL 的引用添加到您的应用程序,然后拖放即可。
历史
MBPanel
版本 1.0。