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
1
using
System.Windows
;
2
3
using
ControlzEx.Theming;
4
5
using
MahApps.Metro.Theming;
6
7
using
Vereinsmeisterschaften.Contracts.Services
;
8
using
Vereinsmeisterschaften.Models
;
9
10
namespace
Vereinsmeisterschaften.Services
;
11
15
public
class
ThemeSelectorService
:
IThemeSelectorService
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
23
public
ThemeSelectorService
()
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
59
public
AppTheme
GetCurrentTheme
()
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
}
Vereinsmeisterschaften.App
Definition
App.xaml.cs:33
Vereinsmeisterschaften.Services.ThemeSelectorService.SetTheme
void SetTheme(AppTheme theme)
Sets the application theme based on the provided AppTheme enum value.
Definition
ThemeSelectorService.cs:41
Vereinsmeisterschaften.Services.ThemeSelectorService.GetCurrentTheme
AppTheme GetCurrentTheme()
Gets the current application theme from the application properties.AppTheme
Definition
ThemeSelectorService.cs:59
Vereinsmeisterschaften.Services.ThemeSelectorService.InitializeTheme
void InitializeTheme()
Initializes the theme manager with high contrast themes and set the current theme.
Definition
ThemeSelectorService.cs:28
Vereinsmeisterschaften.Services.ThemeSelectorService.ThemeSelectorService
ThemeSelectorService()
Constructor for the ThemeSelectorService.
Definition
ThemeSelectorService.cs:23
Vereinsmeisterschaften.Contracts.Services.IThemeSelectorService
Interface for a service to manage the application theme selection.
Definition
IThemeSelectorService.cs:9
System.Windows
Definition
FrameExtensions.cs:1
Vereinsmeisterschaften.Contracts.Services
Definition
IApplicationInfoService.cs:1
Vereinsmeisterschaften.Models
Definition
AppConfig.cs:1
Vereinsmeisterschaften.Models.AppTheme
AppTheme
Enumeration for the application theme.
Definition
AppTheme.cs:7
Vereinsmeisterschaften.Services
Definition
ApplicationHostService.cs:8
Vereinsmeisterschaften
Services
ThemeSelectorService.cs
Generated on Sun Feb 22 2026 13:06:13 for Vereinsmeisterschaften by
1.13.2