Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
ThemeSelectorService.cs
2
3using ControlzEx.Theming;
4
5using MahApps.Metro.Theming;
6
9
11
16{
17 private const string HcDarkTheme = "pack://application:,,,/Styles/Themes/HC.Dark.Blue.xaml";
18 private const string HcLightTheme = "pack://application:,,,/Styles/Themes/HC.Light.Blue.xaml";
19
24 {
25 }
26
28 public void InitializeTheme()
29 {
30 // TODO: Mahapps.Metro supports syncronization with high contrast but you have to provide custom high contrast themes
31 // We've added basic high contrast dictionaries for Dark and Light themes
32 // Please complete these themes following the docs on https://mahapps.com/docs/themes/thememanager#creating-custom-themes
33 ThemeManager.Current.AddLibraryTheme(new LibraryTheme(new Uri(HcDarkTheme), MahAppsLibraryThemeProvider.DefaultInstance));
34 ThemeManager.Current.AddLibraryTheme(new LibraryTheme(new Uri(HcLightTheme), MahAppsLibraryThemeProvider.DefaultInstance));
35
36 var theme = GetCurrentTheme();
37 SetTheme(theme);
38 }
39
41 public void SetTheme(AppTheme theme)
42 {
43 if (theme == AppTheme.Default)
44 {
45 ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll;
46 ThemeManager.Current.SyncTheme();
47 }
48 else
49 {
50 ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncWithHighContrast;
51 ThemeManager.Current.SyncTheme();
52 ThemeManager.Current.ChangeTheme(Application.Current, $"{theme}.Blue", SystemParameters.HighContrast);
53 }
54
55 App.Current.Properties["Theme"] = theme.ToString();
56 }
57
60 {
61 if (App.Current.Properties.Contains("Theme"))
62 {
63 var themeName = App.Current.Properties["Theme"].ToString();
64 Enum.TryParse(themeName, out AppTheme theme);
65 return theme;
66 }
67
68 return AppTheme.Default;
69 }
70}
void SetTheme(AppTheme theme)
Sets the application theme based on the provided AppTheme enum value.
AppTheme GetCurrentTheme()
Gets the current application theme from the application properties.AppTheme
void InitializeTheme()
Initializes the theme manager with high contrast themes and set the current theme.
ThemeSelectorService()
Constructor for the ThemeSelectorService.
Interface for a service to manage the application theme selection.
AppTheme
Enumeration for the application theme.
Definition AppTheme.cs:7