Click here to Skip to main content
15,888,802 members
Articles / Programming Languages / Visual Basic

TeamVision

Rate me:
Please Sign up or sign in to vote.
3.08/5 (11 votes)
16 Nov 2009CPL3 min read 84.3K   5.4K   69  
A simple project task management application. A managed approach to help keep on top of your projects.
Imports System
Imports System.ComponentModel
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles

Namespace Gui.Components

    <ToolboxItem(False)> _
    Public Class BaseStyledPanel
        Inherits ContainerControl
        Private Shared renderer As New ToolStripProfessionalRenderer()

        Public Event ThemeChanged As EventHandler

        Public Sub New()
            MyBase.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            MyBase.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
            MyBase.SetStyle(ControlStyles.ResizeRedraw, True)
            MyBase.SetStyle(ControlStyles.UserPaint, True)
        End Sub

        Protected Overrides Sub OnSystemColorsChanged(ByVal e As System.EventArgs)
            MyBase.OnSystemColorsChanged(e)
            Me.UpdateRenderer()
            MyBase.Invalidate()
        End Sub

        Protected Overridable Sub OnThemeChanged(ByVal e As System.EventArgs)
            If Me.ThemeChangedEvent IsNot Nothing Then
                RaiseEvent ThemeChanged(Me, e)
            End If
        End Sub

        Private Sub UpdateRenderer()
            If (Not Me.UseThemes) Then
                renderer.ColorTable.UseSystemColors = True
            Else
                renderer.ColorTable.UseSystemColors = False
            End If
        End Sub

        <Browsable(False)> _
        Public ReadOnly Property ToolStripRenderer() As ToolStripProfessionalRenderer
            Get
                Return renderer
            End Get
        End Property

        <DefaultValue(True), Browsable(False)> _
        Public ReadOnly Property UseThemes() As Boolean
            Get
                Return ((VisualStyleRenderer.IsSupported AndAlso VisualStyleInformation.IsSupportedByOS) AndAlso Application.RenderWithVisualStyles)
            End Get
        End Property
    End Class
End Namespace

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, along with any associated source code and files, is licensed under The Common Public License Version 1.0 (CPL)


Written By
Founder Arkitech EBC Corporation
United States United States
MS, BBA, software developer, consultant, and trainer. Specializing in building data-centric applications designed for business, university, community & faith based organizations. Started developing Excel VBA macros and never looked back. Freelance developer utilizing VB.Net, SQL Server, Microsoft Access, and ASP.Net.

Comments and Discussions