Beispiel #1
0
        private ThemeInfo LoadDefaultTheme()
        {
            try
            {
                if (ThemeDirExists())
                {
                    var defaultThemeURL = $"{themePath}\\vs2015light.vstheme";

                    if (!File.Exists($"{themePath}\\vs2015light.vstheme"))
                    {
                        Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Could not find default theme file.",
                                                            true);
                        return(null);
                    }

                    //First we load the default base theme, its vs2015lightNG
                    //the true "default" in DockPanelSuite built-in VS2015LightTheme named "vs2015Light"
                    //hence the *NG suffix for this one...
                    var defaultTheme = ThemeSerializer.LoadFromXmlFile(defaultThemeURL);
                    defaultTheme.Name = $"{defaultTheme.Name}NG";
                    return(defaultTheme);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionStackTrace("Error loading default theme", ex);
            }

            return(null);
        }
Beispiel #2
0
 //Delete a theme from memory and disk
 public void deleteTheme(ThemeInfo themeToDelete)
 {
     if (!themes.Contains(themeToDelete.Name))
     {
         return;
     }
     if (ActiveTheme == themeToDelete)
     {
         ActiveTheme = DefaultTheme;
     }
     themes.Remove(themeToDelete.Name);
     ThemeSerializer.DeleteFile(themeToDelete);
 }
Beispiel #3
0
        public static List <ThemeInfo> LoadThemes()
        {
            List <ThemeInfo> themes = new List <ThemeInfo>();

            themes.Add(DefaultTheme);
            try
            {
                themes.AddRange(ThemeSerializer.LoadFromXmlFile(Path.Combine(App.Info.SettingsFileInfo.SettingsPath, App.Info.SettingsFileInfo.ThemesFileName)));
            }
            catch (FileNotFoundException)
            {
            }

            return(themes);
        }
Beispiel #4
0
        /// <summary>
        /// Add a new theme based on an existing one by cloning and renaming, the theme is saved to disk
        /// </summary>
        /// <param name="baseTheme"></param>
        /// <param name="newThemeName"></param>
        /// <returns></returns>
        public ThemeInfo addTheme(ThemeInfo baseTheme, string newThemeName)
        {
            if (themes.Contains(newThemeName))
            {
                return(null);
            }
            var modifiedTheme = (ThemeInfo)baseTheme.Clone();

            modifiedTheme.Name         = newThemeName;
            modifiedTheme.IsExtendable = true;
            modifiedTheme.IsThemeBase  = false;
            ThemeSerializer.SaveToXmlFile(modifiedTheme, baseTheme);
            themes.Add(newThemeName, modifiedTheme);
            return(modifiedTheme);
        }
Beispiel #5
0
 public static void SaveThemes(List <ThemeInfo> themes)
 {
     themes.Remove(DefaultTheme);
     ThemeSerializer.SaveToXmlFile(themes, Path.Combine(App.Info.SettingsFileInfo.SettingsPath, App.Info.SettingsFileInfo.ThemesFileName));
 }
Beispiel #6
0
 //Synchronize the theme XML values from memory to disk
 public void updateTheme(ThemeInfo themeToUpdate)
 {
     ThemeSerializer.UpdateThemeXMLValues(themeToUpdate);
 }
Beispiel #7
0
        //The manager precharges all the themes at once
        public List <ThemeInfo> LoadThemes()
        {
            if (themes != null)
            {
                return(themes.Values.OfType <ThemeInfo>().ToList());
            }
            themes = new Hashtable();

            if (themePath == null)
            {
                return(themes.Values.OfType <ThemeInfo>().ToList());
            }
            try
            {
                //Check that theme folder exist before trying to load themes
                if (ThemeDirExists())
                {
                    var themeFiles = Directory.GetFiles(themePath, "*.vstheme");

                    //First we load the default base theme, its vs2015lightNG
                    var defaultTheme = LoadDefaultTheme();
                    themes.Add(defaultTheme.Name, defaultTheme);
                    //Then the rest
                    foreach (var themeFile in themeFiles)
                    {
                        // Skip the default theme here, since it will get loaded again without the *NG below...
                        if (themeFile.Contains("vs2015light.vstheme"))
                        {
                            continue;
                        }
                        //filter default one
                        var extTheme = ThemeSerializer.LoadFromXmlFile(themeFile, defaultTheme);
                        if (extTheme.Theme == null || themes.ContainsKey(extTheme.Name))
                        {
                            continue;
                        }

                        if (extTheme.Name.Equals("darcula") || extTheme.Name.Equals("vs2015blue") ||
                            extTheme.Name.Equals("vs2015dark"))
                        {
                            extTheme.Name = $"{extTheme.Name}NG";
                        }

                        themes.Add(extTheme.Name, extTheme);
                    }

                    //Load the embedded themes, extended palettes are taken from the vs2015 themes, trying to match the color theme

                    // 2003
                    var vs2003 = new ThemeInfo("vs2003", new VS2003Theme(), "",
                                               VisualStudioToolStripExtender.VsVersion.Vs2003,
                                               ((ThemeInfo)themes["vs2015lightNG"]).ExtendedPalette);
                    themes.Add(vs2003.Name, vs2003);

                    // 2005
                    var vs2005 = new ThemeInfo("vs2005", new VS2005Theme(), "",
                                               VisualStudioToolStripExtender.VsVersion.Vs2005,
                                               ((ThemeInfo)themes["vs2015lightNG"]).ExtendedPalette);
                    themes.Add(vs2005.Name, vs2005);

                    // 2012
                    var vs2012Light = new ThemeInfo("vs2012Light", new VS2012LightTheme(), "",
                                                    VisualStudioToolStripExtender.VsVersion.Vs2012,
                                                    ((ThemeInfo)themes["vs2015lightNG"]).ExtendedPalette);
                    themes.Add(vs2012Light.Name, vs2012Light);
                    var vs2012Dark = new ThemeInfo("vs2012Dark", new VS2012DarkTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2012,
                                                   ((ThemeInfo)themes["vs2015darkNG"]).ExtendedPalette);
                    themes.Add(vs2012Dark.Name, vs2012Dark);
                    var vs2012Blue = new ThemeInfo("vs2012Blue", new VS2012BlueTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2012,
                                                   ((ThemeInfo)themes["vs2015blueNG"]).ExtendedPalette);
                    themes.Add(vs2012Blue.Name, vs2012Blue);

                    // 2013
                    var vs2013Light = new ThemeInfo("vs2013Light", new VS2013LightTheme(), "",
                                                    VisualStudioToolStripExtender.VsVersion.Vs2013,
                                                    ((ThemeInfo)themes["vs2015lightNG"]).ExtendedPalette);
                    themes.Add(vs2013Light.Name, vs2013Light);
                    var vs2013Dark = new ThemeInfo("vs2013Dark", new VS2013DarkTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2013,
                                                   ((ThemeInfo)themes["vs2015darkNG"]).ExtendedPalette);
                    themes.Add(vs2013Dark.Name, vs2013Dark);
                    var vs2013Blue = new ThemeInfo("vs2013Blue", new VS2013BlueTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2013,
                                                   ((ThemeInfo)themes["vs2015blueNG"]).ExtendedPalette);
                    themes.Add(vs2013Blue.Name, vs2013Blue);

                    // 2015
                    var vs2015Light = new ThemeInfo("vs2015Light", new VS2015LightTheme(), "",
                                                    VisualStudioToolStripExtender.VsVersion.Vs2015,
                                                    ((ThemeInfo)themes["vs2015lightNG"]).ExtendedPalette);
                    themes.Add(vs2015Light.Name, vs2015Light);
                    var vs2015Dark = new ThemeInfo("vs2015Dark", new VS2015DarkTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2015,
                                                   ((ThemeInfo)themes["vs2015darkNG"]).ExtendedPalette);
                    themes.Add(vs2015Dark.Name, vs2015Dark);
                    var vs2015Blue = new ThemeInfo("vs2015Blue", new VS2015BlueTheme(), "",
                                                   VisualStudioToolStripExtender.VsVersion.Vs2015,
                                                   ((ThemeInfo)themes["vs2015blueNG"]).ExtendedPalette);
                    themes.Add(vs2015Blue.Name, vs2015Blue);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionStackTrace("Error loading themes", ex);
            }

            return(themes.Values.OfType <ThemeInfo>().ToList());
        }
        //THe manager precharges all the themes at once
        public List <ThemeInfo> LoadThemes()
        {
            if (themes != null)
            {
                return(themes.Values.OfType <ThemeInfo>().ToList());
            }
            themes = new Hashtable();

            //Load the files in theme folder first, to incluide vstheme light as default
            var themePath = App.Info.SettingsFileInfo.ThemeFolder;

            if (themePath == null)
            {
                return(themes.Values.OfType <ThemeInfo>().ToList());
            }
            try
            {
                //In install mode first time is necesary to copy the themes folder
                if (!Directory.Exists(themePath))
                {
                    Directory.CreateDirectory(themePath);
                }
                var orig  = new DirectoryInfo(App.Info.SettingsFileInfo.InstalledThemeFolder);
                var files = orig.GetFiles();
                foreach (var file in files)
                {
                    if (!File.Exists(Path.Combine(themePath, file.Name)))
                    {
                        file.CopyTo(Path.Combine(themePath, file.Name), true);
                    }
                }



                //Check that theme folder exist before trying to load themes
                if (Directory.Exists(themePath))
                {
                    var themeFiles      = Directory.GetFiles(themePath, "*.vstheme");
                    var defaultThemeURL = Directory.GetFiles(themePath, "vs2015light" + ".vstheme")[0];
                    //First we load the default theme, its vs2015light
                    var defaultTheme = ThemeSerializer.LoadFromXmlFile(defaultThemeURL);
                    themes.Add(defaultTheme.Name, defaultTheme);
                    //Then the rest
                    foreach (var themeFile in themeFiles)
                    {
                        //filter default one
                        var 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
                    var vs2003 = new ThemeInfo("Vs2003", new VS2003Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2003, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
                    themes.Add(vs2003.Name, vs2003);
                    var vs2005 = new ThemeInfo("Vs2005", new VS2005Theme(), "", VisualStudioToolStripExtender.VsVersion.Vs2005, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
                    themes.Add(vs2005.Name, vs2005);
                    var vs2012Light = new ThemeInfo("vs2012Light", new VS2012LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
                    themes.Add(vs2012Light.Name, vs2012Light);
                    var vs2012Dark = new ThemeInfo("vs2012Dark", new VS2012DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
                    themes.Add(vs2012Dark.Name, vs2012Dark);
                    var vs2012Blue = new ThemeInfo("vs2012Blue", new VS2012BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2012, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
                    themes.Add(vs2012Blue.Name, vs2012Blue);
                    var vs2013Light = new ThemeInfo("vs2013Light", new VS2013LightTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015light"]).ExtendedPalette);
                    themes.Add(vs2013Light.Name, vs2013Light);
                    var vs2013Dark = new ThemeInfo("vs2013Dark", new VS2013DarkTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015dark"]).ExtendedPalette);
                    themes.Add(vs2013Dark.Name, vs2013Dark);
                    var vs2013Blue = new ThemeInfo("vs2013Blue", new VS2013BlueTheme(), "", VisualStudioToolStripExtender.VsVersion.Vs2013, ((ThemeInfo)themes["vs2015blue"]).ExtendedPalette);
                    themes.Add(vs2013Blue.Name, vs2013Blue);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Error loading themes" + Environment.NewLine + ex.Message, true);
            }
            return(themes.Values.OfType <ThemeInfo>().ToList());
        }