Results 1 to 40 of 49

Thread: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Hi!

    I have just finished creating my first ever custom ToolStripRenderer, and I managed to create one that looks very similar to the VisualStudio 2008 IDE.

    Here is a screenshot, with a shot of the VS2008 IDE menu for comparison:


    There are a few very tiny differences:
    1. The arrow after a nested submenu is still white, should be black. This will be fixed in the next update!
    2. The menus overall seem smaller. The blue selection rectangles for example and the image margins. I don't know if I can change this since that is simply the size of a MenuStrip. If anyone has any ideas, let me know!


    To make this work, all you need is the following code! No custom controls, just the usual MenuStrip and ToolStrip (not MainMenu and ToolBar!) controls.


    Step 1
    If you haven't already got a MenuStrip and/or ToolStrip control, add them now. You can rightclick them and choose "Insert Standard Items" to insert the standard items if you wish.

    If you want your ToolStrip in a ToolStripContainer, add that too and add your MenuStrip and ToolStrip controls to the ToolStripContainer instead of the form.


    Step 2
    Add a new 'Module' and call it "clsColors.vb". This module hosts all the different color constants and a 'DrawRoundedRectangle' function (not mine). Use the following code for this module:
    Code:
    Module clsColors
        Public clrHorBG_GrayBlue As Color = Color.FromArgb(255, 233, 236, 250)
        Public clrHorBG_White As Color = Color.FromArgb(255, 244, 247, 252)
        Public clrSubmenuBG As Color = Color.FromArgb(255, 240, 240, 240)
        Public clrImageMarginBlue As Color = Color.FromArgb(255, 212, 216, 230)
        Public clrImageMarginWhite As Color = Color.FromArgb(255, 244, 247, 252)
        Public clrImageMarginLine As Color = Color.FromArgb(255, 160, 160, 180)
        Public clrSelectedBG_Blue As Color = Color.FromArgb(255, 186, 228, 246)
        Public clrSelectedBG_Header_Blue As Color = Color.FromArgb(255, 146, 202, 230)
        Public clrSelectedBG_White As Color = Color.FromArgb(255, 241, 248, 251)
        Public clrSelectedBG_Border As Color = Color.FromArgb(255, 150, 217, 249)
        Public clrSelectedBG_Drop_Blue As Color = Color.FromArgb(255, 139, 195, 225)
        Public clrSelectedBG_Drop_Border As Color = Color.FromArgb(255, 48, 127, 177)
        Public clrMenuBorder As Color = Color.FromArgb(255, 160, 160, 160)
        Public clrCheckBG As Color = Color.FromArgb(255, 206, 237, 250)
    
        Public clrVerBG_GrayBlue As Color = Color.FromArgb(255, 196, 203, 219)
        Public clrVerBG_White As Color = Color.FromArgb(255, 250, 250, 253)
        Public clrVerBG_Shadow As Color = Color.FromArgb(255, 181, 190, 206)
    
        Public clrToolstripBtnGrad_Blue As Color = Color.FromArgb(255, 129, 192, 224)
        Public clrToolstripBtnGrad_White As Color = Color.FromArgb(255, 237, 248, 253)
        Public clrToolstripBtn_Border As Color = Color.FromArgb(255, 41, 153, 255)
        Public clrToolstripBtnGrad_Blue_Pressed As Color = Color.FromArgb(255, 124, 177, 204)
        Public clrToolstripBtnGrad_White_Pressed As Color = Color.FromArgb(255, 228, 245, 252)
    
        Public Sub DrawRoundedRectangle(ByVal objGraphics As Graphics, _
                                    ByVal m_intxAxis As Integer, _
                                    ByVal m_intyAxis As Integer, _
                                    ByVal m_intWidth As Integer, _
                                    ByVal m_intHeight As Integer, _
                                    ByVal m_diameter As Integer, ByVal color As Color)
    
            Dim pen As New Pen(color)
    
            'Dim g As Graphics
            Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, m_intHeight)
            Dim ArcRect As New RectangleF(BaseRect.Location, New SizeF(m_diameter, m_diameter))
            'top left Arc
            objGraphics.DrawArc(pen, ArcRect, 180, 90)
            objGraphics.DrawLine(pen, m_intxAxis + CInt(m_diameter / 2), m_intyAxis, m_intxAxis + m_intWidth - CInt(m_diameter / 2), m_intyAxis)
    
            ' top right arc
            ArcRect.X = BaseRect.Right - m_diameter
            objGraphics.DrawArc(pen, ArcRect, 270, 90)
            objGraphics.DrawLine(pen, m_intxAxis + m_intWidth, m_intyAxis + CInt(m_diameter / 2), m_intxAxis + m_intWidth, m_intyAxis + m_intHeight - CInt(m_diameter / 2))
    
            ' bottom right arc
            ArcRect.Y = BaseRect.Bottom - m_diameter
            objGraphics.DrawArc(pen, ArcRect, 0, 90)
            objGraphics.DrawLine(pen, m_intxAxis + CInt(m_diameter / 2), m_intyAxis + m_intHeight, m_intxAxis + m_intWidth - CInt(m_diameter / 2), m_intyAxis + m_intHeight)
    
            ' bottom left arc
            ArcRect.X = BaseRect.Left
            objGraphics.DrawArc(pen, ArcRect, 90, 90)
            objGraphics.DrawLine(pen, m_intxAxis, m_intyAxis + CInt(m_diameter / 2), m_intxAxis, m_intyAxis + m_intHeight - CInt(m_diameter / 2))
    
        End Sub
    End Module

    (Continued next post...)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width