Click here to Skip to main content
15,881,803 members
Articles / Multimedia / GDI

MBGlassPanel Using VB.NET 2008

Rate me:
Please Sign up or sign in to vote.
3.75/5 (7 votes)
9 Jul 2012CPOL 27.1K   2.1K   13   3
MBGlassPanel with Microsoft Office Ribbon Visual Style

Image 1

Introduction

Why another Panel? This is a User Control with Microsoft Office Ribbon Visual Style. It is simple to use, just drop it on the form, and use it like the normal Panel.

Background

MBPanel is a Panel which inherits all the properties of simple Panel control. I added Microsoft Office Ribbon like Visuals in MBPanel. The language used is VB.NET. To Use this Control in your Application or Project You Just add the reference of MBPanel.Dll and used it by Dragging and Dropping.

Using the code

The concept for this MBPanel came from the Microsoft Office Ribbon Panel. I organized methods of MBPanel into layers like this:

Following methods which are responsible for rendering simple Panel like Microsoft office Ribbon Panel. This method Render Background of MBPanel:

VB.NET
''' <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

This method Paint Reflective Bands for MBPanel:

VB.NET
 ''' <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 

This method Paint Reflective Bands for MBPanel:

VB.NET
''' <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

This method Paint Border for MBPanel:

VB.NET
''' <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

How to use

Image 2

It is very easy to use the MBPanel in your application. Just add the reference of the provided DLL to your application and just drag and drop.

History

  • MBPanel Version 1.0.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
It always seems good to hear about me, but the thing I do is I code. I'm Interested in Designing Windows Based Application, Web Applications and building Mobile Applications. Currently restricting it to Android 4.0 applications, building Internet Based Applications using ASP.NET and contributing to bring the student community to a position which will help technology to reach the greatest heights ever. A very Big fan of Microsoft & Android..!!

Comments and Discussions

 
GeneralMy vote of 4 Pin
rspercy659-Jul-12 13:07
rspercy659-Jul-12 13:07 
GeneralThis has already been done Pin
rspercy659-Jul-12 13:02
rspercy659-Jul-12 13:02 
GeneralMy vote of 1 Pin
Dave Kreskowiak9-Jul-12 12:13
mveDave Kreskowiak9-Jul-12 12:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.