Example #1
0
        static StyleSettings()
        {
            applicationName = GetAppName();
            var windowsThemes = LoadWindowsThemes();

            if (windowsThemes.Applications == null)
            {
                windowsThemes.Applications = new List <ApplicationThemes>();
            }

            applicationTheme = FindApplication(windowsThemes, applicationName);
            theme            = GetTheme(applicationTheme?.Theme);
        }
Example #2
0
        internal static void SaveWindowTheme(BaseWindow?window, Pik.Metro.Theme wTheme, bool isOnlyThisWindow)
        {
            try
            {
                var windowsThemes = LoadWindowsThemes();
                applicationTheme = FindApplication(windowsThemes, applicationName);
                if (applicationTheme == null)
                {
                    applicationTheme = new ApplicationThemes {
                        Name = applicationName
                    };
                    windowsThemes.Applications.Add(applicationTheme);
                }

                if (isOnlyThisWindow && window != null)
                {
                    var windowTheme = FindWindowTheme(window);
                    if (windowTheme == null)
                    {
                        windowTheme = new WindowTheme {
                            Window = GetWindowName(window)
                        };
                        applicationTheme.Windows.Add(windowTheme);
                        AddApplication(windowsThemes, applicationTheme);
                    }

                    windowTheme.Theme = wTheme.Name;
                }
                else
                {
                    var windowTheme = FindWindowTheme(window);
                    if (windowTheme != null)
                    {
                        applicationTheme.Windows.Remove(windowTheme);
                    }

                    theme = wTheme;
                    applicationTheme.Theme = theme.Name;
                    Change?.Invoke(null, EventArgs.Empty);
                }

                var file = GetWindowsThemesFile();
                Save(file, windowsThemes);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "SaveWindowTheme");
            }
        }