Exemple #1
0
        private static void LoadInstalledThemes(List <string> themeIds)
        {
            foreach (string themeId in themeIds)
            {
                ThemeLoader.TryLoad(themeId).Match(ThemeLoader.HandleError,
                                                   theme => {
                    themeSettings.Add(theme);

                    if (theme.themeId == JsonConfig.settings.themeName)
                    {
                        currentTheme = theme;
                    }
                }
                                                   );
            }

            foreach (string themeId in defaultThemes)
            {
                if (!themeIds.Contains(themeId))
                {
                    themeSettings.Add(new ThemeConfig()
                    {
                        themeId = themeId
                    });
                }
            }
        }
        public static ThemeConfig ImportTheme(string importPath)
        {
            string themeId    = Path.GetFileNameWithoutExtension(importPath);
            int    themeIndex = themeSettings.FindIndex(t => t.themeId == themeId);

            if (themeIndex != -1)
            {
                bool shouldOverwrite = ThemeLoader.PromptDialog(string.Format(_("The '{0}' " +
                                                                                "theme is already installed. Do you want to overwrite it?"), themeId));

                if (!shouldOverwrite)
                {
                    return(null);
                }
            }

            Directory.CreateDirectory(Path.Combine("themes", themeId));
            bool        shouldContinue = true;
            ThemeConfig theme          = null;

            if (Path.GetExtension(importPath) != ".json")
            {
                shouldContinue = ThemeLoader.ExtractTheme(importPath, themeId);
            }
            else
            {
                File.Copy(importPath, Path.Combine("themes", themeId, "theme.json"), true);
            }

            if (shouldContinue)
            {
                theme = ThemeLoader.TryLoad(themeId);
            }

            if (theme == null)
            {
                return(null);
            }

            if (themeIndex == -1)
            {
                themeSettings.Add(theme);
                themeSettings.Sort((t1, t2) => t1.themeId.CompareTo(t2.themeId));
            }
            else
            {
                themeSettings[themeIndex] = theme;
            }

            return(theme);
        }
        private static void LoadInstalledThemes(List <string> themeIds)
        {
            foreach (string themeId in themeIds)
            {
                ThemeConfig theme = ThemeLoader.TryLoad(themeId);
                ThemeLoader.HandleError(themeId);

                if (theme != null)
                {
                    themeSettings.Add(theme);

                    if (theme.themeId == JsonConfig.settings.themeName)
                    {
                        currentTheme = theme;
                    }
                }
            }
        }