예제 #1
0
 public ThemeWrapper(
     IBaseTheme value,
     string themeName,
     ThemeKind kind)
 {
     Value     = value.ThrowIfNull(nameof(value));
     ThemeName = themeName.ThrowIfNull(nameof(themeName));
     Kind      = kind.ThrowIfEnumValueIsUndefined(nameof(kind));
 }
예제 #2
0
        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()}'."
                    )
            });
예제 #3
0
        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);
        }
예제 #4
0
        public static ThemeWrapper Create(ThemeKind themeKind)
        {
            themeKind.ThrowIfEnumValueIsUndefined(nameof(themeKind));

            return(GetThemeByKind(themeKind));
        }
예제 #5
0
 public AppConfig WithTheme(ThemeKind theme)
 {
     return(new AppConfig(
                theme: theme
                ));
 }
예제 #6
0
 public AppConfig(
     ThemeKind theme
     )
 {
     Theme = theme;
 }
예제 #7
0
 public AppConfig()
 {
     Theme = ThemeKind.Light;
 }