Ejemplo n.º 1
0
 public void SetTheme(string theme)
 {
     if (Enum.TryParse(theme, out ElementTheme cacheTheme))
     {
         ThemeSelectorService.SetThemeAsync(cacheTheme).FireAndForgetSafeAsync();
     }
 }
Ejemplo n.º 2
0
        private async void ThemeChanged_CheckedAsync(object sender, RoutedEventArgs e)
        {
            var param = (sender as RadioButton)?.CommandParameter;

            if (param != null)
            {
                await ThemeSelectorService.SetThemeAsync((ElementTheme)param);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Theme Changed Checked Async event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Routed event arguments.</param>
#pragma warning disable CA1822 // Mark members as static

        private async void ThemeChanged_CheckedAsync(object sender, RoutedEventArgs e)
#pragma warning restore CA1822 // Mark members as static
        {
            var param = (sender as RadioButton)?.CommandParameter;

            if (param != null)
            {
                await ThemeSelectorService.SetThemeAsync((ElementTheme)param).ConfigureAwait(true);
            }
        }
Ejemplo n.º 4
0
        private async void ThemeChanged_CheckedAsync(object sender, RoutedEventArgs e)
        {
#pragma warning disable IDE0008 // Use explicit type
            var param = (sender as RadioButton)?.CommandParameter;
#pragma warning restore IDE0008 // Use explicit type

            if (param != null)
            {
                await ThemeSelectorService.SetThemeAsync((ElementTheme)param);
            }
        }
Ejemplo n.º 5
0
        private void LoadThemeSetting()
        {
            List <string> _themeval = new List <string>
            {
                "Theme_Default".GetLocalized(),
                "Theme_Light".GetLocalized(),
                "Theme_Dark".GetLocalized()
            };

            ThemeChooser.ItemsSource   = _themeval;
            ThemeChooser.SelectedIndex = (int)Enum.Parse(typeof(ElementTheme), ThemeSelectorService.Theme.ToString());
            ThemeChooser.Loaded       += (s, e) =>
            {
                ThemeChooser.SelectionChanged += async(s1, e1) =>
                {
                    var themeComboBox = s1 as ComboBox;
                    switch (themeComboBox.SelectedIndex)
                    {
                    case 0:
                        await ThemeSelectorService.SetThemeAsync(ElementTheme.Default);

                        break;

                    case 1:
                        await ThemeSelectorService.SetThemeAsync(ElementTheme.Light);

                        break;

                    case 2:
                        await ThemeSelectorService.SetThemeAsync(ElementTheme.Dark);

                        break;
                    }
                };
            };
        }
Ejemplo n.º 6
0
 public async void SwitchTheme(ElementTheme theme)
 {
     await ThemeSelectorService.SetThemeAsync(theme);
 }