Public Class Customise_Colours Dim OldTheme, CurrentTheme, PreSaveNiteTheme, PreSaveStandardTheme, PreSaveTertiaryTheme As Theme Dim unappliedchanges, unsaved As Boolean Dim SaveWarningThemeName As String 'WARNING: this code isn't pretty... Public Property unapplied() As String Get Return unappliedchanges End Get Private Set(ByVal value As String) unappliedchanges = value InnerCancelButton.Enabled = unappliedchanges ApplyButton.Enabled = unappliedchanges SaveButton.Enabled = Not unappliedchanges End Set End Property Private Sub Customise_Colours_Load(sender As Object, e As EventArgs) Handles MyBase.Load Icon = ProgramIcon() PreSaveStandardTheme = ReturnThemeSettingsAsThemeObject(0) PreSaveNiteTheme = ReturnThemeSettingsAsThemeObject(1) PreSaveTertiaryTheme = ReturnThemeSettingsAsThemeObject(2) NotificationCategorySelector.SelectedIndex = 2 ThemeSelector.SelectedIndex = 0 'todo: maybe change to reflect current theme? End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ThemeSelector.SelectedIndexChanged If unsaved = True Then If MsgBox("Apply changes before switching?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Select Case SaveWarningThemeName Case "Standard" PreSaveStandardTheme = CurrentTheme Case "Nite" PreSaveNiteTheme = CurrentTheme Case "Tertiary" PreSaveTertiaryTheme = CurrentTheme End Select showThemeAppliedMessage() End If End If LoadTheme() SaveWarningThemeName = ThemeSelector.SelectedItem.ToString.Replace("Night", "Nite") unapplied = False End Sub Private Sub LoadTheme() Dim themeName As String = ThemeSelector.SelectedItem.ToString.Replace("Night", "Nite") Select Case themeName Case "Standard" CurrentTheme = PreSaveStandardTheme Case "Nite" CurrentTheme = PreSaveNiteTheme Case "Tertiary" CurrentTheme = PreSaveTertiaryTheme End Select PreviewCurrentTheme() End Sub Private Sub ThemeAppliedHideTimer_Tick(sender As Object, e As EventArgs) Handles ThemeAppliedHideTimer.Tick ThemeApplied.Visible = False ThemeAppliedHideTimer.Stop() End Sub Private Sub PreviewCurrentTheme() Handles NotificationCategorySelector.SelectedIndexChanged MockFilePicker.ForeColor = CurrentTheme.SidebarFG MockFilePicker.BackColor = CurrentTheme.SidebarBG MockStatusBar.ForeColor = CurrentTheme.StatusBarFG MockStatusBar.BackColor = CurrentTheme.StatusBarBG MockTextBox.ForeColor = CurrentTheme.TextBoxFG MockTextBox.BackColor = CurrentTheme.TextBoxBG Dim category As String = NotificationCategorySelector.SelectedItem.ToString MockNotification.ForeColor = CallByName(CurrentTheme, "Notification" & category & "FG", CallType.Get) MockNotification.BackColor = CallByName(CurrentTheme, "Notification" & category & "BG", CallType.Get) End Sub Private Sub SetNewColour(sender As Object, e As EventArgs) Handles NotificationBGButton.Click, TextBoxBGButton.Click, SidebarBGButton.Click, SidebarFGButton.Click, StatusBarFGButton.Click, StatusBarBGButton.Click, NotificationFGButton.Click, TextBoxFGButton.Click Dim Clicked As String = sender.name.ToString.RemoveLast(6).Replace("Notification", "Notification" & NotificationCategorySelector.SelectedItem.ToString) ColourPicker.Color = CallByName(CurrentTheme, Clicked, CallType.Get) If ColourPicker.ShowDialog() = DialogResult.OK Then CallByName(CurrentTheme, Clicked, CallType.Set, ColourPicker.Color) 'TODO: why doesn't this work? >:c unapplied = True unsaved = True ShittyThemeSetWorkaround(Clicked, ColourPicker.Color) PreviewCurrentTheme() End If End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) Handles InnerCancelButton.Click If MsgBox("Undo changes made and reload theme from settings?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then unapplied = False LoadTheme() End If End Sub Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click, Button12.Click MsgBox("Not yet supported, sorry :c") End Sub Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click 'TODO: Restore defaults 'Also, right clicking on a button should reset that thing to its default If MsgBox("Load the default colours for this theme?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Select Case ThemeSelector.SelectedIndex Case 0 CurrentTheme = defaultStandardTheme Case 1 CurrentTheme = defaultNightTheme Case 2 CurrentTheme = defaultTertiaryTheme Case Else CurrentTheme = defaultStandardTheme End Select unsaved = True PreviewCurrentTheme() End If End Sub Private Sub ResetCategoryToDefaults(sender As Object, e As EventArgs) Handles NotificationAllDefaultButton.Click, NotificationCurrentDefaultButton.Click, StatusBarDefaultButton.Click, SidebarDefaultButton.Click, TextBoxDefaultButton.Click 'TODO: replace with a bunch of CallByNames? If MsgBox("Restore the default colours for this category to their defaults?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Dim Clicked As String = sender.name.ToString.RemoveLast(13) Select Case Clicked Case "NotificationAll]" CurrentTheme.NotificationCriticalBG = SelectedThemeDefaults.NotificationCriticalBG CurrentTheme.NotificationCriticalFG = SelectedThemeDefaults.NotificationCriticalBG CurrentTheme.NotificationWarningBG = SelectedThemeDefaults.NotificationCriticalBG CurrentTheme.NotificationWarningFG = SelectedThemeDefaults.NotificationCriticalBG CurrentTheme.NotificationInfoBG = SelectedThemeDefaults.NotificationCriticalBG CurrentTheme.NotificationInfoFG = SelectedThemeDefaults.NotificationCriticalBG Case "NotificationCurrent" Dim category As String = NotificationCategorySelector.SelectedItem.ToString CallByName(CurrentTheme, "Notification" & category & "FG", CallType.Set, CallByName(SelectedThemeDefaults, "Notification" & category & "FG", CallType.Get)) CallByName(CurrentTheme, "Notification" & category & "BG", CallType.Set, CallByName(SelectedThemeDefaults, "Notification" & category & "BG", CallType.Get)) Case "StatusBar" CurrentTheme.StatusBarBG = SelectedThemeDefaults.StatusBarBG CurrentTheme.StatusBarFG = SelectedThemeDefaults.StatusBarFG Case "TextBox" CurrentTheme.TextBoxBG = SelectedThemeDefaults.TextBoxBG CurrentTheme.TextBoxFG = SelectedThemeDefaults.TextBoxFG Case "Sidebar" CurrentTheme.SidebarFG = SelectedThemeDefaults.SidebarFG CurrentTheme.SidebarBG = SelectedThemeDefaults.SidebarBG End Select unsaved = True PreviewCurrentTheme() End If End Sub Public Function SelectedThemeDefaults() As Theme Select Case ThemeSelector.SelectedIndex Case 0 Return defaultStandardTheme Case 1 Return defaultNightTheme Case 2 Return defaultTertiaryTheme Case Else Return defaultStandardTheme End Select End Function Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If MsgBox("Update sidebar colours to match editor colours?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then CurrentTheme.SidebarBG = CurrentTheme.TextBoxBG CurrentTheme.SidebarFG = CurrentTheme.TextBoxFG End If unsaved = True PreviewCurrentTheme() End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click If MsgBox("Update editor colours to match sidebar colours?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then CurrentTheme.TextBoxBG = CurrentTheme.SidebarBG CurrentTheme.TextBoxFG = CurrentTheme.SidebarFG End If unsaved = True PreviewCurrentTheme() End Sub Private Sub Button11_Click(sender As Object, e As EventArgs) Handles SaveButton.Click Dim themeName() As String = {"Standard", "Nite", "Tertiary"} For i = 0 To 2 CallByName(My.Settings, themeName(i) & "NotifyColourCritical", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationCriticalBG", CallType.Get)) CallByName(My.Settings, themeName(i) & "NotifyColourWarning", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationWarningBG", CallType.Get)) CallByName(My.Settings, themeName(i) & "NotifyColourInfo", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationInfoBG", CallType.Get)) CallByName(My.Settings, themeName(i) & "NotifyTextColourCritical", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationCriticalFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "NotifyTextColourWarning", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationWarningFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "NotifyTextColourInfo", CallType.Set, CallByName(GetPreSaveTheme(i), "NotificationInfoFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "SidebarFG", CallType.Set, CallByName(GetPreSaveTheme(i), "SidebarFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "SidebarBG", CallType.Set, CallByName(GetPreSaveTheme(i), "SidebarBG", CallType.Get)) CallByName(My.Settings, themeName(i) & "StatFG", CallType.Set, CallByName(GetPreSaveTheme(i), "StatusBarFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "StatBG", CallType.Set, CallByName(GetPreSaveTheme(i), "StatusBarBG", CallType.Get)) CallByName(My.Settings, themeName(i) & "TextFG", CallType.Set, CallByName(GetPreSaveTheme(i), "TextBoxFG", CallType.Get)) CallByName(My.Settings, themeName(i) & "TextBG", CallType.Set, CallByName(GetPreSaveTheme(i), "TextBoxBG", CallType.Get)) Next My.Settings.Save() NPUWindow.reloadCurrentTheme() End Sub Function GetPreSaveTheme(themeType As Integer) Select Case themeType Case 0 Return PreSaveStandardTheme Case 1 Return PreSaveNiteTheme Case 2 Return PreSaveTertiaryTheme Case Else Return PreSaveStandardTheme End Select End Function Private Sub Button9_Click(sender As Object, e As EventArgs) Handles ApplyButton.Click Dim themeName As String = ThemeSelector.SelectedItem.ToString Select Case themeName Case "Standard" PreSaveStandardTheme = CurrentTheme Case "Night" PreSaveNiteTheme = CurrentTheme Case "Tertiary" PreSaveTertiaryTheme = CurrentTheme End Select unapplied = False showThemeAppliedMessage() End Sub Public Sub ShittyThemeSetWorkaround(Name, Colour) 'upside to using non-american english in a programming language written in american english: calling the variable "color" would've fucked things up, because you can't redefine the built in class! ;p 'If CallByName(currentTheme, Name, CallType.Get) = Colour Then MsgBox("It actually worked") Select Case Name Case "NotificationInfoBG" CurrentTheme.NotificationInfoBG = Colour Case "NotificationInfoFG" CurrentTheme.NotificationInfoFG = Colour Case "NotificationWarningBG" CurrentTheme.NotificationWarningBG = Colour Case "NotificationWarningFG" CurrentTheme.NotificationWarningFG = Colour Case "NotificationCriticalBG" CurrentTheme.NotificationCriticalBG = Colour Case "NotificationCriticalFG" CurrentTheme.NotificationCriticalFG = Colour Case "TextBoxBG" CurrentTheme.TextBoxBG = Colour Case "TextBoxFG" CurrentTheme.TextBoxFG = Colour Case "SidebarBG" CurrentTheme.SidebarBG = Colour Case "SidebarFG" CurrentTheme.SidebarFG = Colour Case "StatusBarBG" CurrentTheme.StatusBarBG = Colour Case "StatusBarFG" CurrentTheme.StatusBarFG = Colour End Select End Sub Public Sub showThemeAppliedMessage() ThemeApplied.Visible = True ThemeAppliedHideTimer.Start() End Sub End Class