public MaterialApp( Key key = null, GlobalKey <NavigatorState> navigatorKey = null, Widget home = null, Dictionary <string, WidgetBuilder> routes = null, string initialRoute = null, RouteFactory onGenerateRoute = null, InitialRouteListFactory onGenerateInitialRoutes = null, RouteFactory onUnknownRoute = null, List <NavigatorObserver> navigatorObservers = null, TransitionBuilder builder = null, string title = "", GenerateAppTitle onGenerateTitle = null, Color color = null, ThemeData theme = null, ThemeData darkTheme = null, ThemeMode themeMode = ThemeMode.system, Locale locale = null, List <LocalizationsDelegate> localizationsDelegates = null, LocaleListResolutionCallback localeListResolutionCallback = null, LocaleResolutionCallback localeResolutionCallback = null, List <Locale> supportedLocales = null, bool showPerformanceOverlay = false, bool checkerboardRasterCacheImages = false, bool checkerboardOffscreenLayers = false, bool debugShowCheckedModeBanner = true, Dictionary <LogicalKeySet, Intent> shortcuts = null, Dictionary <LocalKey, ActionFactory> actions = null ) : base(key: key) { supportedLocales = supportedLocales ?? new List <Locale> { new Locale("en", "US") }; this.navigatorKey = navigatorKey; this.home = home; this.routes = routes ?? new Dictionary <string, WidgetBuilder>(); this.onGenerateInitialRoutes = onGenerateInitialRoutes; this.initialRoute = initialRoute; this.onGenerateRoute = onGenerateRoute; this.onUnknownRoute = onUnknownRoute; this.navigatorObservers = navigatorObservers ?? new List <NavigatorObserver>(); this.builder = builder; this.title = title; this.onGenerateTitle = onGenerateTitle; this.color = color; this.theme = theme; this.darkTheme = darkTheme; this.themeMode = themeMode; this.locale = locale; this.localizationsDelegates = localizationsDelegates; this.localeListResolutionCallback = localeListResolutionCallback; this.localeResolutionCallback = localeResolutionCallback; this.supportedLocales = supportedLocales; this.showPerformanceOverlay = showPerformanceOverlay; this.checkerboardRasterCacheImages = checkerboardRasterCacheImages; this.checkerboardOffscreenLayers = checkerboardOffscreenLayers; this.debugShowCheckedModeBanner = debugShowCheckedModeBanner; this.shortcuts = shortcuts; this.actions = actions; }
/// <summary> /// Changes the application theme. /// </summary> /// <param name="theme">The theme.</param> public void ChangeApplicationTheme(ThemeMode theme) { switch (theme) { case ThemeMode.Dark: Application.Current.Resources.MergedDictionaries.Add(currentResouceDictionary = new ResourceDictionary { Source = Constants.FilePath.DarkThemePath }); break; case ThemeMode.Light: Application.Current.Resources.MergedDictionaries.Add(currentResouceDictionary = new ResourceDictionary() { Source = Constants.FilePath.LightThemePath }); break; case ThemeMode.Default: Application.Current.Resources.MergedDictionaries.Add(currentResouceDictionary = new ResourceDictionary() { Source = Constants.FilePath.DefaultThemePath }); break; } }
public static ApplicationTheme?ToApplicationTheme(this ThemeMode themeMode) { return(themeMode switch { ThemeMode.Light => ApplicationTheme.Light, ThemeMode.Dark => ApplicationTheme.Dark, ThemeMode.UseSystemSetting => default,
/// <summary> /// Free up memory from announcements /// </summary> private void UnloadAnnouncements() { while (announcementItems.Count > 0) { UserControl announcement = announcementItems.ElementAt(0); if (announcement is Welcome) { Welcome welcome = announcement as Welcome; announcementItems.Remove(welcome); welcome.UserControl_Unloaded(null, null); welcome.Unloaded -= welcome.UserControl_Unloaded; } else if (announcement is PlaybackMode) { PlaybackMode playbackMode = announcement as PlaybackMode; announcementItems.Remove(playbackMode); playbackMode.UserControl_Unloaded(null, null); playbackMode.Unloaded -= playbackMode.UserControl_Unloaded; } else if (announcement is ThemeMode) { ThemeMode themeMode = announcement as ThemeMode; announcementItems.Remove(themeMode); themeMode.UserControl_Unloaded(null, null); themeMode.Unloaded -= themeMode.UserControl_Unloaded; } else if (announcement is TvMode) { TvMode tvMode = announcement as TvMode; announcementItems.Remove(tvMode); tvMode.UserControl_Unloaded(null, null); tvMode.Unloaded -= tvMode.UserControl_Unloaded; } else if (announcement is PlaybackOptions) { PlaybackOptions playbackOptions = announcement as PlaybackOptions; announcementItems.Remove(playbackOptions); playbackOptions.UserControl_Unloaded(null, null); playbackOptions.Unloaded -= playbackOptions.UserControl_Unloaded; } else if (announcement is Shuffle) { Shuffle shuffle = announcement as Shuffle; announcementItems.Remove(shuffle); shuffle.UserControl_Unloaded(null, null); shuffle.Unloaded -= shuffle.UserControl_Unloaded; } else if (announcement is NewReleases) { NewReleases newReleases = announcement as NewReleases; announcementItems.Remove(newReleases); newReleases.UserControl_Unloaded(null, null); newReleases.Unloaded -= newReleases.UserControl_Unloaded; } } }
public static ResourceDictionary ToResourceDictionary(this ThemeMode mode, ResourceDictionary customColors = default) { switch (mode) { case ThemeMode.Dark: return(new DarkColors()); case ThemeMode.Light: return(new LightColors()); default: return(customColors); } }
public override void UpdateTheme(ThemeMode themeMode = ThemeMode.Auto) { base.UpdateTheme(themeMode); bool changed = false; switch (AppTheme) { case ThemeMode.Auto: if (AppCompatDelegate.DefaultNightMode != AppCompatDelegate.ModeNightFollowSystem) { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightFollowSystem; changed = true; } break; case ThemeMode.Dark: if (AppCompatDelegate.DefaultNightMode != AppCompatDelegate.ModeNightYes) { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightYes; changed = true; } break; case ThemeMode.Light: if (AppCompatDelegate.DefaultNightMode != AppCompatDelegate.ModeNightNo) { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo; changed = true; } break; case ThemeMode.Custom: if (AppCompatDelegate.DefaultNightMode != AppCompatDelegate.ModeNightFollowSystem) { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightFollowSystem; changed = true; } break; default: break; } if (Activity?.Theme != null && changed) { (Activity as MainActivity)?.Delegate.ApplyDayNight(); Activity.Recreate(); } }
/// <summary> /// 获取系统主题颜色,对应【深色】和【浅色】 /// 只支持 Windows 10 1903+ 以上 /// </summary> /// <returns></returns> public static ThemeMode GetWindows10ThemeMode() { ThemeMode themeMode = ThemeMode.Light; try { RegistryKey temp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", false); if (temp.GetValue("SystemUsesLightTheme") != null) { themeMode = (int)(temp.GetValue("SystemUsesLightTheme")) == 0 ? ThemeMode.Dark : ThemeMode.Light;// 0:【深色】, 1:【浅色】 } } catch { } return(themeMode); }
/// <summary> /// 更改风格 /// </summary> /// <param name="mode"></param> public void ChangeTheme(ThemeMode mode) { ICollection <ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries; if (mergedDictionaries != null) { if (mode == ThemeMode.Light && CurrentTheme != ThemeMode.Light) { mergedDictionaries.Clear(); mergedDictionaries.Add(new LightTheme()); CurrentTheme = ThemeMode.Light; } else if (mode == ThemeMode.Dard && CurrentTheme != ThemeMode.Dard) { mergedDictionaries.Clear(); mergedDictionaries.Add(new DarkTheme()); CurrentTheme = ThemeMode.Dard; } } }
/// <summary> /// Call once-time at startup /// Call every times when user click change theme /// </summary> /// <param name="value"></param> /// <param name="needSave"></param> public static void ChangeTheme(ThemeMode value, bool needSave = true, bool allowDuplicated = false) { if (CurrentTheme != value || allowDuplicated) { theme = value; if (needSave) { SaveCurrentPreferences(); } // Change colors's set switch (theme) { case ThemeMode.Light: colors = GetColors_Light(); break; case ThemeMode.Dark: colors = GetColors_Dark(); break; case ThemeMode.Modern: colors = GetColors_Modern(); break; default: //something wrong break; } System.Windows.Forms.Form mainForm = GetMainForm(); if (mainForm != null && (mainForm is Form1 form1)) { form1.LoadTheme(); } } }
/// <summary> /// Applies the specified theme to the specified element. /// </summary> /// <param name="element">The element to theme.</param> /// <param name="theme">The theme to apply.</param> private void ApplyThemeToElement(FrameworkElement element, ThemeMode theme) { if (element == null) { return; } if (element.Resources == null) { element.Resources = new ResourceDictionary(); } // Search to see if the theme is already applied, or if other themes need removed. foreach (var mergedDictionary in element.Resources.MergedDictionaries.ToList()) { if (mergedDictionary.Source == ThemeUris[theme]) { // Theme is already applied, no further processing necessary. return; } if (ThemeUris.ContainsValue(mergedDictionary.Source)) { // Remove any other theme dictionaries. element.Resources.MergedDictionaries.Remove(mergedDictionary); } } // Apply the theme. var resourceDictionary = LoadResourceDictionary(ThemeUris[theme]); if (resourceDictionary != null) { element.Resources.MergedDictionaries.Insert(0, resourceDictionary); } }
public static Color GetDefaultColorByMode(ThemeMode mode) { var color = Color.White; switch (mode) { case ThemeMode.White: color = Color.White; break; case ThemeMode.Dark: color = Color.Black; break; default: break; } return(color); }
/// <summary> /// Applies the specified theme to the specified element. /// </summary> /// <param name="element">The element to theme.</param> /// <param name="theme">The theme to apply.</param> private void ApplyThemeToElement(FrameworkElement element, ThemeMode theme) { if (element == null) return; if (element.Resources == null) { element.Resources = new ResourceDictionary(); } // Search to see if the theme is already applied, or if other themes need removed. foreach (var mergedDictionary in element.Resources.MergedDictionaries.ToList()) { if (mergedDictionary.Source == ThemeUris[theme]) { // Theme is already applied, no further processing necessary. return; } if (ThemeUris.ContainsValue(mergedDictionary.Source)) { // Remove any other theme dictionaries. element.Resources.MergedDictionaries.Remove(mergedDictionary); } } // Apply the theme. var resourceDictionary = LoadResourceDictionary(ThemeUris[theme]); if (resourceDictionary != null) { element.Resources.MergedDictionaries.Insert(0, resourceDictionary); } }
private void SetTheme(ThemeMode activeTheme) { MessageTextBox.CaretBrush = ChatTextBox.Document.Foreground = MessageTextBox.Document.Foreground = activeTheme == ThemeMode.Dark ? Brushes.White : Brushes.Black; }
private void Initalize(ThemeMode currentMode) { foreach (var widget in Children) { Remove(widget); } this.CurrentMode = currentMode; BashHandler bashHandler = BashHandler.Instance; #if DEBUG Console.WriteLine(bashHandler.UserThemeExtensionExists); #endif if (currentMode == ThemeMode.ShellTheme && !bashHandler.CheckUserThemeExtExists()) { VBox vBox = new VBox { new Label("Please Install The User Themes Extension" + Environment.NewLine + " to Use This Feature On Gnome") }; Add(vBox); vBox.ShowAll(); Show(); } else { switch (currentMode) { case ThemeMode.GtkTheme: currentArray = bashHandler.ThemeList; currentTheme = bashHandler.GetTheme(); break; case ThemeMode.IconTheme: currentArray = bashHandler.IconList; currentTheme = bashHandler.GetIconTheme(); break; case ThemeMode.ShellTheme: currentArray = bashHandler.ShellList; currentTheme = bashHandler.GetShellTheme(); break; case ThemeMode.CursorTheme: currentArray = bashHandler.CursorList; currentTheme = bashHandler.GetCursorTheme(); break; } ListBox box = new ListBox(); RadioButton radioButton = new RadioButton(""); box.SelectionMode = SelectionMode.None; foreach (var theme in currentArray) { ListBoxRow row = new ListBoxRow(); EventBox eventBox = new EventBox(); BoxItem boxItem = new BoxItem(theme, radioButton); row.Child = boxItem; eventBox.Add(row); if (currentTheme == boxItem.ItemName) { box.UnselectAll(); box.SelectionMode = SelectionMode.Single; boxItem.RadioButton.Active = true; #if DEBUG Console.WriteLine(boxItem.ItemName); #endif } eventBox.ButtonPressEvent += (o, args) => { box.UnselectAll(); #if DEBUG Console.WriteLine(boxItem.ItemName); #endif boxItem.RadioButton.Active = true; switch (currentMode) { case ThemeMode.GtkTheme: bashHandler.ChangeTheme(boxItem.ItemName); break; case ThemeMode.IconTheme: bashHandler.ChangeIcon(boxItem.ItemName); break; case ThemeMode.ShellTheme: bashHandler.ChangeShell(boxItem.ItemName); break; case ThemeMode.CursorTheme: bashHandler.ChangeCursor(boxItem.ItemName); break; } }; box.Add(eventBox); } box.ShowAll(); Add(box); Show(); } }
public static PdfActivityConfiguration.Builder GetConfiguration(Context ctx) { var conf = new PdfActivityConfiguration.Builder(ctx); conf.ScrollDirection(PageScrollDirection.ValueOf(Settings.Current.ScrollDirection)) .LayoutMode(PageLayoutMode.ValueOf(Settings.Current.PageLayout)) .ScrollMode(Settings.Current.ScrollMode ? PageScrollMode.Continuous : PageScrollMode.PerPage) .FitMode(Settings.Current.FitMode ? PageFitMode.FitToWidth : PageFitMode.FitToScreen) .RestoreLastViewedPage(Settings.Current.RestoreLastViewedPage) .SetUserInterfaceViewMode(UserInterfaceViewMode.ValueOf(Settings.Current.UIViewMode)) .HideUserInterfaceWhenCreatingAnnotations(Settings.Current.HideUIWhenCreatingAnnotations) .ThemeMode(ThemeMode.ValueOf(Settings.Current.ThemeModeSetting)) .FirstPageAlwaysSingle(Settings.Current.FirstPageAlwaysSingle) .ShowGapBetweenPages(Settings.Current.ShowGapBetweenPages) .SetSearchType(Settings.Current.InlineSearch ? PdfActivityConfiguration.SearchInline : PdfActivityConfiguration.SearchModular) .SetThumbnailBarMode(ThumbnailBarMode.ValueOf(Settings.Current.ThumbnailsBarMode)) .InvertColors(Settings.Current.InvertPageColors || ThemeMode.ValueOf(Settings.Current.ThemeModeSetting) == ThemeMode.Night) .ToGrayscale(Settings.Current.Grayscale) .TextSelectionEnabled(Settings.Current.EnableTextSelection) .UseImmersiveMode(Settings.Current.ImmersiveMode); if (Settings.Current.ShowPageNumberOverlay) { conf.ShowPageNumberOverlay(); } else { conf.HidePageNumberOverlay(); } if (Settings.Current.ShowPageLabels) { conf.ShowPageLabels(); } else { conf.HidePageLabels(); } if (Settings.Current.EnableSearch) { conf.EnableSearch(); } else { conf.DisableSearch(); } if (Settings.Current.ShowThumbnailGrid) { conf.ShowThumbnailGrid(); } else { conf.HideThumbnailGrid(); } if (Settings.Current.EnableDocumentOutline) { conf.EnableOutline(); } else { conf.DisableOutline(); } if (Settings.Current.EnableAnnotationList) { conf.EnableAnnotationList(); } else { conf.DisableAnnotationList(); } if (Settings.Current.EnableAnnotationEditing) { conf.EnableAnnotationEditing(); } else { conf.DisableAnnotationEditing(); } if (Settings.Current.EnableFormEditing) { conf.EnableFormEditing(); } else { conf.DisableFormEditing(); } //if (Settings.Current.ShowShareAction) // conf.SetEnabledShareFeatures () //else // conf.DisableShare (); if (Settings.Current.ShowPrintAction) { conf.EnablePrinting(); } else { conf.DisablePrinting(); } return(conf); }
public Theme(ThemeMode themeMode) { //Screen = screen; Mode = themeMode; }
public override Widget build(BuildContext context) { Widget result = new WidgetsApp( key: new GlobalObjectKey <State>(this), navigatorKey: widget.navigatorKey, navigatorObservers: _navigatorObservers, pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) => new MaterialPageRoute(settings: settings, builder: builder), home: widget.home, routes: widget.routes, initialRoute: widget.initialRoute, onGenerateRoute: widget.onGenerateRoute, onGenerateInitialRoutes: widget.onGenerateInitialRoutes, onUnknownRoute: widget.onUnknownRoute, builder: (BuildContext _context, Widget child) => { ThemeMode mode = widget.themeMode; ThemeData theme = null; if (widget.darkTheme != null) { ui.Brightness platformBrightness = MediaQuery.platformBrightnessOf(context); if (mode == ThemeMode.dark || (mode == ThemeMode.system && platformBrightness == ui.Brightness.dark)) { theme = widget.darkTheme; } } theme = theme ?? widget.theme ?? ThemeData.fallback(); return(new AnimatedTheme( data: theme, isMaterialAppTheme: true, child: widget.builder != null ? new Builder( builder: (__context) => { return widget.builder(__context, child); } ) : child )); }, textStyle: material_._errorTextStyle, title: widget.title, onGenerateTitle: widget.onGenerateTitle, color: widget.color ?? widget.theme?.primaryColor ?? Colors.blue, locale: widget.locale, localizationsDelegates: _localizationsDelegates, localeResolutionCallback: widget.localeResolutionCallback, localeListResolutionCallback: widget.localeListResolutionCallback, supportedLocales: widget.supportedLocales, showPerformanceOverlay: widget.showPerformanceOverlay, checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers, debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner, inspectorSelectButtonBuilder: (BuildContext contextIn, VoidCallback onPressed) => { return(new FloatingActionButton( child: new Icon(Icons.search), onPressed: onPressed, mini: true )); }, shortcuts: widget.shortcuts, actions: widget.actions ); return(result); }
/// <summary> /// Handles the SelectionChanged event of the Theme control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SelectionChangedEventArgs"/> instance containing the event data.</param> private void Theme_SelectionChanged(object sender, SelectionChangedEventArgs e) { ThemeMode theme = (ThemeMode)ComboBoxTheme.SelectedItem; new ThemeHelper().ChangeApplicationTheme(theme); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> /// <param name="thememode">Theme for game.</param> /// /// <param name="secretword">Secret word for game.</param> /// /// <param name="p">player for game.</param> public MainWindow(ThemeMode thememode, string secretword = null, Player p = null) { this.InitializeComponent(); this.theme = thememode; this.game = new HangMan(); this.thePlayers = p; if (this.theme == ThemeMode.TwoPlayersMode) { if (this.thePlayers.Player1IsHost) { lblPlayerr.Content = "Player1"; } else { lblPlayerr.Content = "Player2"; } } // Array to store words string[] mix, sports, movies, countries; mix = new string[9] { "SOCCER", "BASKETBALL", "SKIING", "HARRYPOTTER", "AVATAR", "PIRATESOFTHECARIBBEAN", "TUNISIA", "USA", "RUSSIA" }; sports = new string[3] { "SOCCER", "BASKETBALL", "SKIING" }; movies = new string[3] { "HARRYPOTTER", "AVATAR", "PIRATESOFTHECARIBBEAN" }; countries = new string[3] { "TUNISIA", "USA", "RUSSIA" }; // Create a Random object Random rand = new Random(); if (this.theme == ThemeMode.Mix) { lblTheme.Content = "Mix"; this.game.ThemeChosen = "Mix"; // Generate a random index less than the size of the array. int index = rand.Next(mix.Length); this.game.SecretWord = mix[index]; } else if (this.theme == ThemeMode.Sport) { lblTheme.Content = "Sport"; this.game.ThemeChosen = "Sports"; // Generate a random index less than the size of the array. int index = rand.Next(sports.Length); this.game.SecretWord = sports[index]; } else if (this.theme == ThemeMode.Movies) { lblTheme.Content = "Movies"; this.game.ThemeChosen = "Movies"; // Generate a random index less than the size of the array. int index = rand.Next(movies.Length); this.game.SecretWord = movies[index]; } else if (this.theme == ThemeMode.Countries) { lblTheme.Content = "Countries"; this.game.ThemeChosen = "Countries"; // Generate a random index less than the size of the array. int index = rand.Next(countries.Length); this.game.SecretWord = countries[index]; } else { this.game.SecretWord = secretword.ToUpper(); } this.game.WordLength = this.game.SecretWord.Length; this.game.GuessedLetters = new string[this.game.WordLength]; ////MessageBox.Show(this.game.SecretWord); // Filling the copy word with dashes for (int i = 0; i < this.game.WordLength; i++) { this.game.GuessedLetters[i] = "_"; } // Filling the label with dashes for (int i = 0; i < this.game.WordLength; i++) { lblWord.Content += this.game.GuessedLetters[i]; } }
/// <summary> /// Applies the specified theme to the specified element. /// </summary> /// <param name="element">The element to theme.</param> /// <param name="theme">The theme to apply.</param> private void ApplyThemeToElement(ResourceDictionary element, ThemeMode theme) { if (element == null) return; var mahTheme = theme == ThemeMode.Dark ? Theme.Dark : Theme.Light; var targetAccent = MahApps.Metro.ThemeManager.DefaultAccents.First(accent => accent.Name == "Blue"); MahApps.Metro.ThemeManager.ChangeTheme(element, targetAccent, mahTheme); }
private void SetTheme() => Current.ApplicationTheme = ThemeMode.ToApplicationTheme();
private void SetTheme(ThemeMode activeTheme) { HistoryMessages.Document.Foreground = activeTheme == ThemeMode.Dark ? System.Windows.Media.Brushes.White : System.Windows.Media.Brushes.Black; }
public ThemeUI(ThemeMode currentMode) => Initalize(currentMode);