Skip to content

Commit d14fd1b

Browse files
committed
add dark mode, add popup when couldn't resolve ydd type
1 parent e7756d8 commit d14fd1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+813
-276
lines changed

grzyClothTool/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<setting name="GtaCacheStartup" serializeAs="String">
1212
<value>True</value>
1313
</setting>
14+
<setting name="IsDarkMode" serializeAs="String">
15+
<value>False</value>
16+
</setting>
1417
</grzyClothTool.Properties.Settings>
1518
</userSettings>
1619
</configuration>

grzyClothTool/App.xaml

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,16 @@
11
<Application x:Class="grzyClothTool.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:system="clr-namespace:System;assembly=netstandard"
5-
xmlns:icons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
6-
xmlns:converters="clr-namespace:grzyClothTool.Converters"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
mc:Ignorable="d"
77
StartupUri="./Views/MainWindow.xaml">
88

99
<Application.Resources>
10-
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
11-
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
12-
13-
14-
<Style x:Key="Spin" TargetType="icons:MaterialIcon">
15-
<Style.Triggers>
16-
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
17-
<BeginStoryboard>
18-
<Storyboard>
19-
<DoubleAnimation
20-
Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
21-
From="0" To="360" Duration="0:0:1"
22-
RepeatBehavior="Forever" />
23-
</Storyboard>
24-
</BeginStoryboard>
25-
</EventTrigger>
26-
</Style.Triggers>
27-
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
28-
<Setter Property="RenderTransform">
29-
<Setter.Value>
30-
<RotateTransform Angle="0" />
31-
</Setter.Value>
32-
</Setter>
33-
</Style>
34-
35-
<Color x:Key="Color50">#f6f6f6</Color>
36-
<Color x:Key="Color100">#e7e7e7</Color>
37-
<Color x:Key="Color200">#d1d1d1</Color>
38-
<Color x:Key="Color300">#b0b0b0</Color>
39-
<Color x:Key="Color400">#888888</Color>
40-
<Color x:Key="Color500">#787878</Color>
41-
<Color x:Key="Color600">#5d5d5d</Color>
42-
<Color x:Key="Color700">#4f4f4f</Color>
43-
<Color x:Key="Color800">#454545</Color>
44-
<Color x:Key="Color900">#3d3d3d</Color>
45-
<Color x:Key="Color950">#262626</Color>
46-
47-
<SolidColorBrush x:Key="Brush50" Color="{StaticResource Color50}" />
48-
<SolidColorBrush x:Key="Brush100" Color="{StaticResource Color100}" />
49-
<SolidColorBrush x:Key="Brush200" Color="{StaticResource Color200}" />
50-
<SolidColorBrush x:Key="Brush300" Color="{StaticResource Color300}" />
51-
<SolidColorBrush x:Key="Brush400" Color="{StaticResource Color400}" />
52-
<SolidColorBrush x:Key="Brush500" Color="{StaticResource Color500}" />
53-
<SolidColorBrush x:Key="Brush600" Color="{StaticResource Color600}" />
54-
<SolidColorBrush x:Key="Brush700" Color="{StaticResource Color700}" />
55-
<SolidColorBrush x:Key="Brush800" Color="{StaticResource Color800}" />
56-
<SolidColorBrush x:Key="Brush900" Color="{StaticResource Color900}" />
57-
<SolidColorBrush x:Key="Brush950" Color="{StaticResource Color950}" />
58-
59-
<SolidColorBrush x:Key="White" Color="White" />
60-
<SolidColorBrush x:Key="Black" Color="Black" />
61-
62-
<system:Double x:Key="DisabledOpacity">0.5</system:Double>
63-
64-
<SolidColorBrush x:Key="GroupBoxBorder" Color="{StaticResource Color300}" />
65-
66-
67-
<SolidColorBrush x:Key="ButtonBackground" Color="{StaticResource Color50}" />
68-
<SolidColorBrush x:Key="ButtonHover" Color="{StaticResource Color800}" />
69-
<SolidColorBrush x:Key="ButtonFocus" Color="{StaticResource Color950}" />
70-
<SolidColorBrush x:Key="ButtonBorder" Color="{StaticResource Color400}" />
71-
10+
<ResourceDictionary>
11+
<ResourceDictionary.MergedDictionaries>
12+
<ResourceDictionary d:Source="Themes/Light.xaml" />
13+
</ResourceDictionary.MergedDictionaries>
14+
</ResourceDictionary>
7215
</Application.Resources>
7316
</Application>

grzyClothTool/App.xaml.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
using grzyClothTool.Controls;
1+
using grzyClothTool.Extensions;
22
using grzyClothTool.Views;
3+
using Material.Icons;
34
using System;
45
using System.IO;
56
using System.Threading;
67
using System.Windows;
8+
using grzyClothTool.Properties;
79
using static grzyClothTool.Controls.CustomMessageBox;
810

911
namespace grzyClothTool
@@ -28,10 +30,15 @@ protected override void OnStartup(StartupEventArgs e)
2830

2931
ResetSplashCreated.WaitOne();
3032
base.OnStartup(e);
33+
34+
//get value from settings properties
35+
bool isDarkTheme = Settings.Default.IsDarkMode;
36+
ChangeTheme(isDarkTheme);
3137
}
3238

3339
public App()
3440
{
41+
MaterialIconDataProvider.Instance = new CustomIconProvider(); // use custom icons
3542
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
3643
}
3744

@@ -64,5 +71,16 @@ private void ShowSplash()
6471
System.Windows.Threading.Dispatcher.Run();
6572
}
6673

74+
public static void ChangeTheme(bool isDarkMode)
75+
{
76+
Uri uri = isDarkMode ? new Uri("Themes/Dark.xaml", UriKind.Relative) : new Uri("Themes/Light.xaml", UriKind.Relative);
77+
ResourceDictionary theme = new() { Source = uri };
78+
ResourceDictionary shared = new() { Source = new Uri("Themes/Shared.xaml", UriKind.Relative) };
79+
80+
Current.Resources.MergedDictionaries.Clear();
81+
Current.Resources.MergedDictionaries.Add(theme);
82+
Current.Resources.MergedDictionaries.Add(shared);
83+
}
84+
6785
}
6886
}

grzyClothTool/Controls/Custom/CustomButton.xaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:grzyClothTool.Controls"
7+
xmlns:icons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
78
x:Name="MyCustomButton"
89
d:Height="40" d:Width="280"
910
mc:Ignorable="d">
1011
<UserControl.Resources>
1112
<Style TargetType="Button" x:Key="RoundedButton">
1213
<Setter Property="TextBlock.TextAlignment" Value="Center" />
13-
<Setter Property="Background" Value="{StaticResource Brush200}" />
14-
<Setter Property="Foreground" Value="{StaticResource ButtonFocus}" />
14+
<Setter Property="Background" Value="{DynamicResource Brush200}" />
15+
<Setter Property="Foreground" Value="{DynamicResource Brush950}" />
1516
<Setter Property="Template">
1617
<Setter.Value>
1718
<ControlTemplate TargetType="{x:Type Button}">
@@ -28,11 +29,11 @@
2829
</Style.Resources>
2930
<Style.Triggers>
3031
<Trigger Property="IsMouseOver" Value="True">
31-
<Setter Property="Background" Value="{StaticResource Brush300}" />
32+
<Setter Property="Background" Value="{DynamicResource Brush300}" />
3233
</Trigger>
3334
<Trigger Property="IsEnabled" Value="False">
3435
<Trigger.Setters>
35-
<Setter Property="Opacity" Value="{StaticResource DisabledOpacity}" />
36+
<Setter Property="Opacity" Value="{DynamicResource DisabledOpacity}" />
3637
</Trigger.Setters>
3738
</Trigger>
3839
</Style.Triggers>
@@ -41,8 +42,8 @@
4142
<Style x:Key="ToggleButtonVisibility" TargetType="ToggleButton">
4243
<Setter Property="Visibility" Value="Hidden" />
4344
<Setter Property="TextBlock.TextAlignment" Value="Center" />
44-
<Setter Property="Background" Value="{StaticResource Brush200}" />
45-
<Setter Property="Foreground" Value="{StaticResource ButtonFocus}" />
45+
<Setter Property="Background" Value="{DynamicResource Brush200}" />
46+
<Setter Property="Foreground" Value="{DynamicResource Brush950}" />
4647
<Setter Property="Template">
4748
<Setter.Value>
4849
<ControlTemplate TargetType="{x:Type ToggleButton}">
@@ -57,7 +58,7 @@
5758
<Setter Property="Visibility" Value="Visible" />
5859
</DataTrigger>
5960
<Trigger Property="IsMouseOver" Value="True">
60-
<Setter Property="Background" Value="{StaticResource Brush300}" />
61+
<Setter Property="Background" Value="{DynamicResource Brush300}" />
6162
</Trigger>
6263
</Style.Triggers>
6364
<Style.Resources>
@@ -70,14 +71,14 @@
7071

7172

7273
<Grid>
73-
<Border x:Name="btn" BorderBrush="{StaticResource ButtonBorder}" BorderThickness="0" CornerRadius="{Binding CornerRadius, ElementName=MyCustomButton}">
74+
<Border x:Name="btn" BorderBrush="{DynamicResource Brush400}" BorderThickness="0" CornerRadius="{Binding CornerRadius, ElementName=MyCustomButton}">
7475
<Button Content="{Binding Label, ElementName=MyCustomButton}" ToolTip="{Binding Tooltip, ElementName=MyCustomButton}" BorderThickness="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="16" Click="Button_Click">
7576
<Button.Style>
7677
<Style TargetType="Button" BasedOn="{StaticResource RoundedButton}">
7778
<Setter Property="ContentTemplate">
7879
<Setter.Value>
7980
<DataTemplate>
80-
<Image Source="{Binding Image, ElementName=MyCustomButton}" />
81+
<icons:MaterialIcon Kind="{Binding Image, ElementName=MyCustomButton}" Foreground="{DynamicResource Brush950}" />
8182
</DataTemplate>
8283
</Setter.Value>
8384
</Setter>
@@ -97,12 +98,12 @@
9798
</Button>
9899
</Border>
99100

100-
<ToggleButton Style="{StaticResource ToggleButtonVisibility}" x:Name="DropdownToggle" HorizontalAlignment="Right" VerticalAlignment="Center" Width="30" Height="{Binding ActualHeight, ElementName=btn}" >
101-
<Path Data="M 0 0 L 4 4 L 8 0 Z" Fill="{StaticResource ButtonFocus}" Width="12" Height="8" Stretch="Fill" />
101+
<ToggleButton Style="{DynamicResource ToggleButtonVisibility}" x:Name="DropdownToggle" HorizontalAlignment="Right" VerticalAlignment="Center" Width="30" Height="{Binding ActualHeight, ElementName=btn}" >
102+
<Path Data="M 0 0 L 4 4 L 8 0 Z" Fill="{DynamicResource Brush950}" Width="12" Height="8" Stretch="Fill" />
102103
</ToggleButton>
103104

104105
<Popup Width="{Binding ActualWidth, ElementName=btn}" PlacementTarget="{Binding ElementName=btn}" Placement="Bottom" StaysOpen="False" IsOpen="{Binding IsChecked, ElementName=DropdownToggle}" AllowsTransparency="True">
105-
<Border CornerRadius="{Binding CornerRadius, ElementName=MyCustomButton}" Background="{StaticResource Brush400}" Padding="1" BorderThickness="1">
106+
<Border CornerRadius="{Binding CornerRadius, ElementName=MyCustomButton}" Background="{DynamicResource Brush400}" Padding="1" BorderThickness="1">
106107
<ContentPresenter x:Name="DropdownContentPresenter" Content="{Binding Content, ElementName=MyCustomButton}" />
107108
</Border>
108109
</Popup>

grzyClothTool/Controls/Custom/CustomButton.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class CustomButton : UserControl
2323

2424
public static readonly DependencyProperty ImageProperty = DependencyProperty
2525
.Register("Image",
26-
typeof(ImageSource),
26+
typeof(string),
2727
typeof(CustomButton),
2828
new FrameworkPropertyMetadata(null));
2929

@@ -64,9 +64,9 @@ public string Label
6464
set { SetValue(LabelProperty, value); }
6565
}
6666

67-
public ImageSource Image
67+
public string Image
6868
{
69-
get { return (ImageSource)GetValue(ImageProperty); }
69+
get { return (string)GetValue(ImageProperty); }
7070
set { SetValue(ImageProperty, value); }
7171
}
7272

grzyClothTool/Controls/Custom/CustomMessageBox.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
WindowStartupLocation="CenterOwner"
1515
ResizeMode="NoResize"
1616
Title="CustomMessageBox" Height="450" Width="800">
17-
<Grid Margin="5" Background="White">
17+
<Grid Margin="5" Background="{DynamicResource Brush50}">
1818
<Grid.ColumnDefinitions>
1919
<ColumnDefinition Width="32"/>
2020
<ColumnDefinition Width="*"/>
@@ -28,7 +28,7 @@
2828
<!-- Border for our custom message box -->
2929
<Border Grid.ColumnSpan="3"
3030
Grid.RowSpan="3"
31-
BorderBrush="Gray"
31+
BorderBrush="{DynamicResource Brush100}"
3232
BorderThickness="1"
3333
HorizontalAlignment="Stretch"
3434
VerticalAlignment="Stretch">
@@ -50,7 +50,7 @@
5050
Foreground="Black"
5151
FontWeight="SemiBold"
5252
Margin="1,1,1,0"
53-
Padding="5,2,0,0"
53+
Padding="5,4,0,0"
5454
MouseLeftButtonDown="OnCaptionPress"/>
5555
<!-- Icon for our custom message box -->
5656
<Image x:Name="CMBIcon"
@@ -67,12 +67,13 @@
6767
Margin="2,24,4,24">
6868
<TextBlock x:Name="CMBMessage"
6969
TextWrapping="Wrap"
70+
Foreground="{DynamicResource Brush950}"
7071
Text="Custom Message Box Message"/>
7172
</Label>
7273
<!-- Background for button block -->
7374
<Rectangle Grid.Row="2"
7475
Grid.ColumnSpan="2"
75-
Fill="{StaticResource Brush100}"
76+
Fill="{DynamicResource Brush100}"
7677
Margin="1,0,1,1"/>
7778
<!-- Buttons block -->
7879
<StackPanel x:Name="CMBButtons"

grzyClothTool/Controls/Drawable/DrawableList.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Setter Property="Template">
1414
<Setter.Value>
1515
<ControlTemplate TargetType="ListBoxItem">
16-
<Border x:Name="Border" BorderBrush="{StaticResource Brush800}" BorderThickness="1" Padding="0, 5, 0, 5" Margin="0,2,2,2" CornerRadius="5">
16+
<Border x:Name="Border" BorderBrush="{DynamicResource Brush600}" BorderThickness="1" Padding="0, 5, 0, 5" Margin="0,2,2,2" CornerRadius="5">
1717
<Grid>
1818
<Grid.ColumnDefinitions>
1919
<ColumnDefinition Width="4"/>
@@ -55,7 +55,7 @@
5555
</Border>
5656
<ControlTemplate.Triggers>
5757
<Trigger Property="IsMouseOver" Value="True">
58-
<Setter Property="Background" Value="{StaticResource Brush200 }" TargetName="Border"/>
58+
<Setter Property="Background" Value="{DynamicResource Brush200}" TargetName="Border"/>
5959
</Trigger>
6060
<Trigger Property="IsSelected" Value="True">
6161
<Setter Property="FontWeight" Value="Bold" />
@@ -73,7 +73,8 @@
7373
</UserControl.Resources>
7474

7575
<ListBox
76-
Background="{StaticResource Brush50}"
76+
Background="Transparent"
77+
Foreground="{DynamicResource Brush950}"
7778
x:Name="MyListBox"
7879
SelectionChanged="ListBox_SelectionChanged"
7980
HorizontalContentAlignment="Stretch"

0 commit comments

Comments
 (0)