Skip to content

Commit b0298e3

Browse files
committed
Custom themes added
1 parent 5f45443 commit b0298e3

7 files changed

Lines changed: 323 additions & 3 deletions

File tree

Source/NETworkManager/Models/Settings/AppearanceManager.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
using MahApps.Metro;
22
using MahApps.Metro.Controls.Dialogs;
33
using System;
4+
using System.IO;
45
using System.Windows;
56

67
namespace NETworkManager.Models.Settings
78
{
89
public static class AppearanceManager
910
{
11+
private static string ThemesFilePath = Path.Combine(ConfigurationManager.Current.ExecutionPath, "Themes");
12+
13+
private const string CostomThemeFileExtension = @".Theme.xaml";
14+
private const string CostomAccentFileExtension = @".Accent.xaml";
15+
1016
public static MetroDialogSettings MetroDialog = new MetroDialogSettings();
1117

1218
/// <summary>
1319
/// Load Appearance (AppTheme and Accent) from the user settings.
1420
/// </summary>
1521
public static void Load()
1622
{
23+
// Add custom themes
24+
foreach (string file in Directory.GetFiles(ThemesFilePath))
25+
{
26+
string fileName = Path.GetFileName(file);
27+
28+
// Theme
29+
if (fileName.EndsWith(CostomThemeFileExtension))
30+
ThemeManager.AddAppTheme(fileName.Substring(0, fileName.Length - CostomThemeFileExtension.Length), new Uri(file));
31+
32+
// Accent
33+
if (fileName.EndsWith(CostomAccentFileExtension))
34+
ThemeManager.AddAccent(fileName.Substring(0, fileName.Length - CostomAccentFileExtension.Length), new Uri(file));
35+
}
36+
1737
// Change the AppTheme if it is not empty and different from the currently loaded
1838
string appThemeName = SettingsManager.Current.Appearance_AppTheme;
1939

@@ -38,7 +58,11 @@ public static void Load()
3858
/// <param name="name">Name of the AppTheme</param>
3959
public static void ChangeAppTheme(string name)
4060
{
41-
ThemeManager.ChangeAppTheme(Application.Current, name);
61+
AppTheme theme = ThemeManager.GetAppTheme(name);
62+
63+
// If user has renamed / removed a custom theme --> fallback default
64+
if (theme != null)
65+
ThemeManager.ChangeAppTheme(Application.Current, name);
4266
}
4367

4468
/// <summary>
@@ -50,7 +74,9 @@ public static void ChangeAccent(string name)
5074
Tuple<AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
5175
Accent accent = ThemeManager.GetAccent(name);
5276

53-
ThemeManager.ChangeAppStyle(Application.Current, accent, appStyle.Item1);
77+
// If user has renamed / removed a custom theme --> fallback default
78+
if (accent != null)
79+
ThemeManager.ChangeAppStyle(Application.Current, accent, appStyle.Item1);
5480
}
5581
}
5682
}

Source/NETworkManager/NETworkManager.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,21 @@
429429
<Generator>MSBuild:Compile</Generator>
430430
<SubType>Designer</SubType>
431431
</Page>
432+
<None Include="Themes\Black.Accent.xaml">
433+
<Generator>MSBuild:Compile</Generator>
434+
<SubType>Designer</SubType>
435+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
436+
</None>
437+
<None Include="Themes\Black.Theme.xaml">
438+
<SubType>Designer</SubType>
439+
<Generator>MSBuild:Compile</Generator>
440+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
441+
</None>
442+
<None Include="Themes\White.Theme.xaml">
443+
<Generator>MSBuild:Compile</Generator>
444+
<SubType>Designer</SubType>
445+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
446+
</None>
432447
<Page Include="Views\Applications\PingHostView.xaml">
433448
<Generator>MSBuild:Compile</Generator>
434449
<SubType>Designer</SubType>

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@
529529
<!-- AppTheme.Name -->
530530
<system:String x:Key="String_AppTheme_BaseLight">Hell</system:String>
531531
<system:String x:Key="String_AppTheme_BaseDark">Dunkel</system:String>
532+
<system:String x:Key="String_AppTheme_Black">Schwarz</system:String>
533+
<system:String x:Key="String_AppTheme_White">Weiß</system:String>
532534

533535
<!-- Accent.Name -->
534536
<system:String x:Key="String_Accent_Red">Rot</system:String>
@@ -554,6 +556,7 @@
554556
<system:String x:Key="String_Accent_Mauve">Mauve</system:String>
555557
<system:String x:Key="String_Accent_Taupe">Taupe</system:String>
556558
<system:String x:Key="String_Accent_Sienna">Siena</system:String>
559+
<system:String x:Key="String_Accent_Black">Schwarz</system:String>
557560

558561
<!-- IPStatus -->
559562
<system:String x:Key="String_IPStatus_Success">Erfolgreich</system:String>

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,9 @@
529529
<!-- AppTheme.Name -->
530530
<system:String x:Key="String_AppTheme_BaseLight">Light</system:String>
531531
<system:String x:Key="String_AppTheme_BaseDark">Dark</system:String>
532-
532+
<system:String x:Key="String_AppTheme_Black">Black</system:String>
533+
<system:String x:Key="String_AppTheme_White">White</system:String>
534+
533535
<!-- Accent.Name -->
534536
<system:String x:Key="String_Accent_Red">Red</system:String>
535537
<system:String x:Key="String_Accent_Green">Green</system:String>
@@ -554,6 +556,7 @@
554556
<system:String x:Key="String_Accent_Mauve">Mauve</system:String>
555557
<system:String x:Key="String_Accent_Taupe">Taupe</system:String>
556558
<system:String x:Key="String_Accent_Sienna">Sienna</system:String>
559+
<system:String x:Key="String_Accent_Black">Black</system:String>
557560

558561
<!-- IPStatus -->
559562
<system:String x:Key="String_IPStatus_Success">Success</system:String>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
4+
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
5+
mc:Ignorable="options">
6+
7+
<Color x:Key="HighlightColor">#FF000000</Color>
8+
9+
<Color x:Key="AccentBaseColor">#FF000000</Color>
10+
<!-- 80% -->
11+
<Color x:Key="AccentColor">#CC000000</Color>
12+
<!-- 60% -->
13+
<Color x:Key="AccentColor2">#99000000</Color>
14+
<!-- 40% -->
15+
<Color x:Key="AccentColor3">#66000000</Color>
16+
<!-- 20% -->
17+
<Color x:Key="AccentColor4">#33000000</Color>
18+
19+
<!-- re-set brushes too -->
20+
<SolidColorBrush x:Key="HighlightBrush" Color="{StaticResource HighlightColor}" options:Freeze="True" />
21+
<SolidColorBrush x:Key="AccentBaseColorBrush" Color="{StaticResource AccentBaseColor}" options:Freeze="True" />
22+
<SolidColorBrush x:Key="AccentColorBrush" Color="{StaticResource AccentColor}" options:Freeze="True" />
23+
<SolidColorBrush x:Key="AccentColorBrush2" Color="{StaticResource AccentColor2}" options:Freeze="True" />
24+
<SolidColorBrush x:Key="AccentColorBrush3" Color="{StaticResource AccentColor3}" options:Freeze="True" />
25+
<SolidColorBrush x:Key="AccentColorBrush4" Color="{StaticResource AccentColor4}" options:Freeze="True" />
26+
27+
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="{StaticResource AccentColor}" options:Freeze="True" />
28+
29+
<LinearGradientBrush x:Key="ProgressBrush" StartPoint="1.002,0.5" EndPoint="0.001,0.5" options:Freeze="True">
30+
<GradientStop Offset="0" Color="{StaticResource HighlightColor}" />
31+
<GradientStop Offset="1" Color="{StaticResource AccentColor3}" />
32+
</LinearGradientBrush>
33+
34+
<SolidColorBrush x:Key="CheckmarkFill" Color="{StaticResource AccentColor}" options:Freeze="True" />
35+
<SolidColorBrush x:Key="RightArrowFill" Color="{StaticResource AccentColor}" options:Freeze="True" />
36+
37+
<Color x:Key="IdealForegroundColor">White</Color>
38+
<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
39+
<SolidColorBrush x:Key="IdealForegroundDisabledBrush" Opacity="0.4" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
40+
<SolidColorBrush x:Key="AccentSelectedColorBrush" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
41+
42+
<!-- DataGrid brushes -->
43+
44+
<SolidColorBrush x:Key="MetroDataGrid.HighlightBrush" Color="{StaticResource AccentColor}" options:Freeze="True" />
45+
<SolidColorBrush x:Key="MetroDataGrid.HighlightTextBrush" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
46+
<SolidColorBrush x:Key="MetroDataGrid.MouseOverHighlightBrush" Color="{StaticResource AccentColor3}" options:Freeze="True" />
47+
<SolidColorBrush x:Key="MetroDataGrid.FocusBorderBrush" Color="{StaticResource AccentColor}" options:Freeze="True" />
48+
<SolidColorBrush x:Key="MetroDataGrid.InactiveSelectionHighlightBrush" Color="{StaticResource AccentColor2}" options:Freeze="True" />
49+
<SolidColorBrush x:Key="MetroDataGrid.InactiveSelectionHighlightTextBrush" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
50+
51+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchBrush.Win10" Color="{StaticResource AccentColor}" options:Freeze="True" />
52+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchMouseOverBrush.Win10" Color="{StaticResource AccentColor2}" options:Freeze="True" />
53+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10" Color="{StaticResource IdealForegroundColor}" options:Freeze="True" />
54+
</ResourceDictionary>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
4+
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
5+
mc:Ignorable="options">
6+
7+
<Color x:Key="BlackColor">#FFFFFFFF</Color>
8+
<Color x:Key="WhiteColor">#ff000000</Color>
9+
10+
<Color x:Key="Gray1">#FFF9F9F9</Color>
11+
<Color x:Key="Gray2">#FF7F7F7F</Color>
12+
<Color x:Key="Gray3">#FF9D9D9D</Color>
13+
<Color x:Key="Gray4">#FFA59F93</Color>
14+
<Color x:Key="Gray5">#FFB9B9B9</Color>
15+
<Color x:Key="Gray6">#FFCCCCCC</Color>
16+
<Color x:Key="Gray7">#FF7E7E7E</Color>
17+
<Color x:Key="Gray8">#FF454545</Color>
18+
<Color x:Key="Gray9">#5EC9C9C9</Color>
19+
<Color x:Key="Gray10">#FF2F2F2F</Color>
20+
21+
<Color x:Key="GrayNormal">#FF7D7D7D</Color>
22+
<Color x:Key="GrayHover">#FFAAAAAA</Color>
23+
24+
<Color x:Key="FlyoutColor">#FF2B2B2B</Color>
25+
26+
<!-- re-set brushes too -->
27+
<SolidColorBrush x:Key="BlackBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
28+
<SolidColorBrush x:Key="TextBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
29+
<SolidColorBrush x:Key="LabelTextBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
30+
<SolidColorBrush x:Key="BlackColorBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
31+
<SolidColorBrush x:Key="TextBoxMouseOverInnerBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
32+
<SolidColorBrush x:Key="TextBoxFocusBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
33+
<SolidColorBrush x:Key="ButtonMouseOverBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
34+
<SolidColorBrush x:Key="ButtonMouseOverInnerBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
35+
<SolidColorBrush x:Key="ComboBoxMouseOverBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
36+
<SolidColorBrush x:Key="ComboBoxMouseOverInnerBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
37+
38+
<SolidColorBrush x:Key="ControlBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
39+
<SolidColorBrush x:Key="WhiteBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
40+
<SolidColorBrush x:Key="WhiteColorBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
41+
<SolidColorBrush x:Key="DisabledWhiteBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
42+
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
43+
44+
<SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="{StaticResource WhiteColor}" options:Freeze="True" />
45+
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="{StaticResource BlackColor}" options:Freeze="True" />
46+
47+
<SolidColorBrush x:Key="GrayBrush1" Color="{StaticResource Gray1}" options:Freeze="True" />
48+
<SolidColorBrush x:Key="GrayBrush2" Color="{StaticResource Gray2}" options:Freeze="True" />
49+
<SolidColorBrush x:Key="GrayBrush7" Color="{StaticResource Gray7}" options:Freeze="True" />
50+
<SolidColorBrush x:Key="GrayBrush8" Color="{StaticResource Gray8}" options:Freeze="True" />
51+
<SolidColorBrush x:Key="GrayBrush10" Color="{StaticResource Gray10}" options:Freeze="True" />
52+
53+
<SolidColorBrush x:Key="GrayNormalBrush" Color="{StaticResource GrayNormal}" options:Freeze="True" />
54+
<SolidColorBrush x:Key="GrayHoverBrush" Color="{StaticResource GrayHover}" options:Freeze="True" />
55+
56+
<SolidColorBrush x:Key="SliderValueDisabled" Color="#FF535353" options:Freeze="True" />
57+
<SolidColorBrush x:Key="SliderTrackDisabled" Color="#FF383838" options:Freeze="True" />
58+
<SolidColorBrush x:Key="SliderThumbDisabled" Color="#FF7E7E7E" options:Freeze="True" />
59+
<SolidColorBrush x:Key="SliderTrackHover" Color="#FF737373" options:Freeze="True" />
60+
<SolidColorBrush x:Key="SliderTrackNormal" Color="#FF6C6C6C" options:Freeze="True" />
61+
62+
<SolidColorBrush x:Key="FlyoutBackgroundBrush" Color="{StaticResource FlyoutColor}" options:Freeze="True" />
63+
<SolidColorBrush x:Key="FlyoutForegroundBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
64+
65+
<SolidColorBrush x:Key="FlatButtonPressedBackgroundBrush" Color="#444444" options:Freeze="True" />
66+
67+
<!-- menu brushes -->
68+
<SolidColorBrush x:Key="MenuBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
69+
<SolidColorBrush x:Key="ContextMenuBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
70+
<SolidColorBrush x:Key="SubMenuBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
71+
<SolidColorBrush x:Key="MenuItemBackgroundBrush" Color="{StaticResource WhiteColor}" options:Freeze="True" />
72+
73+
<SolidColorBrush x:Key="ContextMenuBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
74+
<SolidColorBrush x:Key="SubMenuBorderBrush" Color="{StaticResource BlackColor}" options:Freeze="True" />
75+
76+
<SolidColorBrush x:Key="MenuItemSelectionFill" Color="#313131" options:Freeze="True" />
77+
<SolidColorBrush x:Key="MenuItemSelectionStroke" Color="#313131" options:Freeze="True" />
78+
79+
<SolidColorBrush x:Key="TopMenuItemPressedFill" Color="#313131" options:Freeze="True" />
80+
<SolidColorBrush x:Key="TopMenuItemPressedStroke" Color="#E0717070" options:Freeze="True" />
81+
<SolidColorBrush x:Key="TopMenuItemSelectionStroke" Color="#90717070" options:Freeze="True" />
82+
83+
<!-- original #FF9A9A9A" -->
84+
<SolidColorBrush x:Key="DisabledMenuItemForeground" Color="{StaticResource Gray7}" options:Freeze="True" />
85+
<SolidColorBrush x:Key="DisabledMenuItemGlyphPanel" Color="#848589" options:Freeze="True" />
86+
87+
<SolidColorBrush x:Key="{x:Static SystemColors.MenuTextBrushKey}" Color="{StaticResource BlackColor}" options:Freeze="True" />
88+
89+
<Color x:Key="MenuShadowColor">#FFFFFFFF</Color>
90+
91+
<!-- DataGrid brushes -->
92+
93+
<SolidColorBrush x:Key="MetroDataGrid.DisabledHighlightBrush" Color="{StaticResource Gray7}" options:Freeze="True" />
94+
95+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.PressedBrush.Win10" Color="#FF999999" options:Freeze="True" />
96+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OffBorderBrush.Win10" Color="#FFCCCCCC" options:Freeze="True" />
97+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OffMouseOverBorderBrush.Win10" Color="#FFFFFFFF" options:Freeze="True" />
98+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OffDisabledBorderBrush.Win10" Color="#FF666666" options:Freeze="True" />
99+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchDisabledBrush.Win10" Color="#FF444444" options:Freeze="True" />
100+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorBrush.Win10" Color="#FFCCCCCC" options:Freeze="True" />
101+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorMouseOverBrush.Win10" Color="#FFFFFFFF" options:Freeze="True" />
102+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorPressedBrush.Win10" Color="#FFFFFFFF" options:Freeze="True" />
103+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorDisabledBrush.Win10" Color="#FF666666" options:Freeze="True" />
104+
105+
<SolidColorBrush x:Key="MahApps.Metro.Brushes.Badged.DisabledBackgroundBrush" Color="#FF666666" options:Freeze="True" />
106+
107+
</ResourceDictionary>

0 commit comments

Comments
 (0)