Skip to content

Commit

Permalink
featire: add dark style to resources (not finished)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukegor committed Jul 18, 2024
1 parent 08cefbf commit cce0be9
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 9 deletions.
10 changes: 7 additions & 3 deletions JSharp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:JSharp"
xmlns:prism="http://prismlibrary.com/">
<Application.Resources>

</Application.Resources>
<Application.Resources>
<!--<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Themes.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>-->
</Application.Resources>
</prism:PrismApplication>
142 changes: 142 additions & 0 deletions JSharp/Resources/Themes.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">

<!-- Define brushes for dark mode -->
<Color x:Key="DarkBackgroundColor">#333333</Color>
<Color x:Key="DarkForegroundColor">#FFFFFF</Color>
<Color x:Key="DarkBorderColor">#444444</Color>
<SolidColorBrush x:Key="DarkBackgroundBrush" Color="{StaticResource DarkBackgroundColor}" />
<SolidColorBrush x:Key="DarkForegroundBrush" Color="{StaticResource DarkForegroundColor}" />
<SolidColorBrush x:Key="DarkBorderBrush" Color="{StaticResource DarkBorderColor}" />
<SolidColorBrush x:Key="DarkControlBrush" Color="#444444" />

<!-- Window Style -->
<Style TargetType="Window">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- Grid Style -->
<Style TargetType="Grid">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
</Style>

<!-- Button Style -->
<Style TargetType="Button">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- ComboBox Style -->
<Style TargetType="ComboBox">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- ComboBoxItem Style -->
<Style TargetType="ComboBoxItem">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- TextBlock Style -->
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- Label Style -->
<Style TargetType="Label">
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- TextBox Style -->
<Style TargetType="TextBox">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- xctk:IntegerUpDown Style -->
<Style TargetType="xctk:IntegerUpDown">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- ToolBar Style -->
<Style TargetType="ToolBar">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- Menu Style -->
<Style TargetType="Menu">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- MenuItem Style -->
<Style TargetType="MenuItem">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Style.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter Property="Background" Value="{StaticResource DarkControlBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Trigger>
</Style.Triggers>
</Style>

<!-- TabControl Style -->
<Style TargetType="TabControl">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- TabItem Style -->
<Style TargetType="TabItem">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- DataGrid Style -->
<Style TargetType="DataGrid">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- CheckBox Style -->
<Style TargetType="CheckBox">
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- RadioButton Style -->
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- Slider Style -->
<Style TargetType="Slider">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DarkForegroundBrush}" />
</Style>

<!-- ScrollViewer Style -->
<Style TargetType="ScrollViewer">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
</Style>

<!-- Separator Style -->
<Style TargetType="Separator">
<Setter Property="Background" Value="{StaticResource DarkBorderBrush}" />
</Style>

<!-- Window Title Bar Style (if using a custom window) -->
<Style x:Key="WindowChromeStyle" TargetType="ContentPresenter">
</Style>
</ResourceDictionary>
4 changes: 2 additions & 2 deletions JSharp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ internal void UpdateDescriptor()
System.Windows.Point? startPoint = focusedImage.Points[0];
if (startPoint != null)
{
sb.Append($", Top-left Point 1: ({focusedImage.Points[0]})");
sb.Append($", Top-left {WindowSpecific.Point} 1: ({focusedImage.Points[0]})");

System.Windows.Point? endPoint = focusedImage.Points[1];
if (endPoint != null)
{
sb.Append($", Bottom-right Point 2: ({FocusedImage.Points[1]})");
sb.Append($", Bottom-right {WindowSpecific.Point} 2: ({FocusedImage.Points[1]})");

// Calculate the width and height of the rectangle
double width = Math.Abs(endPoint.Value.X - startPoint.Value.X);
Expand Down
10 changes: 6 additions & 4 deletions JSharp/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:prism="http://prismlibrary.com/"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="JSharp.MainWindow"
mc:Ignorable="d"
Title="JSharp" Height="200" Width="700" ResizeMode="CanMinimize" Closing="Window_Closing" PreviewKeyDown="Window_PreviewKeyDown">
Title="JSharp" Height="180" Width="700" ResizeMode="CanMinimize" Closing="Window_Closing" PreviewKeyDown="Window_PreviewKeyDown">

<Window.DataContext>
<viewModel:MainWindowViewModel/>
Expand Down Expand Up @@ -99,16 +99,18 @@
<MenuItem Header="{x:Static resx:Strings.ShowHistogram}" Command="{Binding ShowHistogram_ClickCommand}"/>
<MenuItem Header="{x:Static resx:Strings.PlotProfile}" Command="{Binding PlotProfile_ClickCommand}"/>
<Separator/>
<MenuItem Header="{x:Static resx:Thresholding.SimpleAnalyze}" Command="{Binding SimpleAnalyze_ClickCommand}"/>
<MenuItem Header="{x:Static resx:Thresholding.Analyze}" Command="{Binding Analyze_ClickCommand}"/>
<MenuItem Header="{x:Static resx:Strings.Analyze}">
<MenuItem Header="{x:Static resx:Thresholding.SimpleAnalyze}" Command="{Binding SimpleAnalyze_ClickCommand}"/>
<MenuItem Header="{x:Static resx:Thresholding.Analyze}" Command="{Binding Analyze_ClickCommand}"/>
</MenuItem>
</MenuItem>
<MenuItem Header="{x:Static resx:UIStrings.Settings}" Command="{Binding OpenSettings_ClickCommand}"/>
<MenuItem Header="{x:Static resx:UIStrings.Help}">
<MenuItem Header="{x:Static resx:UIStrings.About}" Click="About_Click"/>
</MenuItem>
</Menu>
<Label x:Name="LblFocusedImage" Content="{Binding LblFocusedImageContent, TargetNullValue=null}" Grid.Row="1" HorizontalAlignment="Left" Margin="0,2,0,0" VerticalAlignment="Top" Height="31" Width="Auto"/>
<ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="700" Grid.Row="2" ToolBarTray.IsLocked="True">
<ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="600" Grid.Row="2" ToolBarTray.IsLocked="True">
<RadioButton x:Name="RadioBtnNone" GroupName="ToolGroup" Checked="RadioButton_Checked" Unchecked="RadioButton_Unchecked">
<RadioButton.Background>
<ImageBrush ImageSource="/Resources/Icons/ToolBar_Icons/NoneIcon.ico"/>
Expand Down

0 comments on commit cce0be9

Please sign in to comment.