public ThemeWrapper( IBaseTheme value, string themeName, ThemeKind kind) { Value = value.ThrowIfNull(nameof(value)); ThemeName = themeName.ThrowIfNull(nameof(themeName)); Kind = kind.ThrowIfEnumValueIsUndefined(nameof(kind)); }
private static ThemeWrapper GetThemeByKind(ThemeKind themeKind) { return(themeKind switch { ThemeKind.Light => new ThemeWrapper( Theme.Light, nameof(Theme.Light), ThemeKind.Light ), ThemeKind.Dark => new ThemeWrapper( Theme.Dark, nameof(Theme.Dark), ThemeKind.Dark ), _ => throw new ArgumentOutOfRangeException( nameof(themeKind), themeKind, $"Unknown theme kind: '{themeKind.ToString()}'." ) });
public static ContextMenu CreateThemedContextMenu(ThemeKind theme) { var cm = new ContextMenu { }; cm.ItemContainerTemplateSelector = new MenuItemTemplateSelector { Theme = theme }; cm.UsesItemContainerTemplate = true; if (theme == ThemeKind.DarkOnly) { cm.Style = (Style)Application.Current.FindResource("ContextMenuDarkOnly"); } cm.FlowDirection = SystemSettings.IsRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; cm.Opened += ContextMenu_Opened; cm.Closed += ContextMenu_Closed; cm.StaysOpen = true; // To be removed on open. return(cm); }
public static ThemeWrapper Create(ThemeKind themeKind) { themeKind.ThrowIfEnumValueIsUndefined(nameof(themeKind)); return(GetThemeByKind(themeKind)); }
public AppConfig WithTheme(ThemeKind theme) { return(new AppConfig( theme: theme )); }
public AppConfig( ThemeKind theme ) { Theme = theme; }
public AppConfig() { Theme = ThemeKind.Light; }