Click here to Skip to main content
15,884,684 members
Articles / Multimedia / GDI+

Creating Glow Button

Rate me:
Please Sign up or sign in to vote.
4.86/5 (23 votes)
24 Apr 20073 min read 128.8K   5.8K   83  
An article of how to make a button that can glow
Imports System.Drawing

Public Class GlassColorTable
    Implements IGlassColor

    Protected _BackgroundHigh As Color
    Protected _BackgroundLow As Color
    Protected _ShineHigh As Color
    Protected _ShineLow As Color
    Protected _BorderLeft As Color
    Protected _BorderRight As Color
    Protected _BorderTop As Color
    Protected _BorderBottom As Color
    Protected _TextColor As Color
    Protected _GlowCenter As Color

    Private _State As IGlassColor.States
    Private _cSet As ColorSet

    Public Overridable ReadOnly Property BackgroundLow() As Color
        Get
            Return _BackgroundHigh
        End Get
    End Property

    Public Overridable ReadOnly Property BackgroundHigh() As Color
        Get
            Return _BackgroundLow
        End Get
    End Property

    Public Overridable ReadOnly Property ShineHigh() As Color
        Get
            Return _ShineHigh
        End Get
    End Property

    Public Overridable ReadOnly Property ShineLow() As Color
        Get
            Return _ShineLow
        End Get
    End Property

    Public Overridable ReadOnly Property BorderTop() As Color
        Get
            Return _BorderTop
        End Get
    End Property

    Public Overridable ReadOnly Property BorderLeft() As Color
        Get
            Return _BorderLeft
        End Get
    End Property

    Public Overridable ReadOnly Property BorderRight() As Color
        Get
            Return _BorderRight
        End Get
    End Property

    Public Overridable ReadOnly Property BorderBottom() As Color
        Get
            Return _BorderBottom
        End Get
    End Property

    Public Overridable ReadOnly Property TextColor() As Color
        Get
            Return _TextColor
        End Get
    End Property

    Public Overridable ReadOnly Property GlowCenter() As Color
        Get
            Return _GlowCenter
        End Get
    End Property

    Public Property Renderer() As ColorSet
        Get
            Return _cSet
        End Get
        Set(ByVal value As ColorSet)
            _cSet = value

            'Set Glow that can't affect from State
            _GlowCenter = _cSet.GlowCenter
        End Set
    End Property

    Public Property State() As IGlassColor.States
        Get
            Return _State
        End Get
        Set(ByVal value As IGlassColor.States)
            _State = value

            Select Case _State
                Case IGlassColor.States.Disabled
                    Me.DisabledState()
                Case IGlassColor.States.Highlighted
                    Me.HighlightState()
                Case IGlassColor.States.Normal
                    Me.NormalState()
                Case IGlassColor.States.Pressed
                    Me.PressedState()
            End Select
        End Set
    End Property

    Public Sub DisabledState() Implements IGlassColor.DisabledState

    End Sub

    Public Sub HighlightState() Implements IGlassColor.HighlightState
        _BackgroundHigh = _cSet.BackgroundHighFocus
        _BackgroundLow = _cSet.BackgroundLowFocus
        _ShineHigh = _cSet.ShineHighFocus
        _ShineLow = _cSet.ShineLowFocus
        _BorderLeft = _cSet.BorderLeftFocus
        _BorderRight = _cSet.BorderRightFocus
        _BorderTop = _cSet.BorderTopFocus
        _BorderBottom = _cSet.BorderBottomFocus
        _TextColor = _cSet.TextColorFocus
    End Sub

    Public Sub NormalState() Implements IGlassColor.NormalState
        _BackgroundHigh = _cSet.BackgroundHigh
        _BackgroundLow = _cSet.BackgroundLow
        _ShineHigh = _cSet.ShineHigh
        _ShineLow = _cSet.ShineLow
        _BorderLeft = _cSet.BorderLeft
        _BorderRight = _cSet.BorderRight
        _BorderTop = _cSet.BorderTop
        _BorderBottom = _cSet.BorderBottom
        _TextColor = _cSet.TextColor
    End Sub

    Public Sub PressedState() Implements IGlassColor.PressedState
        _BackgroundHigh = _cSet.BackgroundHighPressed
        _BackgroundLow = _cSet.BackgroundLowPressed
        _ShineHigh = _cSet.ShineHighPressed
        _ShineLow = _cSet.ShineLowPressed
        _BorderLeft = _cSet.BorderLeftPressed
        _BorderRight = _cSet.BorderRightPressed
        _BorderTop = _cSet.BorderTopPressed
        _BorderBottom = _cSet.BorderBottomPressed
        _TextColor = _cSet.TextColorPressed
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Team Leader Component Crafts
Indonesia Indonesia
Got his BA in Information and Technology from University of Surabaya, Indonesia in 2004. Finished his post graduate at Magistrate and Management Institute of Technology, Surabaya in 2009.

He has developed several middle to large scale enterprise application, mostly on windows based architecture.

Currently working as IT Manager on a company based on Sidoarjo.

Comments and Discussions