Click here to Skip to main content
Click here to Skip to main content

MBGlassPanel Using VB.NET 2008

By , 9 Jul 2012
 

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:

''' <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:

 ''' <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:

''' <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:

''' <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

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)

About the Author

Manoj K Bhoir
Software Developer
India India
Member
It always seems good to hear about me, but the thing I do is I code. I'm Interested in Designing Windows Based Application, 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..!!

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 4memberrspercy659 Jul '12 - 13:07 
You need to add more content on how the code actually works. Dont feel bad because I use to get the same grieve when I first started writing stuff for my articles. Dont worry to much about what other people here at CP has to say. You will get better at this.
GeneralThis has already been donememberrspercy659 Jul '12 - 13:02 
Look at this link... A Reflective and Translucent Glass Panel[^]
 
I do like your control though.
rspercy65

GeneralMy vote of 1mvpDave Kreskowiak9 Jul '12 - 12:13 
I don't know who approved this as an article, but it's nothing more than a code dump.

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 9 Jul 2012
Article Copyright 2012 by Manoj K Bhoir
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid