public static void Activate(ThemeTypes type, string name) { var app = Application.Current; var mergedDictionaries = app.Resources.MergedDictionaries; var currentTheme = mergedDictionaries .OfType <ThemeResourceDictionary>() .FirstOrDefault(d => d.Type == type); var newTheme = ThemeResourceDictionary.Load(type, name); if (currentTheme == newTheme) { return; } if (newTheme != null) { mergedDictionaries.Add(newTheme); } if (currentTheme != null) { mergedDictionaries.Remove(currentTheme); } }
public void SwitchTheme(ThemeTypes themeType) { if (themeType != CurrentThemeType) { Application.Current.Resources.MergedDictionaries.Clear(); switch (themeType) { case ThemeTypes.Light: { Application.Current.Resources.MergedDictionaries.Add(_lightThemeDictionary); break; } case ThemeTypes.Dark: { Application.Current.Resources.MergedDictionaries.Add(_darkThemeDictionary); break; } case ThemeTypes.Default: { Application.Current.Resources.MergedDictionaries.Add(_lightThemeDictionary); break; } } CurrentThemeType = themeType; MessagingCenter.Send(this, ConstantsHelper.AppThemeChanged); } }
/// <summary> /// Gets the application user settings and updates the application with them /// </summary> private void GetUserSettings() { var jsonObject = (string)Properties.Settings.Default["Servers"]; if (jsonObject != null) { try { NetworkSettings = JsonConvert.DeserializeObject <ObservableCollection <NetworkConfig> >(jsonObject) ?? NetworkSettings; if (NetworkSettings.Count == 0) { throw new Exception("Settings are empty."); } } catch (Exception) { NewConfigCommandAction(); } } else { NewConfigCommandAction(); } // Get theme var theme = (int)Properties.Settings.Default["Theme"]; CurrentTheme = theme; Theme = ThemeTypes.GetTheme(CurrentTheme); OnPropertyChanged(nameof(Theme)); // Get selected tab SelectedTab = (int)Properties.Settings.Default["SelectedTab"] >= 0 ? (int)Properties.Settings.Default["SelectedTab"] : 0; Refresh(); }
/// <summary> /// Change UI theme /// </summary> private void ThemeCommandAction() { CurrentTheme++; CurrentTheme = CurrentTheme > 3 ? 0 : CurrentTheme; Theme = ThemeTypes.GetTheme(CurrentTheme); OnPropertyChanged(nameof(Theme)); }
public static void SetTheme(ThemeTypes theme) { string themeName = null; CurrentTheme = theme; switch (theme) { case ThemeTypes.Dark: themeName = "DarkTheme"; break; case ThemeTypes.Light: themeName = "LightTheme"; break; case ThemeTypes.ColourfulDark: themeName = "ColourfulDarkTheme"; break; case ThemeTypes.ColourfulLight: themeName = "ColourfulLightTheme"; break; } try { if (!themeName.IsEmpty()) { ChangeTheme(new Uri($"Themes/{themeName}.xaml", UriKind.Relative)); } } catch { } }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (!DesignMode && Theme != FAThemeManager.Theme && FAThemeManager.UseGlobalThemes) { Theme = FAThemeManager.Theme; } }
public static List <MasterPageItem> GetMenu(ThemeTypes themeType) { var masterPageItems = new List <MasterPageItem> { new MasterPageItem { Title = AppResources.Notes, IconSource = themeType == ThemeTypes.Dark ? ConstantsHelper.NotesListLightIcon : ConstantsHelper.NotesListDarkIcon, TargetType = typeof(NotesView), IsDisplayed = true, Index = MenuViewIndex.NotesView }, new MasterPageItem { Title = AppResources.ToDoSection, IconSource = themeType == ThemeTypes.Dark ? ConstantsHelper.ToDoListLightIcon : ConstantsHelper.ToDoListDarkIcon, TargetType = typeof(ToDoCalendarView), IsDisplayed = true, Index = MenuViewIndex.ToDoPage }, new MasterPageItem { Title = AppResources.Birthdays, IconSource = themeType == ThemeTypes.Dark ? ConstantsHelper.BirthdaysIcon : ConstantsHelper.BirthdaysDarkIcon, TargetType = typeof(BirthdaysView), IsDisplayed = true, Index = MenuViewIndex.BirthdaysView }, new MasterPageItem { Title = AppResources.Achievements, IconSource = themeType == ThemeTypes.Dark ? ConstantsHelper.AchievementIcon : ConstantsHelper.AchievementDarkIcon, TargetType = typeof(AchievementsView), IsDisplayed = true, Index = MenuViewIndex.AchievementsView }, new MasterPageItem { Title = AppResources.Settings, IconSource = themeType == ThemeTypes.Dark ? ConstantsHelper.SettingsLightIcon : ConstantsHelper.SettingsDarkIcon, TargetType = typeof(SettingsView), IsDisplayed = true, Index = MenuViewIndex.SettingsView } }; return(masterPageItems); }
public static void ApplyTheme(this ContentControl control, ThemeTypes theme) { var dictionary = GetThemeResourceDictionary(theme); if (dictionary != null) { control.Resources.MergedDictionaries.Clear(); control.Resources.MergedDictionaries.Add(dictionary); } }
public MDTextBox() { ThemeChanged += OnColorSchemeChanged; BorderStyle = BorderStyle.FixedSingle; Font = new Font("Microsoft PhagsPa", 9.75f); BackColor = Color.FromArgb(35, 35, 35); ForeColor = Color.White; Size = new Size(120, 24); TabStop = setTabStop; ThemeType = ThemeTypes.Dark; }
public static void ApplyTheme(this Application app, ThemeTypes theme) { var dictionary = GetThemeResourceDictionary(theme); if (dictionary != null) { if (_currentTheme != null) { app.Resources.MergedDictionaries.Remove(_currentTheme); } _currentTheme = dictionary; app.Resources.MergedDictionaries.Add(dictionary); } }
public static void SetTheme(ThemeTypes theme) { string themeName = GetThemeName(theme); CurrentTheme = theme; try { if (!string.IsNullOrEmpty(themeName)) { ChangeTheme(new Uri($"Themes/{themeName}.xaml", UriKind.Relative)); } } catch { } }
public void PlayTheme(EventThemeOptions eventTheme) { switch (eventTheme) { case EventThemeOptions.MAINMENU: activeTheme = ThemeTypes.MENU; if (currentPlayingTheme != null && currentPlayingTheme.name == mainMenuTheme.name) { return; } FadeCurrentPlayingTheme(); currentPlayingTheme = mainMenuTheme; break; case EventThemeOptions.WINSCREEN: activeTheme = ThemeTypes.MENU; FadeCurrentPlayingTheme(); currentPlayingTheme = winTheme; break; case EventThemeOptions.LOSESCREEN: activeTheme = ThemeTypes.MENU; FadeCurrentPlayingTheme(); currentPlayingTheme = loseTheme; break; case EventThemeOptions.FINALROUND: activeTheme = ThemeTypes.BATTLE; FadeCurrentPlayingTheme(); currentPlayingTheme = lastRound; break; case EventThemeOptions.FINALROUNDWAVE: activeTheme = ThemeTypes.BATTLE; FadeCurrentPlayingTheme(); currentPlayingTheme = lastRoundLastWave; break; default: break; } currentPlayingTheme.source.Play(); }
public static ThemeResourceDictionary Load(ThemeTypes type, string name) { var uri = new Uri( string.Format("ui/Resources/Themes/{0}/{1}.xaml", type, name), UriKind.Relative ); List<ThemeResourceDictionary> themes; ThemeResourceDictionary dictionary = null; if (loadedDictionaries.TryGetValue(type, out themes)) { dictionary = themes.FirstOrDefault(d => d.Source == uri); } return dictionary ?? new ThemeResourceDictionary { Source = uri, Type = type }; }
public static ThemeResourceDictionary Load(ThemeTypes type, string name) { var uri = new Uri( string.Format("ui/Resources/Themes/{0}/{1}.xaml", type, name), UriKind.Relative ); List <ThemeResourceDictionary> themes; ThemeResourceDictionary dictionary = null; if (loadedDictionaries.TryGetValue(type, out themes)) { dictionary = themes.FirstOrDefault(d => d.Source == uri); } return(dictionary ?? new ThemeResourceDictionary { Source = uri, Type = type }); }
public static string GetThemeName(ThemeTypes theme) { switch (theme) { case ThemeTypes.Dark: return("DarkTheme"); case ThemeTypes.Light: return("LightTheme"); case ThemeTypes.ColourfulDark: return("ColourfulDarkTheme"); case ThemeTypes.ColourfulLight: return("ColourfulLightTheme"); default: return("Error"); } }
public static void Activate(ThemeTypes type, string name) { var app = Application.Current; var mergedDictionaries = app.Resources.MergedDictionaries; var currentTheme = mergedDictionaries .OfType<ThemeResourceDictionary>() .FirstOrDefault(d => d.Type == type); var newTheme = ThemeResourceDictionary.Load(type, name); if (currentTheme == newTheme) return; if (newTheme != null) mergedDictionaries.Add(newTheme); if (currentTheme != null) mergedDictionaries.Remove(currentTheme); }
public SettingsViewModel(INavigationService navigationService, ThemeSwitcher themeSwitcher, IThemeService themeService, ICommandResolver commandResolver) : base(navigationService) { _themeService = themeService; _themeSwitcher = themeSwitcher; _savedTheme = (ThemeTypes)Enum.Parse(typeof(ThemeTypes), Settings.ThemeType); bool.TryParse(Settings.UsePin, out bool shouldUsePin); UsePin = shouldUsePin; if ((ThemeTypes)Enum.Parse(typeof(ThemeTypes), Settings.ThemeType) == ThemeTypes.Dark) { IsDarkTheme = true; } SaveSettingsCommand = commandResolver.Command <string>(pin => SaveSettings(pin)); OpenPinViewCommand = commandResolver.AsyncCommand(OpenPinViewAsync); }
/// <summary> /// Gets the application user settings and updates the application with them /// </summary> private void GetUserSettings() { var jsonObject = (string)Properties.Settings.Default["Servers"]; if (jsonObject != null) { try { HttpServer = JsonConvert.DeserializeObject <ObservableCollection <HttpServer> >(jsonObject) ?? HttpServer; foreach (HttpServer server in HttpServer) { server.Started = false; server.Stop = false; } if (HttpServer.Count == 0) { throw new Exception("Settings are empty."); } } catch (Exception) { NewServerCommandAction(); } } else { NewServerCommandAction(); } // Get theme var theme = (int)Properties.Settings.Default["Theme"]; CurrentTheme = theme; Theme = ThemeTypes.GetTheme(CurrentTheme); OnPropertyChanged(nameof(Theme)); // Get selected tab SelectedTab = (int)Properties.Settings.Default["SelectedTab"] >= 0 ? (int)Properties.Settings.Default["SelectedTab"] : 0; Refresh(); }
public void PlayBattleThemePlaylist() { if (currentPlayingTheme != null) { if (currentPlayingTheme.source.isPlaying) { int index = (battleIndex - 1 + battleThemes.Count) % battleThemes.Count; if (currentPlayingTheme.name == battleThemes[index].name) { return; } } } activeTheme = ThemeTypes.BATTLE; FadeCurrentPlayingTheme(); currentPlayingTheme = battleThemes[battleIndex]; currentPlayingTheme.source.Play(); battleIndex = (battleIndex + 1) % battleThemes.Count; }
public void PlayBuildThemePlaylist() { if (currentPlayingTheme != null) { if (currentPlayingTheme.source.isPlaying) { int index = (buildIndex - 1 + buildThemes.Count) % buildThemes.Count; if (currentPlayingTheme.name == buildThemes[index].name) { return; } } } activeTheme = ThemeTypes.BUILD; FadeCurrentPlayingTheme(); currentPlayingTheme = buildThemes[buildIndex]; currentPlayingTheme.source.Play(); buildIndex = (buildIndex + 1) % buildThemes.Count; }
public SettingsViewModel( INavigationService navigationService, IFileSystem fileService, IMediaService mediaService, ThemeSwitcher themeSwitcher, IThemeService themeService, IPlatformDocumentPicker documentPicker, ICommandResolver commandResolver) : base(navigationService) { _fileService = fileService; _mediaService = mediaService; _themeService = themeService; _themeSwitcher = themeSwitcher; _documentPicker = documentPicker; _savedTheme = (ThemeTypes)Enum.Parse(typeof(ThemeTypes), Settings.ThemeType); bool.TryParse(Settings.UsePin, out bool shouldUsePin); UsePin = shouldUsePin; if ((ThemeTypes)Enum.Parse(typeof(ThemeTypes), Settings.ThemeType) == ThemeTypes.Dark) { IsDarkTheme = true; } bool.TryParse(Settings.UsePinBackground, out bool shouldUsePinBackground); UsePinPageBackground = shouldUsePinBackground; if (UsePinPageBackground) { PinBackgroundImagePath = Settings.PinBackground; } SaveSettingsCommand = commandResolver.Command(SaveSettings); OpenPinViewCommand = commandResolver.AsyncCommand(OpenPinViewAsync); ChangePinViewBackgroundCommand = commandResolver.AsyncCommand(ChangePinBackground); ResetPinBackgroundCommand = commandResolver.Command(ResetPinBackground); }
public void PlayMenuThemePlaylist() { if (currentPlayingTheme != null) { if (currentPlayingTheme.source.isPlaying) { int index = (menuIndex - 1 + menuThemes.Count) % menuThemes.Count; if (currentPlayingTheme.name == menuThemes[index].name) { return; } } } activeTheme = ThemeTypes.MENU; FadeCurrentPlayingTheme(); currentPlayingTheme = menuThemes[menuIndex]; currentPlayingTheme.source.Play(); menuIndex = (menuIndex + 1) % menuThemes.Count; }
public static void SetTheme(ThemeTypes theme) { string themeName = null; CurrentTheme = theme; switch (theme) { case ThemeTypes.YellowDark: themeName = "ColourfulDarkTheme_Yellow"; break; case ThemeTypes.OrangeDark: themeName = "ColourfulDarkTheme_Orange"; break; case ThemeTypes.RedDark: themeName = "ColourfulDarkTheme_Red"; break; } try { if (!string.IsNullOrEmpty(themeName)) { ChangeTheme(new Uri($"Themes/{themeName}.xaml", UriKind.Relative)); } } catch { } }
public static void SetTheme(ThemeTypes theme) { string themeName = null; CurrentTheme = theme; switch (theme) { case ThemeTypes.Dark: themeName = "dark"; break; case ThemeTypes.Light: themeName = "light"; break; case ThemeTypes.Classic: themeName = "classic"; break; } try { if (!string.IsNullOrEmpty(themeName)) { ChangeTheme(themeName); } } catch { } }
public void SetTheme(ThemeTypes theme) { ThemesController.SetTheme(theme); }
public ThemeHelper(ThemeTypes theme) { currentTheme = theme; }
protected void UpdateTheme() { switch (LookAndFeel.ActiveStyle) { case ActiveLookAndFeelStyle.WindowsXP: Theme = ThemeTypes.WindowsXP; break; case ActiveLookAndFeelStyle.Office2003: Theme = ThemeTypes.Office2003; break; case ActiveLookAndFeelStyle.Skin: Theme = ThemeTypes.Office2007; break; case ActiveLookAndFeelStyle.Flat: Theme = ThemeTypes.Office2000; break; default: throw new Exception("This style is not implemented"); } }
protected virtual void OnLookAndFeelChanged(object sender, EventArgs e) { switch(lookAndFeel.ActiveStyle) { case ActiveLookAndFeelStyle.WindowsXP: Theme = ThemeTypes.WindowsXP; break; case ActiveLookAndFeelStyle.Office2003: Theme = ThemeTypes.Office2003; break; case ActiveLookAndFeelStyle.Skin: Theme = ThemeTypes.Office2007; break; case ActiveLookAndFeelStyle.Flat: Theme = ThemeTypes.Office2000; break; default: throw new Exception("This style is not implemented"); } }
public Theme GetTheme(ThemeTypes type) { switch (type) { case ThemeTypes.DefaultTheme: return new Theme { Name = "Default Theme", JavascriptSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Default Theme", Syntax.Javascript), JsonSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Default Theme", Syntax.Json), CssSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Default Theme", Syntax.Css), SyntaxBackgroundColor = new SolidColorBrush(Colors.White), SyntaxForegroundColor = new SolidColorBrush(Colors.Black), ApplicationTheme = ThemeManager.GetTheme("Light.Blue"), TextBoxForground = new SolidColorBrush(Colors.Black), AutoCompleteBackground = new SolidColorBrush(Color.FromRgb(200,200,200)), ListBoxBorderColor = new SolidColorBrush(Colors.Black), HighlightColor = new SolidColorBrush(Color.FromRgb(180, 180, 180)) }; case ThemeTypes.Monokai: return new Theme { Name = "Monokai Theme", JavascriptSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Monokai Theme", Syntax.Javascript), JsonSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Monokai Theme", Syntax.Json), CssSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Monokai Theme", Syntax.Css), SyntaxBackgroundColor = new SolidColorBrush(Color.FromRgb(39,40,34)), SyntaxForegroundColor = new SolidColorBrush(Color.FromRgb(248,248,240)), ApplicationTheme = ThemeManager.GetTheme("Dark.Blue"), TextBoxForground = new SolidColorBrush(Colors.White), AutoCompleteBackground = new SolidColorBrush(Color.FromRgb(50, 50, 50)), ListBoxBorderColor = new SolidColorBrush(Colors.White), HighlightColor = new SolidColorBrush(Color.FromRgb(73, 72, 62)) }; case ThemeTypes.AyuLight: return new Theme { Name = "Ayu Light Theme", JavascriptSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Light Theme", Syntax.Javascript), JsonSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Light Theme", Syntax.Json), CssSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Light Theme", Syntax.Css), SyntaxBackgroundColor = new SolidColorBrush(Color.FromRgb(250, 250, 250)), SyntaxForegroundColor = new SolidColorBrush(Color.FromRgb(108,118,128)), ApplicationTheme = ThemeManager.GetTheme("Light.Blue"), TextBoxForground = new SolidColorBrush(Colors.Black), AutoCompleteBackground = new SolidColorBrush(Color.FromRgb(210, 210, 210)), ListBoxBorderColor = new SolidColorBrush(Color.FromRgb(108, 118, 128)), HighlightColor = new SolidColorBrush(Color.FromRgb(73, 72, 62)) }; case ThemeTypes.AyuMirage: return new Theme { Name = "Ayu Mirage Theme", JavascriptSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Mirage Theme", Syntax.Javascript), JsonSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Mirage Theme", Syntax.Json), CssSyntaxTheme = SyntaxHighlighting.SyntaxHighligtResolver.Insatnce.Resolve("Ayu Mirage Theme", Syntax.Css), SyntaxBackgroundColor = new SolidColorBrush(Color.FromRgb(31, 36, 48)), SyntaxForegroundColor = new SolidColorBrush(Color.FromRgb(203, 204, 198)), ApplicationTheme = ThemeManager.GetTheme("Light.Blue"), TextBoxForground = new SolidColorBrush(Color.FromRgb(50, 50, 50)), AutoCompleteBackground = new SolidColorBrush(Color.FromRgb(190, 190, 190)), ListBoxBorderColor = new SolidColorBrush(Color.FromRgb(108, 118, 128)), HighlightColor= new SolidColorBrush(Color.FromRgb(73, 72, 62)) }; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
private static ResourceDictionary GetThemeResourceDictionary(ThemeTypes theme) { var packUri = theme.GetEnumAttribute <DescriptionAttribute>().Description; return(Application.LoadComponent(new Uri(packUri, UriKind.Relative)) as ResourceDictionary); }
public void Reset() { CurrentThemeType = ThemeTypes.Light; }