Theme selector now shows preview, refactored ThemeEngine

This commit is contained in:
2019-03-16 10:17:38 +00:00
parent aff8059b5b
commit ab0c7a05af
4 changed files with 142 additions and 14 deletions
+1 -1
View File
@@ -60,7 +60,6 @@ Public Class frmMain
Public WithEvents oRestore As New mgrRestore
Public hshScanList As Hashtable
Public oSettings As New mgrSettings
Public oThemeEngine As New mgrThemeEngine
Delegate Sub UpdateNotifierCallBack(ByVal iCount As Integer)
Delegate Sub UpdateLogCallBack(ByVal sLogUpdate As String, ByVal bTrayUpdate As Boolean, ByVal objIcon As System.Windows.Forms.ToolTipIcon, ByVal bTimeStamp As Boolean)
@@ -1642,6 +1641,7 @@ Public Class frmMain
#End Region
#Region "Set application theme"
Dim oThemeEngine As New mgrThemeEngine()
oThemeEngine.SetTheme(oSettings.ThemeSelection)
'Base Theme
+56 -4
View File
@@ -80,6 +80,10 @@ Partial Class frmSettings
Me.chkAutoHideLog = New System.Windows.Forms.CheckBox()
Me.cboThemeSelection = New System.Windows.Forms.ComboBox()
Me.lblThemeSelection = New System.Windows.Forms.Label()
Me.btnPrevBase = New System.Windows.Forms.Button()
Me.btnPrevBaseSec = New System.Windows.Forms.Button()
Me.btnPrevHighlight = New System.Windows.Forms.Button()
Me.btnPrevHighlightSec = New System.Windows.Forms.Button()
Me.grpFolderOptions.SuspendLayout()
Me.grp7zGeneral.SuspendLayout()
Me.pnlBackup.SuspendLayout()
@@ -639,12 +643,16 @@ Partial Class frmSettings
'
'grpInterfaceOptions
'
Me.grpInterfaceOptions.Controls.Add(Me.btnPrevHighlightSec)
Me.grpInterfaceOptions.Controls.Add(Me.btnPrevHighlight)
Me.grpInterfaceOptions.Controls.Add(Me.btnPrevBaseSec)
Me.grpInterfaceOptions.Controls.Add(Me.btnPrevBase)
Me.grpInterfaceOptions.Controls.Add(Me.chkAutoHideLog)
Me.grpInterfaceOptions.Controls.Add(Me.cboThemeSelection)
Me.grpInterfaceOptions.Controls.Add(Me.lblThemeSelection)
Me.grpInterfaceOptions.Location = New System.Drawing.Point(6, 12)
Me.grpInterfaceOptions.Name = "grpInterfaceOptions"
Me.grpInterfaceOptions.Size = New System.Drawing.Size(354, 97)
Me.grpInterfaceOptions.Size = New System.Drawing.Size(354, 82)
Me.grpInterfaceOptions.TabIndex = 1
Me.grpInterfaceOptions.TabStop = False
Me.grpInterfaceOptions.Text = "Interface Options"
@@ -652,7 +660,7 @@ Partial Class frmSettings
'chkAutoHideLog
'
Me.chkAutoHideLog.AutoSize = True
Me.chkAutoHideLog.Location = New System.Drawing.Point(12, 56)
Me.chkAutoHideLog.Location = New System.Drawing.Point(9, 56)
Me.chkAutoHideLog.Name = "chkAutoHideLog"
Me.chkAutoHideLog.Size = New System.Drawing.Size(167, 17)
Me.chkAutoHideLog.TabIndex = 3
@@ -663,9 +671,9 @@ Partial Class frmSettings
'
Me.cboThemeSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboThemeSelection.FormattingEnabled = True
Me.cboThemeSelection.Location = New System.Drawing.Point(100, 23)
Me.cboThemeSelection.Location = New System.Drawing.Point(110, 23)
Me.cboThemeSelection.Name = "cboThemeSelection"
Me.cboThemeSelection.Size = New System.Drawing.Size(121, 21)
Me.cboThemeSelection.Size = New System.Drawing.Size(114, 21)
Me.cboThemeSelection.TabIndex = 1
'
'lblThemeSelection
@@ -677,6 +685,46 @@ Partial Class frmSettings
Me.lblThemeSelection.TabIndex = 0
Me.lblThemeSelection.Text = "Theme Selection:"
'
'btnPrevBase
'
Me.btnPrevBase.Enabled = False
Me.btnPrevBase.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPrevBase.Location = New System.Drawing.Point(230, 23)
Me.btnPrevBase.Name = "btnPrevBase"
Me.btnPrevBase.Size = New System.Drawing.Size(21, 21)
Me.btnPrevBase.TabIndex = 4
Me.btnPrevBase.UseVisualStyleBackColor = True
'
'btnPrevBaseSec
'
Me.btnPrevBaseSec.Enabled = False
Me.btnPrevBaseSec.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPrevBaseSec.Location = New System.Drawing.Point(258, 23)
Me.btnPrevBaseSec.Name = "btnPrevBaseSec"
Me.btnPrevBaseSec.Size = New System.Drawing.Size(21, 21)
Me.btnPrevBaseSec.TabIndex = 5
Me.btnPrevBaseSec.UseVisualStyleBackColor = True
'
'btnPrevHighlight
'
Me.btnPrevHighlight.Enabled = False
Me.btnPrevHighlight.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPrevHighlight.Location = New System.Drawing.Point(285, 23)
Me.btnPrevHighlight.Name = "btnPrevHighlight"
Me.btnPrevHighlight.Size = New System.Drawing.Size(21, 21)
Me.btnPrevHighlight.TabIndex = 6
Me.btnPrevHighlight.UseVisualStyleBackColor = True
'
'btnPrevHighlightSec
'
Me.btnPrevHighlightSec.Enabled = False
Me.btnPrevHighlightSec.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPrevHighlightSec.Location = New System.Drawing.Point(312, 23)
Me.btnPrevHighlightSec.Name = "btnPrevHighlightSec"
Me.btnPrevHighlightSec.Size = New System.Drawing.Size(21, 21)
Me.btnPrevHighlightSec.TabIndex = 7
Me.btnPrevHighlightSec.UseVisualStyleBackColor = True
'
'frmSettings
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -788,4 +836,8 @@ Partial Class frmSettings
Friend WithEvents chkAutoHideLog As CheckBox
Friend WithEvents cboThemeSelection As ComboBox
Friend WithEvents lblThemeSelection As Label
Friend WithEvents btnPrevBase As Button
Friend WithEvents btnPrevHighlightSec As Button
Friend WithEvents btnPrevHighlight As Button
Friend WithEvents btnPrevBaseSec As Button
End Class
+20
View File
@@ -5,6 +5,7 @@ Public Class frmSettings
Dim bShutdown As Boolean = False
Dim bSyncSettingsChanged As Boolean = False
Dim eCurrentSyncFields As clsGame.eOptionalSyncFields
Private oSettings As mgrSettings
Property Settings As mgrSettings
@@ -451,4 +452,23 @@ Public Class frmSettings
Private Sub lstSettings_SelectedValueChanged(sender As Object, e As EventArgs) Handles lstSettings.SelectedValueChanged
ChangePanel()
End Sub
Private Sub cboThemeSelection_SelectedValueChanged(sender As Object, e As EventArgs) Handles cboThemeSelection.SelectedValueChanged
'Previews theme based on current combo-box selection.
Dim oThemeEngine As New mgrThemeEngine()
If cboThemeSelection.SelectedIndex = 0 Then
oThemeEngine.SetTheme(cboThemeSelection.SelectedIndex)
ElseIf cboThemeSelection.SelectedIndex = 1 Then
oThemeEngine.SetTheme(cboThemeSelection.SelectedIndex)
End If
'Only set the theme once it has been defined.
If oThemeEngine.bThemeHasBeenDefined Then
btnPrevBase.BackColor = oThemeEngine.ColorBase
btnPrevBaseSec.BackColor = oThemeEngine.ColorBaseSecondary
btnPrevHighlight.BackColor = oThemeEngine.ColorHighlight
btnPrevHighlightSec.BackColor = oThemeEngine.ColorHighlightSecondary
End If
End Sub
End Class
+65 -9
View File
@@ -2,11 +2,67 @@
Public Class mgrThemeEngine
Public ReadOnly Property ColorBase As Color
Public ReadOnly Property ColorBaseSecondary As Color
Public ReadOnly Property ColorHighlight As Color
Public ReadOnly Property ColorHighlightSecondary As Color
Private _ColorBase As Color
Public Property ColorBase() As Color
Get
If _ColorBase = Nothing Then
Throw New NullReferenceException
End If
Return _ColorBase
End Get
Private Set(ByVal value As Color)
_ColorBase = value
End Set
End Property
Private _ColorBaseSecondary As Color
Public Property ColorBaseSecondary() As Color
Get
If _ColorBaseSecondary = Nothing Then
Throw New NullReferenceException
End If
Return _ColorBaseSecondary
End Get
Private Set(ByVal value As Color)
_ColorBaseSecondary = value
End Set
End Property
Private _ColorHighlight As Color
Public Property ColorHighlight() As Color
Get
If _ColorHighlight = Nothing Then
Throw New NullReferenceException
End If
Return _ColorHighlight
End Get
Private Set(ByVal value As Color)
_ColorHighlight = value
End Set
End Property
Private _ColorHighlightSecondary As Color
Public Property ColorHighlightSecondary() As Color
Get
If _ColorHighlightSecondary = Nothing Then
Throw New NullReferenceException
End If
Return _ColorHighlightSecondary
End Get
Private Set(ByVal value As Color)
_ColorHighlightSecondary = value
End Set
End Property
Private _bThemeHasBeenDefined As Boolean
Public Property bThemeHasBeenDefined() As Boolean
Get
Return _bThemeHasBeenDefined
End Get
Private Set(ByVal value As Boolean)
_bThemeHasBeenDefined = value
End Set
End Property
''' <summary>
''' Supported themes.
@@ -20,9 +76,7 @@ Public Class mgrThemeEngine
''' Configures the base colors for the overall theme based on input.
''' </summary>
''' <param name="_eBaseTheme"></param>
''' <returns></returns>
Public Function SetTheme(_eBaseTheme As eBaseTheme)
Dim selectedColor As Color
Public Sub SetTheme(_eBaseTheme As eBaseTheme)
Select Case _eBaseTheme
Case eBaseTheme.Dark
_ColorBase = New ColorConverter().ConvertFromString(
@@ -37,6 +91,8 @@ Public Class mgrThemeEngine
_ColorHighlightSecondary = New ColorConverter().ConvertFromString(
mgrThemeEngine_RGB_Dark_HighlightSecondary)
_bThemeHasBeenDefined = True
Case eBaseTheme.Light
_ColorBase = New ColorConverter().ConvertFromString(
mgrThemeEngine_RGB_Light_Base)
@@ -50,7 +106,7 @@ Public Class mgrThemeEngine
_ColorHighlightSecondary = New ColorConverter().ConvertFromString(
mgrThemeEngine_RGB_Light_HighlightSecondary)
_bThemeHasBeenDefined = True
End Select
Return selectedColor
End Function
End Sub
End Class