private void applyTheme() { LightTheme lt = new LightTheme(); DarkTheme dt = new DarkTheme(); if (Preferences.Default.DarkTheme == false) { backgroundColour = lt.formBackgroundColor; infolabelColour = lt.infoLabelColor; labelColour = lt.labelColor; } else if (Preferences.Default.DarkTheme == true) { backgroundColour = dt.formBackgroundColor; infolabelColour = dt.infoLabelColor; labelColour = dt.labelColor; } BackColor = backgroundColour; specsverLabel.BackColor = backgroundColour; specsverLabel.ForeColor = infolabelColour; buildLabel.BackColor = backgroundColour; buildLabel.ForeColor = infolabelColour; aluminiumcoreLibVersionLabel.BackColor = backgroundColour; aluminiumcoreLibVersionLabel.ForeColor = infolabelColour; ossLabel.BackColor = backgroundColour; ossLabel.ForeColor = labelColour; }
private void loadLightTheme() { LightTheme lt = new LightTheme(); //Set the theme for all the tabControl pages BackColor = lt.formBackgroundColor; ForeColor = lt.infoLabelColor; preferencedPage.ForeColor = lt.infoLabelColor; preferencedPage.BackColor = lt.formBackgroundColor; tellemtryPage.ForeColor = lt.labelColor; tellemtryPage.BackColor = lt.formBackgroundColor; thirdPartyPage.ForeColor = lt.infoLabelColor; thirdPartyPage.BackColor = lt.formBackgroundColor; doneBtn.ForeColor = lt.infoLabelColor; doneBtn.BackColor = lt.formBackgroundColor; applyBtn.ForeColor = lt.infoLabelColor; applyBtn.BackColor = lt.formBackgroundColor; aboutLabel.ForeColor = lt.labelColor; aboutLabel.BackColor = lt.formBackgroundColor; theme.ForeColor = lt.labelColor; theme.BackColor = lt.formBackgroundColor; tellemtry.ForeColor = lt.labelColor; tellemtry.BackColor = lt.formBackgroundColor; }
private static void ApplyTheme(ThemeSetting theme) { var environment = DependencyService.Get <IEnvironment>(); ResourceDictionary themeDict; SystemTheme systemTheme = environment.GetOperatingSystemTheme(); switch (theme) { case ThemeSetting.System: if (systemTheme == SystemTheme.Dark) { themeDict = new DarkTheme(); } else { themeDict = new LightTheme(); } break; case ThemeSetting.Light: themeDict = new LightTheme(); systemTheme = SystemTheme.Light; break; case ThemeSetting.Dark: themeDict = new DarkTheme(); systemTheme = SystemTheme.Dark; break; default: throw new NotImplementedException(); } var styleDict = new ElementStyles(); ICollection <ResourceDictionary> mergedDictionaries = currentApplication?.Resources.MergedDictionaries; if (mergedDictionaries != null) { mergedDictionaries.Clear(); mergedDictionaries.Add(themeDict); // Need to merge theme into style dict before adding as style dict depends on theme styleDict.MergedDictionaries.Add(themeDict); mergedDictionaries.Add(styleDict); // Just add font dict since it doesn't depend on any others mergedDictionaries.Add(new AppFonts()); } // Set system theme for platform-specific theming. environment.ApplyTheme(systemTheme); }
/// <summary> /// Changes the application GUI's theme. /// </summary> /// <param name="theme">The theme to switch to.</param> /// <returns>Whether the theme change occurred or not (e.g. in case of changing to a theme that's already active, or in case of a failure, this method returns <c>false</c>).</returns> public bool ChangeTheme(string theme) { if (theme.NullOrEmpty() || theme.Equals(CurrentTheme)) { #if DEBUG if (theme.NullOrEmpty()) { logger.LogError($"{nameof(App)}::{nameof(ChangeTheme)}: Attempted to change theme with a null or empty theme identifier parameter. Please only provide a valid theme parameter to this method!"); } #endif return(false); } ResourceDictionary themeDictionary = null; switch (theme) { case Themes.DARK_THEME: themeDictionary = new DarkTheme(); break; case Themes.LIGHT_THEME: themeDictionary = new LightTheme(); break; case Themes.OLED_THEME: themeDictionary = new OLEDTheme(); break; } if (themeDictionary is null) { logger?.LogWarning($"Theme \"{theme}\" couldn't be found/does not exist."); return(false); } try { Resources.Clear(); Resources.Add(themeDictionary); Resources.Add(new Theme()); Resources.Add(new ControlTemplates()); CurrentTheme = theme; return(true); } catch (Exception e) { logger?.LogWarning($"Theme \"{themeDictionary}\" couldn't be applied. Reverting to default theme... Thrown exception: {e.ToString()}"); return(false); } }
static void Zadatak7() { DarkTheme darkTheme = new DarkTheme(); LightTheme lightTheme = new LightTheme(); ReminderNote note1 = new ReminderNote("buy milk lol", lightTheme); ReminderNote note2 = new ReminderNote("buy milk again lol", darkTheme); Notebook notebook = new Notebook(darkTheme); notebook.AddNote(note1, lightTheme); notebook.AddNote(note2); notebook.Display(); }
/// <summary> /// Initializes static members of the <see cref="ThemeManager" /> class. /// </summary> /// <param name="menu"> /// The menu. /// </param> public static void Initialize(Menu menu) { Events.OnLoad += (sender, args) => { Menu = new Menu("thememanager", "Theme Manager"); Menu.Add( new MenuList <string>( "themeID", "Theme", new[] { "Default", "Blue", "Blue 2", "Light", "Light 2", "Colored", "Tech" })).ValueChanged += (o, eventArgs) => { Notifications.Add(new Notification("Theme Manager", "Please reload Menu !")); }; menu.Add(Menu); switch (Menu["themeID"].GetValue <MenuList>().Index) { case 0: Current = new DefaultTheme(); break; case 1: Current = new BlueTheme(); break; case 2: Current = new BlueTheme2(); break; case 3: Current = new LightTheme(); break; case 4: Current = new LightTheme2(); break; case 5: Current = new ColoredTheme(); break; case 6: Current = new TechTheme(); break; } }; }
static void Main(string[] args) { ThemeFactory tf = new PurpleTheme(); tf.CreateScrollBar().Scroll(); tf.CreateSlider().Slide(); Console.ReadKey(); ThemeFactory tf22 = new LightTheme(); tf22.CreateScrollBar().Scroll(); tf22.CreateSlider().Slide(); Console.ReadKey(); }
public static void ChangeTheme(string theme) { // don't change to the same theme if (theme == CurrentTheme) { return; } // clear all the resources Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.Clear(); ResourceDictionary applicationResourceDictionary = Application.Current.Resources; ResourceDictionary newTheme = null; switch (theme.ToLowerInvariant()) { case "light": newTheme = new LightTheme(); break; case "dark": newTheme = new DarkTheme(); break; case "rose": newTheme = new RoseTheme(); break; default: newTheme = new BaseStyleResources(); break; } foreach (var merged in newTheme.MergedDictionaries) { applicationResourceDictionary.MergedDictionaries.Add(merged); } ManuallyCopyThemes(newTheme, applicationResourceDictionary); CurrentTheme = theme; var platformManager = DependencyService.Get <IPlatformThemeManager>(); if (platformManager != null) { platformManager.ChangeTheme(theme); } }
public static void ChangeTheme(Theme theme, bool forceTheme = false) { if ((theme != CurrentTheme) || forceTheme) { var appResourceDictionary = Application.Current.Resources; ResourceDictionary newTheme; var environment = DependencyService.Get <IEnvironment>(); if (theme == Theme.Default) { theme = environment?.GetOSTheme() ?? Theme.Light; } switch (theme) { case Theme.Light: newTheme = new LightTheme(); break; case Theme.Dark: newTheme = new DarkTheme(); break; case Theme.NordDark: newTheme = new NordDarkTheme(); break; case Theme.NordLight: newTheme = new NordLightTheme(); break; default: newTheme = new LightTheme(); break; } foreach (var merged in newTheme.MergedDictionaries) { appResourceDictionary.MergedDictionaries.Add(merged); } ManuallyCopyThemes(newTheme, appResourceDictionary); CurrentTheme = theme; var statusBarColor = (Color)App.Current.Resources["brandColor"]; environment?.SetStatusBarColor(statusBarColor, true); } }
static void Zadatak6() { DarkTheme darkTheme = new DarkTheme(); LightTheme lightTheme = new LightTheme(); ReminderList list1 = new ReminderList("buy more milk plz", darkTheme); list1.AddToList("mihael"); list1.AddToList("bilo ko drugi"); list1.Show(); ReminderList list2 = new ReminderList("get work done", lightTheme); list2.AddToList("mihael"); list2.AddToList("somebodyelse"); list2.Show(); }
private void DefaultThemeChanged(DependencyPropertyChangedEventArgs e) { switch (DefaultTheme) { case DefaultThemesEnum.DarkTheme: Theme = new DarkTheme(ProgrammingLanguage); break; case DefaultThemesEnum.LightTheme: Theme = new LightTheme(ProgrammingLanguage); break; default: Theme = new BlueTheme(ProgrammingLanguage); break; } Theme.SetTheme(this, CustomCompletionControl.Theme); }
public static void ChangeTheme(Theme theme, bool forceTheme = false) { // don't change to the same theme if (theme == CurrentTheme && !forceTheme) { return; } //// clear all the resources var applicationResourceDictionary = Application.Current.Resources; if (theme == Theme.Default) { theme = AppInfo.RequestedTheme == AppTheme.Dark ? Theme.Dark : Theme.Light; } ResourceDictionary newTheme; switch (theme) { case Theme.Light: newTheme = new LightTheme(); break; case Theme.Dark: newTheme = new DarkTheme(); break; case Theme.Default: default: newTheme = new LightTheme(); break; } CurrentTheme = theme; ManuallyCopyThemes(newTheme, applicationResourceDictionary); ChangeStatusBarColor(theme); }
private void applyTheme() { if (Preferences.Default.DarkTheme == false) { LightTheme lt = new LightTheme(); BackColor = lt.formBackgroundColor; okBtn.BackColor = lt.formBackgroundColor; okBtn.ForeColor = lt.infoLabelColor; } else if (Preferences.Default.DarkTheme == true) { DarkTheme dt = new DarkTheme(); BackColor = dt.formBackgroundColor; okBtn.BackColor = dt.formBackgroundColor; okBtn.ForeColor = dt.infoLabelColor; } }
public static bool IsLightTheme() => LightTheme.IsSystemUsesLightTheme();