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