Solved

Button: Image on XP-Style button

Posted on 2004-08-25
17
549 Views
Last Modified: 2012-06-21
Is there a way to get a image on a button that has XP-Style

.. sorry that i don't can give more point.. my last points.. :(


Need help.. plz
0
Comment
Question by:NissePPP
  • 9
  • 8
17 Comments
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
VS says that MyXPButton.csproj is not installed.. ??
 i can't open the project..
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
thats exactly what i need.. hmm i hope i can convert it to VB.NET
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
I was just trying to do that for you

about not being able to open it: you might have not the ful VS.Net 2003 / or not fully installed
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
aha.. that's true.. :) i can try on my other computer..

if you can do that convert it to VB.NEt.. you are the king... :)
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
if you solve the convertion  you can go to this question
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21091207.html

i solved that my self.. but i can give you the points.. its 200 p.. just write something . so i can accept your answer
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
hehe.. working on it ;-)
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
btw: you COULD use only the compiled DLL (created in the 'source' project; used in the demo-project). You have to study the DEMO project how you should use it.. but its an option!
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:NissePPP
Comment Utility
oki
.. but if it's possible to convert it it wolud be great.. so i can change fkn in it later.. :)
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 25 total points
Comment Utility
Heee.. you can do very difficult or very easy!

just do this:

1) Find the myxpbutton.dll in the DEMO-project.
2) copy it to the directory of your new VB.NET project
3) Open your project
4) go to the TOOLBAR and do a right-click > "add remove items"
5) click browse and open the myxpbutton.dll
6) click OK and it will be added to you toolbar and you can add this to you project as a normal button but with MUCH more options!!

worked for me!
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
hehe.. thx for the help..

i have to try to convert the file later then.. :)

i would be nice to have it in code. :)

but thx anyway..
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
I have now the converted the sourcecode of the DLL.

Just put this into a new dll-project (exactly like the original c#.net project but now with vb.net code), compile it and do exactly as I described in my last post (11:58AM CEST), but now with the dll you got from this sourcecode:

----------------( ControlPaint.vb )-----------------------------------------------------------------------------------------------------------------------------

Imports Microsoft.VisualBasic
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D

Namespace MyXPButton
    NotInheritable Class ControlPaint

        Public Shared ReadOnly Property BorderColor() As Color
            Get
                Return Color.FromArgb(127, 157, 185)
            End Get
        End Property

        Public Shared ReadOnly Property DisabledBorderColor() As Color
            Get
                Return Color.FromArgb(201, 199, 186)
            End Get
        End Property

        Public Shared ReadOnly Property ButtonBorderColor() As Color
            Get
                Return Color.FromArgb(28, 81, 128)
            End Get
        End Property

        Public Shared ReadOnly Property DisabledButtonBorderColor() As Color
            Get
                Return Color.FromArgb(202, 200, 187)
            End Get
        End Property

        Public Shared ReadOnly Property DisabledBackColor() As Color
            Get
                Return Color.FromArgb(236, 233, 216)
            End Get
        End Property

        Public Shared ReadOnly Property DisabledForeColor() As Color
            Get
                Return Color.FromArgb(161, 161, 146)
            End Get
        End Property

        Public Shared Function GetStringFormat(contentAlignment As ContentAlignment) As StringFormat
            If Not [Enum].IsDefined(GetType(ContentAlignment), contentAlignment) Then
                Throw New InvalidEnumArgumentException("contentAlignment", contentAlignment, GetType(ContentAlignment))
            End If
            Dim stringFormat As StringFormat = New StringFormat()
            Dim contentAlignment2 As ContentAlignment = contentAlignment
            If contentAlignment2 <= ContentAlignment.MiddleCenter Then
                Select contentAlignment2
                Case ContentAlignment.TopCenter
                    stringFormat.LineAlignment = StringAlignment.Near
                    stringFormat.Alignment = StringAlignment.Center

                Case ContentAlignment.TopLeft
                    stringFormat.LineAlignment = StringAlignment.Near
                    stringFormat.Alignment = StringAlignment.Near

                Case ContentAlignment.TopRight
                    stringFormat.LineAlignment = StringAlignment.Near
                    stringFormat.Alignment = StringAlignment.Far

                Case CType(3, ContentAlignment)

                Case Else
                    If contentAlignment2 = ContentAlignment.MiddleLeft Then
                        stringFormat.LineAlignment = StringAlignment.Center
                        stringFormat.Alignment = StringAlignment.Near
                    ElseIf contentAlignment2 = ContentAlignment.MiddleCenter Then
                        stringFormat.LineAlignment = StringAlignment.Center
                        stringFormat.Alignment = StringAlignment.Center
                    End If
                End Select
            ElseIf contentAlignment2 <= ContentAlignment.BottomLeft Then
                If contentAlignment2 = ContentAlignment.MiddleRight Then
                    stringFormat.LineAlignment = StringAlignment.Center
                    stringFormat.Alignment = StringAlignment.Far
                ElseIf contentAlignment2 = ContentAlignment.BottomLeft Then
                    stringFormat.LineAlignment = StringAlignment.Far
                    stringFormat.Alignment = StringAlignment.Near
                End If
            ElseIf contentAlignment2 = ContentAlignment.BottomCenter Then
                stringFormat.LineAlignment = StringAlignment.Far
                stringFormat.Alignment = StringAlignment.Center
            ElseIf contentAlignment2 = ContentAlignment.BottomRight Then
                stringFormat.LineAlignment = StringAlignment.Far
                stringFormat.Alignment = StringAlignment.Far
            End If
            Dim stringFormat2 As StringFormat = stringFormat
            Return stringFormat2
        End Function

        Public Shared Sub DrawRoundedRectangle(g As Graphics, p As Pen, rc As Rectangle, size As Size)
            Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.DrawLine(p, Convert.ToSingle(rc.Left + size.Width / 2), rc.Top, Convert.ToSingle(rc.Right - size.Width / 2), rc.Top)
            g.DrawArc(p, rc.Right - size.Width, rc.Top, size.Width, size.Height, 270, 90)
            g.DrawLine(p, rc.Right, Convert.ToSingle(rc.Top + size.Height / 2), rc.Right, Convert.ToSingle(rc.Bottom - size.Height / 2))
            g.DrawArc(p, rc.Right - size.Width, rc.Bottom - size.Height, size.Width, size.Height, 0, 90)
            g.DrawLine(p, Convert.ToSingle(rc.Right - size.Width / 2), rc.Bottom, Convert.ToSingle(rc.Left + size.Width / 2), rc.Bottom)
            g.DrawArc(p, rc.Left, rc.Bottom - size.Height, size.Width, size.Height, 90, 90)
            g.DrawLine(p, rc.Left, Convert.ToSingle(rc.Bottom - size.Height / 2), rc.Left, Convert.ToSingle(rc.Top + size.Height / 2))
            g.DrawArc(p, rc.Left, rc.Top, size.Width, size.Height, 180, 90)
            g.SmoothingMode = oldSmoothingMode
        End Sub

        Public Shared Sub DrawBorder(g As Graphics, x As Integer, y As Integer, width As Integer, height As Integer)
            g.DrawRectangle(New Pen(BorderColor, 0.0F), x, y, width, height)
        End Sub

        Public Shared Sub EraseExcessOldDropDown(g As Graphics, newButton As Rectangle)
            g.FillRectangle(New SolidBrush(SystemColors.Window), newButton.X - 2, newButton.Y, 2, newButton.Height + 1)
        End Sub
    End Class
End Namespace

-----------------------------------------------------------------------------------------------------------------------------------------------------------------



----------------( MyXPButton.vb )-----------------------------------------------------------------------------------------------------------------------------

Imports Microsoft.VisualBasic
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.Windows.Forms

Namespace MyXPButton

    Public Class emunType
        Public Enum XPStyle
            [Default] = 0
            Blue = 1
            OliveGreen = 2
            Silver = 3
        End Enum

        Public Enum BtnShape
            Rectangle = 0
            Ellipse = 1
        End Enum
    End Class

    Public Class MyXPButton
        Inherits Button

        Public Enum ControlState
            Normal = 0
            Hover = 1
            Pressed = 2
            [Default] = 3
            Disabled = 4
        End Enum

        Private components As Container = Nothing

        Private enmState As ControlState = ControlState.Normal

        Private bCanClick As Boolean = False

        Private locPoint As Point

        Private Shared ReadOnly sizeBorderPixelIndent As Size

        Private Shared ReadOnly clrOuterShadow1 As Color = Color.FromArgb(64, 164, 164, 164)

        Private Shared ReadOnly clrOuterShadow2 As Color = Color.FromArgb(64, Color.White)

        Private Shared ReadOnly clrBackground1 As Color = Color.FromArgb(250, 250, 248)

        Private Shared ReadOnly clrBackground2 As Color = Color.FromArgb(240, 240, 234)

        Private Shared ReadOnly clrBorder As Color = Color.FromArgb(0, 60, 116)

        Private Shared ReadOnly clrInnerShadowBottom1 As Color = Color.FromArgb(236, 235, 230)

        Private Shared ReadOnly clrInnerShadowBottom2 As Color = Color.FromArgb(226, 223, 214)

        Private Shared ReadOnly clrInnerShadowBottom3 As Color = Color.FromArgb(214, 208, 197)

        Private Shared ReadOnly clrInnerShadowRight1a As Color = Color.FromArgb(128, 236, 234, 230)

        Private Shared ReadOnly clrInnerShadowRight1b As Color = Color.FromArgb(128, 224, 220, 212)

        Private Shared ReadOnly clrInnerShadowRight2a As Color = Color.FromArgb(128, 234, 228, 218)

        Private Shared ReadOnly clrInnerShadowRight2b As Color = Color.FromArgb(128, 212, 208, 196)

        Private Shared ReadOnly clrInnerShadowBottomPressed1 As Color = Color.FromArgb(234, 233, 227)

        Private Shared ReadOnly clrInnerShadowBottomPressed2 As Color = Color.FromArgb(242, 241, 238)

        Private Shared ReadOnly clrInnerShadowTopPressed1 As Color = Color.FromArgb(209, 204, 193)

        Private Shared ReadOnly clrInnerShadowTopPressed2 As Color = Color.FromArgb(220, 216, 207)

        Private Shared ReadOnly clrInnerShadowLeftPressed1 As Color = Color.FromArgb(216, 213, 203)

        Private Shared ReadOnly clrInnerShadowLeftPressed2 As Color = Color.FromArgb(222, 220, 211)

        Private m_btnStyle As emunType.XPStyle = emunType.XPStyle.Default

        Private m_btnShape As emunType.BtnShape = emunType.BtnShape.Rectangle


        Public Shadows Property FlatStyle() As FlatStyle
            Get
                Return MyBase.FlatStyle
            End Get

            Set(ByVal value As FlatStyle)
                MyBase.FlatStyle = FlatStyle.Standard
            End Set
        End Property

        Public Property BtnShape() As emunType.BtnShape
            Get
                Return m_btnShape
            End Get

            Set(ByVal value As emunType.BtnShape)
                m_btnShape = value
                MyBase.Invalidate()
            End Set
        End Property

        <DefaultValueAttribute("Blue"), _
        RefreshPropertiesAttribute(RefreshProperties.Repaint)> _
        Public Property BtnStyle() As emunType.XPStyle
            Get
                Return m_btnStyle
            End Get

            Set(ByVal value As emunType.XPStyle)
                m_btnStyle = value
                MyBase.Invalidate()
            End Set
        End Property

        Public Property AdjustImageLocation() As Point
            Get
                Return locPoint
            End Get

            Set(ByVal value As Point)
                locPoint = value
                MyBase.Invalidate()
            End Set
        End Property

        Private ReadOnly Property BorderRectangle() As Rectangle
            Get
                Dim rc As Rectangle = MyBase.ClientRectangle
                Return New Rectangle(1, 1, rc.Width - 3, rc.Height - 3)
            End Get
        End Property

        Public Sub New()
            InitializeComponent()
            MyBase.SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer, True)
        End Sub

        Shared Sub New()
            sizeBorderPixelIndent = New Size(4, 4)
        End Sub

        Protected Overrides Sub OnClick(ByVal ea As EventArgs)
            MyBase.Capture = False
            bCanClick = False
            If MyBase.ClientRectangle.Contains(MyBase.PointToClient(Control.MousePosition)) Then
                enmState = ControlState.Hover
            Else
                enmState = ControlState.Normal
            End If
            MyBase.Invalidate()
            MyBase.OnClick(ea)
        End Sub

        Protected Overrides Sub OnMouseEnter(ByVal ea As EventArgs)
            MyBase.OnMouseEnter(ea)
            enmState = ControlState.Hover
            MyBase.Invalidate()
        End Sub

        Protected Overrides Sub OnMouseDown(ByVal mea As MouseEventArgs)
            MyBase.OnMouseDown(mea)
            If mea.Button = MouseButtons.Left Then
                bCanClick = True
                enmState = ControlState.Pressed
                MyBase.Invalidate()
            End If
        End Sub

        Protected Overrides Sub OnMouseMove(ByVal mea As MouseEventArgs)
            MyBase.OnMouseMove(mea)
            If MyBase.ClientRectangle.Contains(mea.X, mea.Y) Then
                If enmState = ControlState.Hover AndAlso MyBase.Capture AndAlso Not bCanClick Then
                    bCanClick = True
                    enmState = ControlState.Pressed
                    MyBase.Invalidate()
                End If
            ElseIf enmState = ControlState.Pressed Then
                bCanClick = False
                enmState = ControlState.Hover
                MyBase.Invalidate()
            End If
        End Sub

        Protected Overrides Sub OnMouseLeave(ByVal ea As EventArgs)
            MyBase.OnMouseLeave(ea)
            enmState = ControlState.Normal
            MyBase.Invalidate()
        End Sub

        Protected Overrides Sub OnPaint(ByVal pea As PaintEventArgs)
            OnPaintBackground(pea)
            Select Case enmState
                Case ControlState.Normal
                    If Not MyBase.Enabled Then
                        OnDrawDisabled(pea.Graphics)
                    ElseIf Focused OrElse MyBase.IsDefault Then
                        Select Case m_btnShape
                            Case emunType.BtnShape.Rectangle
                                OnDrawDefault(pea.Graphics)

                            Case emunType.BtnShape.Ellipse
                                OnDrawDefaultEllipse(pea.Graphics)
                        End Select
                    Else
                        Select Case m_btnShape
                            Case emunType.BtnShape.Rectangle
                                OnDrawNormal(pea.Graphics)

                            Case emunType.BtnShape.Ellipse
                                OnDrawNormalEllipse(pea.Graphics)
                        End Select
                    End If

                Case ControlState.Hover
                    Select Case m_btnShape
                        Case emunType.BtnShape.Rectangle
                            OnDrawHover(pea.Graphics)

                        Case emunType.BtnShape.Ellipse
                            OnDrawHoverEllipse(pea.Graphics)

                        Case Else
                            Exit Select
                    End Select

                Case ControlState.Pressed
                    Select Case m_btnShape
                        Case emunType.BtnShape.Rectangle
                            OnDrawPressed(pea.Graphics)

                        Case emunType.BtnShape.Ellipse
                            OnDrawPressedEllipse(pea.Graphics)

                        Case Else
                            Exit Select
                    End Select
            End Select
            OnDrawTextAndImage(pea.Graphics)
        End Sub

        Protected Overrides Sub OnEnabledChanged(ByVal ea As EventArgs)
            MyBase.OnEnabledChanged(ea)
            enmState = ControlState.Normal
            MyBase.Invalidate()
        End Sub

        Private Sub OnDrawNormal(ByVal g As Graphics)
            DrawNormalButton(g)
        End Sub

        Private Sub OnDrawHoverEllipse(ByVal g As Graphics)
            DrawNormalEllipse(g)
            DrawEllipseHoverBorder(g)
            DrawEllipseBorder(g)
        End Sub

        Private Sub OnDrawHover(ByVal g As Graphics)
            DrawNormalButton(g)
            Dim rcBorder As Rectangle = BorderRectangle
            Dim penTop1 As Pen = New Pen(Color.FromArgb(255, 240, 207))
            Dim penTop2 As Pen = New Pen(Color.FromArgb(253, 216, 137))
            g.DrawLine(penTop1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)
            g.DrawLine(penTop2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)
            penTop1.Dispose()
            penTop2.Dispose()
            Dim penBottom1 As Pen = New Pen(Color.FromArgb(248, 178, 48))
            Dim penBottom2 As Pen = New Pen(Color.FromArgb(229, 151, 0))
            g.DrawLine(penBottom1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)
            g.DrawLine(penBottom2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)
            penBottom1.Dispose()
            penBottom2.Dispose()
            Dim rcLeft As Rectangle = New Rectangle(rcBorder.Left + 1, rcBorder.Top + 3, 2, rcBorder.Height - 5)
            Dim rcRight As Rectangle = New Rectangle(rcBorder.Right - 2, rcBorder.Top + 3, 2, rcBorder.Height - 5)
            Dim brushSide As LinearGradientBrush = New LinearGradientBrush(rcLeft, Color.FromArgb(254, 221, 149), Color.FromArgb(249, 180, 53), LinearGradientMode.Vertical)
            g.FillRectangle(brushSide, rcLeft)
            g.FillRectangle(brushSide, rcRight)
            brushSide.Dispose()
        End Sub

        Private Sub OnDrawPressedEllipse(ByVal g As Graphics)
            DrawPressedEllipse(g)
            DrawEllipseBorder(g)
        End Sub

        Private Sub DrawPressedEllipse(ByVal g As Graphics)
            Dim rcBorder As Rectangle = BorderRectangle
            Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)
            Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(226, 225, 218))
            g.FillEllipse(brushBackground, rcBackground)
        End Sub

        Private Sub OnDrawPressed(ByVal g As Graphics)
            Dim rcBorder As Rectangle = BorderRectangle
            DrawOuterShadow(g)
            Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)
            Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(226, 225, 218))
            g.FillRectangle(brushBackground, rcBackground)
            brushBackground.Dispose()
            DrawBorder(g)
            Dim penInnerShadowBottomPressed1 As Pen = New Pen(clrInnerShadowBottomPressed1)
            Dim penInnerShadowBottomPressed2 As Pen = New Pen(clrInnerShadowBottomPressed2)
            g.DrawLine(penInnerShadowBottomPressed1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)
            g.DrawLine(penInnerShadowBottomPressed2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)
            penInnerShadowBottomPressed1.Dispose()
            penInnerShadowBottomPressed2.Dispose()
            Dim penInnerShadowTopPressed1 As Pen = New Pen(clrInnerShadowTopPressed1)
            Dim penInnerShadowTopPressed2 As Pen = New Pen(clrInnerShadowTopPressed2)
            g.DrawLine(penInnerShadowTopPressed1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)
            g.DrawLine(penInnerShadowTopPressed2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)
            penInnerShadowTopPressed1.Dispose()
            penInnerShadowTopPressed2.Dispose()
            Dim penInnerShadowLeftPressed1 As Pen = New Pen(clrInnerShadowLeftPressed1)
            Dim penInnerShadowLeftPressed2 As Pen = New Pen(clrInnerShadowLeftPressed2)
            g.DrawLine(penInnerShadowLeftPressed1, rcBorder.Left + 1, rcBorder.Top + 3, rcBorder.Left + 1, rcBorder.Bottom - 3)
            g.DrawLine(penInnerShadowLeftPressed2, rcBorder.Left + 2, rcBorder.Top + 3, rcBorder.Left + 2, rcBorder.Bottom - 3)
            penInnerShadowLeftPressed1.Dispose()
            penInnerShadowLeftPressed2.Dispose()
        End Sub

        Private Sub OnDrawNormalEllipse(ByVal g As Graphics)
            DrawNormalEllipse(g)
            DrawEllipseBorder(g)
        End Sub

        Private Sub OnDrawDefaultEllipse(ByVal g As Graphics)
            DrawNormalEllipse(g)
            DrawEllipseDefaultBorder(g)
            DrawEllipseBorder(g)
        End Sub

        Private Sub OnDrawDefault(ByVal g As Graphics)
            DrawNormalButton(g)
            Dim rcBorder As Rectangle = BorderRectangle
            Dim penTop1 As Pen = New Pen(Color.FromArgb(206, 231, 255))
            Dim penTop2 As Pen = New Pen(Color.FromArgb(188, 212, 246))
            g.DrawLine(penTop1, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)
            g.DrawLine(penTop2, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)
            penTop1.Dispose()
            penTop2.Dispose()
            Dim penBottom1 As Pen = New Pen(Color.FromArgb(137, 173, 228))
            Dim penBottom2 As Pen = New Pen(Color.FromArgb(105, 130, 238))
            g.DrawLine(penBottom1, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)
            g.DrawLine(penBottom2, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)
            penBottom1.Dispose()
            penBottom2.Dispose()
            Dim rcLeft As Rectangle = New Rectangle(rcBorder.Left + 1, rcBorder.Top + 3, 2, rcBorder.Height - 5)
            Dim rcRight As Rectangle = New Rectangle(rcBorder.Right - 2, rcBorder.Top + 3, 2, rcBorder.Height - 5)
            Dim brushSide As LinearGradientBrush = New LinearGradientBrush(rcLeft, Color.FromArgb(186, 211, 245), Color.FromArgb(137, 173, 228), LinearGradientMode.Vertical)
            g.FillRectangle(brushSide, rcLeft)
            g.FillRectangle(brushSide, rcRight)
            brushSide.Dispose()
        End Sub

        Private Sub OnDrawDisabled(ByVal g As Graphics)
            Dim rcBorder As Rectangle = BorderRectangle
            Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)
            Dim brushBackground As SolidBrush = New SolidBrush(Color.FromArgb(245, 244, 234))
            g.FillRectangle(brushBackground, rcBackground)
            brushBackground.Dispose()
            Dim penBorder As Pen = New Pen(Color.FromArgb(201, 199, 186))
            ControlPaint.DrawRoundedRectangle(g, penBorder, rcBorder, sizeBorderPixelIndent)
            penBorder.Dispose()
        End Sub

        Private Sub OnDrawTextAndImage(ByVal g As Graphics)
            Dim brushText As SolidBrush

            If MyBase.Enabled Then
                brushText = New SolidBrush(ForeColor)
            Else
                brushText = New SolidBrush(ControlPaint.DisabledForeColor)
            End If
            Dim sf As StringFormat = ControlPaint.GetStringFormat(TextAlign)
            sf.HotkeyPrefix = HotkeyPrefix.Show
            If Not MyBase.Image Is Nothing Then
                Dim rc As Rectangle = New Rectangle
                Dim ImagePoint As Point = New Point(6, 4)
                Dim contentAlignment As contentAlignment = MyBase.ImageAlign
                If contentAlignment = contentAlignment.TopCenter Then
                    ImagePoint.Y = 2
                    ImagePoint.X = (MyBase.ClientRectangle.Width - MyBase.Image.Width) / 2
                    rc.Width = MyBase.ClientRectangle.Width
                    rc.Height = MyBase.ClientRectangle.Height - MyBase.Image.Height - 4
                    rc.X = MyBase.ClientRectangle.X
                    rc.Y = MyBase.Image.Height
                ElseIf contentAlignment = contentAlignment.MiddleCenter Then
                    ImagePoint.X = (MyBase.ClientRectangle.Width - MyBase.Image.Width) / 2
                    ImagePoint.Y = (MyBase.ClientRectangle.Height - MyBase.Image.Height) / 2
                    rc.Width = 0
                    rc.Height = 0
                    rc.X = MyBase.ClientRectangle.Width
                    rc.Y = MyBase.ClientRectangle.Height
                ElseIf contentAlignment <> contentAlignment.MiddleRight Then
                    ImagePoint.X = 6
                    ImagePoint.Y = MyBase.ClientRectangle.Height / 2 - MyBase.Image.Height / 2
                    rc.Width = MyBase.ClientRectangle.Width - MyBase.Image.Width
                    rc.Height = MyBase.ClientRectangle.Height
                    rc.X = MyBase.Image.Width
                    rc.Y = 0
                Else
                    rc.Width = MyBase.ClientRectangle.Width - MyBase.Image.Width - 8
                    rc.Height = MyBase.ClientRectangle.Height
                    rc.X = 0
                    rc.Y = 0
                    ImagePoint.X = rc.Width
                    ImagePoint.Y = MyBase.ClientRectangle.Height / 2 - MyBase.Image.Height / 2
                End If
                ImagePoint.X = ImagePoint.X + locPoint.X
                ImagePoint.Y = ImagePoint.Y + locPoint.Y
                If MyBase.Enabled Then
                    g.DrawImage(MyBase.Image, ImagePoint)
                Else
                    System.Windows.Forms.ControlPaint.DrawImageDisabled(g, MyBase.Image, locPoint.X, locPoint.Y, BackColor)
                End If
                If contentAlignment.MiddleCenter <> MyBase.ImageAlign Then
                    g.DrawString(Text, Font, brushText, RectangleF.op_Implicit(rc), sf)
                End If
            Else
                g.DrawString(Text, Font, brushText, RectangleF.op_Implicit(MyBase.ClientRectangle), sf)
            End If
            brushText.Dispose()
            sf.Dispose()
        End Sub

        Private Sub DrawNormalEllipse(ByVal g As Graphics)
            Dim rcBackground As Rectangle = BorderRectangle
            Dim brushBackground As LinearGradientBrush = Nothing
            Select Case m_btnStyle
                Case emunType.XPStyle.Default
                    brushBackground = New LinearGradientBrush(rcBackground, clrBackground1, clrBackground2, LinearGradientMode.Vertical)

                Case emunType.XPStyle.Blue
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical)

                Case emunType.XPStyle.OliveGreen
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical)

                Case emunType.XPStyle.Silver
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical)
            End Select
            Dim fs1 As Single() = New Single(2) {}
            fs1(1) = 0.008F
            fs1(2) = 1.0F
            Dim relativeIntensities As Single() = fs1
            Dim fs2 As Single() = New Single(2) {}
            fs2(1) = 0.22F
            fs2(2) = 1.0F
            Dim relativePositions As Single() = fs2
            Dim blend As blend = New blend
            blend.Factors = relativeIntensities
            blend.Positions = relativePositions
            brushBackground.Blend = blend
            g.FillEllipse(brushBackground, rcBackground)
        End Sub

        Private Sub DrawNormalButton(ByVal g As Graphics)
            Dim rcBorder As Rectangle = BorderRectangle
            DrawOuterShadow(g)
            Dim rcBackground As Rectangle = New Rectangle(rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1)
            Dim brushBackground As LinearGradientBrush = Nothing
            Select Case m_btnStyle
                Case emunType.XPStyle.Default
                    brushBackground = New LinearGradientBrush(rcBackground, clrBackground1, clrBackground2, LinearGradientMode.Vertical)

                Case emunType.XPStyle.Blue
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical)

                Case emunType.XPStyle.OliveGreen
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical)

                Case emunType.XPStyle.Silver
                    brushBackground = New LinearGradientBrush(rcBackground, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical)
            End Select
            Dim fs1 As Single() = New Single(2) {}
            fs1(1) = 0.08F
            fs1(2) = 1.0F
            Dim relativeIntensities As Single() = fs1
            Dim fs2 As Single() = New Single(2) {}
            fs2(1) = 0.32F
            fs2(2) = 1.0F
            Dim relativePositions As Single() = fs2
            Dim blend As blend = New blend
            blend.Factors = relativeIntensities
            blend.Positions = relativePositions
            brushBackground.Blend = blend
            g.FillRectangle(brushBackground, rcBackground)
            brushBackground.Dispose()
            DrawBorder(g)
            If m_btnStyle = emunType.XPStyle.Default Then
                Dim penInnerShadowBottom1 As Pen = New Pen(clrInnerShadowBottom1)
                Dim penInnerShadowBottom2 As Pen = New Pen(clrInnerShadowBottom2)
                Dim penInnerShadowBottom3 As Pen = New Pen(clrInnerShadowBottom3)
                g.DrawLine(penInnerShadowBottom1, rcBorder.Left + 1, rcBorder.Bottom - 3, rcBorder.Right - 1, rcBorder.Bottom - 3)
                g.DrawLine(penInnerShadowBottom2, rcBorder.Left + 1, rcBorder.Bottom - 2, rcBorder.Right - 1, rcBorder.Bottom - 2)
                g.DrawLine(penInnerShadowBottom3, rcBorder.Left + 2, rcBorder.Bottom - 1, rcBorder.Right - 2, rcBorder.Bottom - 1)
                penInnerShadowBottom1.Dispose()
                penInnerShadowBottom2.Dispose()
                penInnerShadowBottom3.Dispose()
                Dim ptInnerShadowRight1a As Point = New Point(rcBorder.Right - 2, rcBorder.Top + 1)
                Dim ptInnerShadowRight1b As Point = New Point(rcBorder.Right - 2, rcBorder.Bottom - 1)
                Dim ptInnerShadowRight2a As Point = New Point(rcBorder.Right - 1, rcBorder.Top + 2)
                Dim ptInnerShadowRight2b As Point = New Point(rcBorder.Right - 1, rcBorder.Bottom - 2)
                Dim brushInnerShadowRight1 As LinearGradientBrush = New LinearGradientBrush(ptInnerShadowRight1a, ptInnerShadowRight1b, clrInnerShadowRight1a, clrInnerShadowRight1b)
                Dim penInnerShadowRight1 As Pen = New Pen(brushInnerShadowRight1)
                Dim brushInnerShadowRight2 As LinearGradientBrush = New LinearGradientBrush(ptInnerShadowRight2a, ptInnerShadowRight2b, clrInnerShadowRight2a, clrInnerShadowRight2b)
                Dim penInnerShadowRight2 As Pen = New Pen(brushInnerShadowRight2)
                g.DrawLine(penInnerShadowRight1, ptInnerShadowRight1a, ptInnerShadowRight1b)
                g.DrawLine(penInnerShadowRight2, ptInnerShadowRight2a, ptInnerShadowRight2b)
                penInnerShadowRight1.Dispose()
                penInnerShadowRight2.Dispose()
                brushInnerShadowRight1.Dispose()
                brushInnerShadowRight2.Dispose()
                Dim penTop As Pen = New Pen(Color.White)
                g.DrawLine(penTop, rcBorder.Left + 2, rcBorder.Top + 1, rcBorder.Right - 2, rcBorder.Top + 1)
                g.DrawLine(penTop, rcBorder.Left + 1, rcBorder.Top + 2, rcBorder.Right - 1, rcBorder.Top + 2)
                g.DrawLine(penTop, rcBorder.Left + 1, rcBorder.Top + 3, rcBorder.Right - 1, rcBorder.Top + 3)
                penTop.Dispose()
            End If
        End Sub

        Private Sub DrawOuterShadow(ByVal g As Graphics)
            Dim brushOuterShadow As LinearGradientBrush = New LinearGradientBrush(MyBase.ClientRectangle, clrOuterShadow1, clrOuterShadow2, LinearGradientMode.Vertical)
            g.FillRectangle(brushOuterShadow, MyBase.ClientRectangle)
            brushOuterShadow.Dispose()
        End Sub

        Private Sub DrawEllipseOuterShadow(ByVal g As Graphics)
            Dim brushOuterShadow As LinearGradientBrush = New LinearGradientBrush(MyBase.ClientRectangle, clrOuterShadow1, clrOuterShadow2, LinearGradientMode.Vertical)
            g.FillRectangle(brushOuterShadow, MyBase.ClientRectangle)
            brushOuterShadow.Dispose()
        End Sub

        Private Sub DrawBorder(ByVal g As Graphics)
            Dim penBorder As Pen = New Pen(clrBorder)
            ControlPaint.DrawRoundedRectangle(g, penBorder, BorderRectangle, sizeBorderPixelIndent)
            penBorder.Dispose()
        End Sub

        Private Sub DrawEllipseBorder(ByVal g As Graphics)
            Dim penBorder As Pen = New Pen(Color.FromArgb(0, 0, 0))
            Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.DrawEllipse(penBorder, BorderRectangle)
            g.SmoothingMode = oldSmoothingMode
            penBorder.Dispose()
        End Sub

        Private Sub DrawEllipseDefaultBorder(ByVal g As Graphics)
            Dim penTop2 As Pen = New Pen(Color.FromArgb(137, 173, 228), 2.0F)
            Dim rcInFrame As Rectangle = New Rectangle(BorderRectangle.X + 2, BorderRectangle.Y + 1, BorderRectangle.Width - 4, BorderRectangle.Height - 2)
            Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.DrawEllipse(penTop2, rcInFrame)
            g.SmoothingMode = oldSmoothingMode
            penTop2.Dispose()
        End Sub

        Private Sub DrawEllipseHoverBorder(ByVal g As Graphics)
            Dim penTop2 As Pen = New Pen(Color.FromArgb(248, 178, 48), 2.0F)
            Dim rcInFrame As Rectangle = New Rectangle(BorderRectangle.X + 2, BorderRectangle.Y + 1, BorderRectangle.Width - 4, BorderRectangle.Height - 2)
            Dim oldSmoothingMode As SmoothingMode = g.SmoothingMode
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.DrawEllipse(penTop2, rcInFrame)
            g.SmoothingMode = oldSmoothingMode
            penTop2.Dispose()
        End Sub

        Protected Overloads Sub Dispose(ByVal disposing As Boolean)
            If disposing AndAlso Not components Is Nothing Then
                components.Dispose()
            End If
            MyBase.Dispose(disposing)
        End Sub

        Private Sub InitializeComponent()
            components = New Container
        End Sub
    End Class
End Namespace

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
btw: this works!

Why a grade B? This is a complete answer isn't it ??
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
now it is.. i accepted before you put the code here,, sorry.. but go to the link above
0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
post something in the link i posted before.... so i can give you the points


you are the man... hehe.. thx.. m8
0
 
LVL 4

Expert Comment

by:Daniellus83
Comment Utility
thank you so much... It's funny how fast I converted this code ;)  I hope to break the next Olympics the worldrecord cs>vb-code-converting ...

0
 
LVL 1

Author Comment

by:NissePPP
Comment Utility
hehe you did a very nice jobb.. i don't understand how you did it.. but VB.NET and C# you know how to work,,
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now