From 437ff003b0c552d4a8498be30ba5d2a7c43ebeb2 Mon Sep 17 00:00:00 2001 From: Riley McArdle Date: Thu, 14 Mar 2013 20:18:56 -0500 Subject: [PATCH] More theme improvements. --- mRemoteV1/Config/Config.Settings.Load.vb | 2 ++ mRemoteV1/Forms/frmMain.vb | 10 ++-------- mRemoteV1/Forms/frmOptions.vb | 1 + mRemoteV1/My Project/Settings.Designer.vb | 13 +++++++++++++ mRemoteV1/My Project/Settings.settings | 3 +++ mRemoteV1/Themes/ThemeInfo.vb | 16 ++++++++++++++++ mRemoteV1/Themes/ThemeManager.vb | 16 ++++++++++++++++ mRemoteV1/app.config | 3 +++ 8 files changed, 56 insertions(+), 8 deletions(-) diff --git a/mRemoteV1/Config/Config.Settings.Load.vb b/mRemoteV1/Config/Config.Settings.Load.vb index f750912f5..d5a5a3719 100644 --- a/mRemoteV1/Config/Config.Settings.Load.vb +++ b/mRemoteV1/Config/Config.Settings.Load.vb @@ -44,6 +44,8 @@ Namespace Config log.InfoFormat("Override Culture: {0}/{1}", Threading.Thread.CurrentThread.CurrentUICulture.Name, Threading.Thread.CurrentThread.CurrentUICulture.NativeName) End If + Themes.ThemeManager.LoadTheme(My.Settings.ThemeName) + .WindowState = FormWindowState.Normal If My.Settings.MainFormState = FormWindowState.Normal Then If Not My.Settings.MainFormLocation.IsEmpty Then .Location = My.Settings.MainFormLocation diff --git a/mRemoteV1/Forms/frmMain.vb b/mRemoteV1/Forms/frmMain.vb index fe5aa13d5..22b7bb432 100644 --- a/mRemoteV1/Forms/frmMain.vb +++ b/mRemoteV1/Forms/frmMain.vb @@ -37,14 +37,6 @@ Public Class frmMain Startup.CreateLogger() - Try - ThemeManager.LoadThemes() - ThemeManager.ActiveTheme = ThemeManager.DefaultTheme - AddHandler ThemeManager.ThemeChanged, AddressOf ApplyThemes - Catch ex As Exception - Debug.Print(ex.Message) - End Try - ' Create gui config load and save objects Dim SettingsLoad As New Config.Settings.Load(Me) @@ -56,6 +48,8 @@ Public Class frmMain Startup.ParseCommandLineArgs() ApplyLanguage() + + AddHandler ThemeManager.ThemeChanged, AddressOf ApplyThemes ApplyThemes() fpChainedWindowHandle = SetClipboardViewer(Me.Handle) diff --git a/mRemoteV1/Forms/frmOptions.vb b/mRemoteV1/Forms/frmOptions.vb index 08a33564a..eaac0f2f5 100644 --- a/mRemoteV1/Forms/frmOptions.vb +++ b/mRemoteV1/Forms/frmOptions.vb @@ -1802,6 +1802,7 @@ Public Class frmOptions My.Settings.XULRunnerPath = Me.txtXULrunnerPath.Text ThemeManager.SaveThemes(_themeList) + Settings.ThemeName = ThemeManager.ActiveTheme.Name If My.Settings.LoadConsFromCustomLocation = False Then App.Runtime.SetMainFormText(App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile) diff --git a/mRemoteV1/My Project/Settings.Designer.vb b/mRemoteV1/My Project/Settings.Designer.vb index c8797de68..867c1ceba 100644 --- a/mRemoteV1/My Project/Settings.Designer.vb +++ b/mRemoteV1/My Project/Settings.Designer.vb @@ -2332,6 +2332,19 @@ Namespace My Return CType(Me("UpdateChannel"),String) End Get End Property + + _ + Public Property ThemeName() As String + Get + Return CType(Me("ThemeName"),String) + End Get + Set + Me("ThemeName") = value + End Set + End Property End Class End Namespace diff --git a/mRemoteV1/My Project/Settings.settings b/mRemoteV1/My Project/Settings.settings index b8d6a37fd..fd0b3af48 100644 --- a/mRemoteV1/My Project/Settings.settings +++ b/mRemoteV1/My Project/Settings.settings @@ -530,5 +530,8 @@ release + + + \ No newline at end of file diff --git a/mRemoteV1/Themes/ThemeInfo.vb b/mRemoteV1/Themes/ThemeInfo.vb index 66708f777..ac37a6e5c 100644 --- a/mRemoteV1/Themes/ThemeInfo.vb +++ b/mRemoteV1/Themes/ThemeInfo.vb @@ -16,6 +16,22 @@ Namespace Themes Public Overrides Function ToString() As String Return Name End Function + + Public Overrides Function Equals(obj As Object) As Boolean + Dim otherTheme As ThemeInfo = TryCast(obj, ThemeInfo) + If otherTheme Is Nothing Then Return False + + Dim themeInfoType As Type = (New ThemeInfo).GetType() + Dim myProperty As Object + Dim otherProperty As Object + For Each propertyInfo As Reflection.PropertyInfo In themeInfoType.GetProperties() + myProperty = propertyInfo.GetValue(Me, Nothing) + otherProperty = propertyInfo.GetValue(otherTheme, Nothing) + If Not myProperty.Equals(otherProperty) Then Return False + Next + + Return True + End Function #End Region #Region "Events" diff --git a/mRemoteV1/Themes/ThemeManager.vb b/mRemoteV1/Themes/ThemeManager.vb index a694d4740..f04a64d4b 100644 --- a/mRemoteV1/Themes/ThemeManager.vb +++ b/mRemoteV1/Themes/ThemeManager.vb @@ -4,6 +4,22 @@ Imports System.ComponentModel Namespace Themes Public Class ThemeManager #Region "Public Methods" + Public Shared Function LoadTheme(ByVal themeName As String, Optional ByVal setActive As Boolean = True) As ThemeInfo + Dim loadedTheme As ThemeInfo = DefaultTheme + + If Not String.IsNullOrEmpty(themeName) Then + For Each theme As ThemeInfo In LoadThemes() + If theme.Name = themeName Then + loadedTheme = theme + Exit For + End If + Next + End If + + If setActive Then ActiveTheme = loadedTheme + Return loadedTheme + End Function + Public Shared Function LoadThemes() As List(Of ThemeInfo) Dim themes As New List(Of ThemeInfo) themes.Add(DefaultTheme) diff --git a/mRemoteV1/app.config b/mRemoteV1/app.config index a67b2664d..19ad3ffc3 100644 --- a/mRemoteV1/app.config +++ b/mRemoteV1/app.config @@ -565,6 +565,9 @@ False + + +