/// <summary>
        /// Initialize class members and properties from <paramref name="themeModels"/> settings.
        /// </summary>
        /// <param name="themeModels"></param>
        private void InitObject(IThemeInfos themeModels)
        {
            try
            {
                // add the default themes
                if (themeModels != null)
                {
                    foreach (var item in themeModels.GetThemeInfos())
                    {
                        var displayName = ConvertThemeNameToLocalizedString(item.DisplayName);

                        this.themes.Add(new Link {
                            DisplayName = displayName, Source = item.ThemeSource
                        });
                    }
                }

                ////this.SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FontLarge : FontSmall;
                SyncThemeAndColor();

                AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
            }
            catch
            {
            }
        }
示例#2
0
        /// <summary>
        /// Resets the standard themes available through the theme settings interface.
        /// </summary>
        /// <param name="themes"></param>
        public void SetDefaultThemes(IThemeInfos themes)
        {
            themes.RemoveAllThemeInfos();

            // Add dark theme resource items
            var resources = new List <Uri>();

            foreach (var item in MetroDarkResources)
            {
                resources.Add(new Uri(item, UriKind.RelativeOrAbsolute));
            }

            themes.AddThemeInfo(MetroDarkThemeName, resources);

            // Add light theme resource items
            resources = new List <Uri>();
            foreach (var item in ThemesManager.MetroResources)
            {
                resources.Add(new Uri(item, UriKind.RelativeOrAbsolute));
            }

            themes.AddThemeInfo(MetroLightThemeName, resources);

            // Add generic theme resource items
            resources = new List <Uri>();
            foreach (var item in ThemesManager.GenericResources)
            {
                resources.Add(new Uri(item, UriKind.RelativeOrAbsolute));
            }

            themes.AddThemeInfo(GenericThemeName, resources);
        }
示例#3
0
        /// <summary>
        /// Adds more resource files into the standard themes available
        /// through the theme settings interface.
        /// </summary>
        /// <param name="themeName"></param>
        /// <param name="additionalResource"></param>
        /// <param name="themes"></param>
        public void AddThemeResources(string themeName
                                      , List <Uri> additionalResource
                                      , IThemeInfos themes)
        {
            var theme = themes.GetThemeInfo(themeName);

            theme.AddResources(additionalResource);

            _defaultTheme = themes.GetThemeInfo("Dark");
        }
示例#4
0
        /// <summary>
        /// This function assumes that themes and their resources have
        /// been added, previously.
        ///
        /// Use this method to define a default theme which can always be
        /// used as a backup whenever a certain theme is not defined etc...
        /// </summary>
        /// <param name="Themes"></param>
        /// <param name="defaultThemeName"></param>
        public void SetDefaultTheme(IThemeInfos Themes
                                    , string defaultThemeName)
        {
            var theme = Themes.GetThemeInfo(defaultThemeName);

            if (theme == null)
            {
                throw new System.ArgumentOutOfRangeException(defaultThemeName);
            }

            _defaultTheme = theme;
        }
示例#5
0
        /// <summary>
        /// Set the current theme as a selection of the settings service properties.
        /// </summary>
        /// <param name="Themes">Collections of themes to select the new theme from.</param>
        /// <param name="themeName">Name od the theme to be set (e.g.: Dark, Light)</param>
        /// <param name="AccentColor">Apply this accent color
        /// (can be Windows default or custom accent color).
        /// Accent Color in UI elements is invisible if this is null.</param>
        public void SetTheme(IThemeInfos Themes
                             , string themeName
                             , Color AccentColor)
        {
            var theme = Themes.GetThemeInfo(themeName);

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

            SetTheme(theme, AccentColor);
        }
        /// <summary>
        /// Resets the standard themes available through the theme settings interface.
        /// </summary>
        /// <param name="themes"></param>
        public void SetDefaultThemes(IThemeInfos themes)
        {
            themes.RemoveAllThemeInfos();

            // Add theming models
            themes.AddThemeInfo("Dark", new List <Uri>
            {
                new Uri("/Mlib;component/Themes/DarkTheme.xaml", UriKind.RelativeOrAbsolute)
            });

            themes.AddThemeInfo("Light", new List <Uri>
            {
                new Uri("/Mlib;component/Themes/LightTheme.xaml", UriKind.RelativeOrAbsolute)
            });

            _defaultTheme = themes.GetThemeInfo("Dark");
        }
示例#7
0
        /// <summary>
        /// Resets the standard themes available through the theme settings interface.
        /// Method Adds Dark and Light theme infos from MLib - calling applications can
        /// use the AddThemeResources() method to add more resources.
        /// </summary>
        /// <param name="themes">Collection of themeinfos in which Dark and Light themes
        /// with MLib resources should be added.</param>
        /// <param name="removeAllThemeInfos">Determines whether existing collection
        /// of themeinfos is removed before addinng Dark and Light themes.</param>
        public void SetDefaultThemes(IThemeInfos themes,
                                     bool removeAllThemeInfos = true)
        {
            if (removeAllThemeInfos == true)
            {
                themes.RemoveAllThemeInfos();
            }

            // Add theming models
            themes.AddThemeInfo("Dark", new List <Uri>
            {
                new Uri("/Mlib;component/Themes/DarkTheme.xaml", UriKind.RelativeOrAbsolute)
            });

            themes.AddThemeInfo("Light", new List <Uri>
            {
                new Uri("/Mlib;component/Themes/LightTheme.xaml", UriKind.RelativeOrAbsolute)
            });

            SetDefaultTheme(themes, "Dark");
        }
示例#8
0
 /// <summary>
 /// Gets an instance of an object that implements the
 /// <see cref="ISettingsManager"/> interface.
 /// </summary>
 /// <returns></returns>
 public static ISettingsManager GetInstance(IThemeInfos themeInfos)
 {
     return(new SettingsManagerImpl(themeInfos));
 }
示例#9
0
 /// <summary>
 /// Class cosntructor
 /// </summary>
 public SettingsManagerImpl(IThemeInfos themeinfos)
     : this()
 {
     Themes = themeinfos;
 }
////        private string selectedFontSize;
        #endregion fields

        #region contructors
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="themeModels"></param>
        public AppearanceViewModel(IThemeInfos themeModels) :
            base(Local.Strings.STR_Appearance_SETTINGS_Caption)
        {
            InitObject(themeModels);
        }