mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
fix installer version missing themes
fixed the installed veresion missing themes, added more controls for theme failure to load
This commit is contained in:
@@ -13,5 +13,7 @@ namespace mRemoteNG.App.Info
|
||||
public static string LayoutFileName { get; } = "pnlLayout.xml";
|
||||
public static string ExtAppsFilesName { get; } = "extApps.xml";
|
||||
public static string ThemesFileName { get; } = "Themes.xml";
|
||||
public static string ThemeFolder { get; } = Path.Combine(SettingsPath, "Themes");
|
||||
public static string InstalledThemeFolder { get; } = Path.Combine(ExePath, "Themes");
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Messages;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -66,47 +69,72 @@ namespace mRemoteNG.Themes
|
||||
themes = new Hashtable();
|
||||
|
||||
//Load the files in theme folder first, to incluide vstheme light as default
|
||||
string execPath = App.Info.SettingsFileInfo.SettingsPath;
|
||||
if(execPath != null)
|
||||
string themePath = App.Info.SettingsFileInfo.ThemeFolder;
|
||||
if (themePath != null)
|
||||
{
|
||||
//Check that theme folder exist before trying to load themes
|
||||
if(Directory.Exists(Path.Combine(execPath, "themes")))
|
||||
try
|
||||
{
|
||||
string[] themeFiles = Directory.GetFiles(Path.Combine(execPath, "themes"), "*.vstheme");
|
||||
string defaultThemeURL = Directory.GetFiles(Path.Combine(execPath, "themes"), "vs2015light" + ".vstheme")[0];
|
||||
//First we load the default theme, its vs2015light
|
||||
ThemeInfo defaultTheme = ThemeSerializer.LoadFromXmlFile(defaultThemeURL);
|
||||
themes.Add(defaultTheme.Name, defaultTheme);
|
||||
//Then the rest
|
||||
foreach (string themeFile in themeFiles)
|
||||
//In install mode first time is necesary to copy the themes folder
|
||||
if (!Directory.Exists(themePath))
|
||||
{
|
||||
//filter default one
|
||||
ThemeInfo extTheme = ThemeSerializer.LoadFromXmlFile(themeFile, defaultTheme);
|
||||
if (extTheme.Theme != null && !themes.ContainsKey(extTheme.Name))
|
||||
{
|
||||
themes.Add(extTheme.Name, extTheme);
|
||||
}
|
||||
Directory.CreateDirectory(themePath);
|
||||
|
||||
}
|
||||
DirectoryInfo orig = new DirectoryInfo(App.Info.SettingsFileInfo.InstalledThemeFolder);
|
||||
FileInfo[] files = orig.GetFiles();
|
||||
foreach (FileInfo file in files)
|
||||
{
|
||||
|
||||
if (!File.Exists(Path.Combine(themePath, file.Name)))
|
||||
file.CopyTo(Path.Combine(themePath, file.Name), true);
|
||||
}
|
||||
|
||||
|
||||
//Load the embedded themes, extended palettes are taken from the vs2015 themes, trying to match the color theme
|
||||
ThemeInfo vs2003 = new ThemeInfo("Vs2003", new VS2003Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2003, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2003.Name, vs2003);
|
||||
ThemeInfo vs2005 = new ThemeInfo("Vs2005", new VS2005Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2005, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2005.Name, vs2005);
|
||||
ThemeInfo vs2012Light = new ThemeInfo("vs2012Light", new VS2012LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2012Light.Name, vs2012Light);
|
||||
ThemeInfo vs2012Dark = new ThemeInfo("vs2012Dark", new VS2012DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
|
||||
themes.Add(vs2012Dark.Name, vs2012Dark);
|
||||
ThemeInfo vs2012Blue = new ThemeInfo("vs2012Blue", new VS2012BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
|
||||
themes.Add(vs2012Blue.Name, vs2012Blue);
|
||||
ThemeInfo vs2013Light = new ThemeInfo("vs2013Light", new VS2013LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2013Light.Name, vs2013Light);
|
||||
ThemeInfo vs2013Dark = new ThemeInfo("vs2013Dark", new VS2013DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
|
||||
themes.Add(vs2013Dark.Name, vs2013Dark);
|
||||
ThemeInfo vs2013Blue = new ThemeInfo("vs2013Blue", new VS2013BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
|
||||
themes.Add(vs2013Blue.Name, vs2013Blue);
|
||||
}
|
||||
|
||||
//Check that theme folder exist before trying to load themes
|
||||
if (Directory.Exists(themePath))
|
||||
{
|
||||
string[] themeFiles = Directory.GetFiles(themePath, "*.vstheme");
|
||||
string defaultThemeURL = Directory.GetFiles(themePath, "vs2015light" + ".vstheme")[0];
|
||||
//First we load the default theme, its vs2015light
|
||||
ThemeInfo defaultTheme = ThemeSerializer.LoadFromXmlFile(defaultThemeURL);
|
||||
themes.Add(defaultTheme.Name, defaultTheme);
|
||||
//Then the rest
|
||||
foreach (string themeFile in themeFiles)
|
||||
{
|
||||
//filter default one
|
||||
ThemeInfo extTheme = ThemeSerializer.LoadFromXmlFile(themeFile, defaultTheme);
|
||||
if (extTheme.Theme != null && !themes.ContainsKey(extTheme.Name))
|
||||
{
|
||||
themes.Add(extTheme.Name, extTheme);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Load the embedded themes, extended palettes are taken from the vs2015 themes, trying to match the color theme
|
||||
ThemeInfo vs2003 = new ThemeInfo("Vs2003", new VS2003Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2003, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2003.Name, vs2003);
|
||||
ThemeInfo vs2005 = new ThemeInfo("Vs2005", new VS2005Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2005, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2005.Name, vs2005);
|
||||
ThemeInfo vs2012Light = new ThemeInfo("vs2012Light", new VS2012LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2012Light.Name, vs2012Light);
|
||||
ThemeInfo vs2012Dark = new ThemeInfo("vs2012Dark", new VS2012DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
|
||||
themes.Add(vs2012Dark.Name, vs2012Dark);
|
||||
ThemeInfo vs2012Blue = new ThemeInfo("vs2012Blue", new VS2012BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
|
||||
themes.Add(vs2012Blue.Name, vs2012Blue);
|
||||
ThemeInfo vs2013Light = new ThemeInfo("vs2013Light", new VS2013LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
|
||||
themes.Add(vs2013Light.Name, vs2013Light);
|
||||
ThemeInfo vs2013Dark = new ThemeInfo("vs2013Dark", new VS2013DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
|
||||
themes.Add(vs2013Dark.Name, vs2013Dark);
|
||||
ThemeInfo vs2013Blue = new ThemeInfo("vs2013Blue", new VS2013BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
|
||||
themes.Add(vs2013Blue.Name, vs2013Blue);
|
||||
}
|
||||
}
|
||||
catch(Exception ex )
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Error loading themes" + Environment.NewLine + ex.Message, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user