Esempio n. 1
0
        /// <summary/>
        public override DisplayThemeStateValue GetValue()
        {
            string themeFilename = DisplayConfiguration.GetThemeFilename();
            //If we query on a backed up theme, the BACKUP words will show up
            //API returns Windows Classic if no theme is found (Server 2003 for example)
            string themeName = DisplayConfiguration.GetTheme().Replace(BackupStr, string.Empty);

            //If the theme manager is disabled or there's no theme selected, return windows classic
            if (!DisplayConfiguration.IsThemeEnabled || themeFilename == null)
            {
                return(new DisplayThemeStateValue(themeName, null));
            }

            //If the theme has been customized, make sure we back it up
            string modifiedThemeName = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme", "DisplayName of Modified", null) as string;

            if (!String.IsNullOrEmpty(modifiedThemeName))
            {
                //Need to save theme
                themeFilename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), String.Format("{0}{1}.theme", themeName, BackupStr));
                DisplayConfiguration.SaveCurrentTheme(themeFilename);
            }

            return(new DisplayThemeStateValue(themeName, themeFilename));
        }
Esempio n. 2
0
        /// <summary/>
        public override bool SetValue(DisplayThemeStateValue value, object action)
        {
            if (!String.IsNullOrEmpty(value.ThemeFilename))
            {
                if (!string.Equals(DisplayConfiguration.GetThemeFilename(), value.ThemeFilename, StringComparison.InvariantCultureIgnoreCase))
                {
                    DisplayConfiguration.SetCustomTheme(value.ThemeFilename);
                }

                return(String.Equals(DisplayConfiguration.GetThemeFilename(), value.ThemeFilename, StringComparison.InvariantCultureIgnoreCase));
            }
            else if (!String.IsNullOrEmpty(value.Theme))
            {
                //If we have no theme file information, we need to ensure we are using the right theme by switching
                //

                DisplayConfiguration.SetTheme(value.Theme);
                return(DisplayConfiguration.GetTheme().Equals(value.Theme, StringComparison.InvariantCultureIgnoreCase));
            }
            return(false);
        }