Skip to content

Commit

Permalink
Merge pull request #2 from Hibi-10000/feat/dark-theme
Browse files Browse the repository at this point in the history
✨ ダークモード対応(暫定)
  • Loading branch information
Hibi-10000 authored Dec 24, 2024
2 parents 887bf79 + e538b8e commit 6034f7b
Show file tree
Hide file tree
Showing 26 changed files with 7,673 additions and 13 deletions.
30 changes: 30 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,33 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

## WPF Theme Library

**Source**: https://github.com/AngryCarrot789/WPFDarkTheme

### License

```
MIT License
Copyright (c) 2021 REghZy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
2 changes: 2 additions & 0 deletions src/Hash.Wpf/AboutWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Windows;
using System.Windows.Navigation;
using Dark.Net;

namespace Hash.Wpf;

Expand All @@ -26,6 +27,7 @@ public partial class AboutWindow : Window
public AboutWindow()
{
InitializeComponent();
DarkNet.Instance.SetWindowThemeWpf(this, Theme.Auto);
}

private void OK_OnClick(object sender, RoutedEventArgs e)
Expand Down
12 changes: 11 additions & 1 deletion src/Hash.Wpf/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Hash.Wpf">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- Contains all of the colours and brushes for a theme -->
<ResourceDictionary Source="Themes/ColourDictionaries/SoftDark.xaml"/>
<!-- Contains most of the control-specific brushes which reference -->
<!-- the above theme. I aim for this to contain ALL brushes, not most -->
<ResourceDictionary Source="Themes/ControlColours.xaml"/>
<!-- Contains all of the control styles (Button, ListBox, etc) -->
<ResourceDictionary Source="Themes/Controls.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
6 changes: 6 additions & 0 deletions src/Hash.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.IO;
using System.Threading;
using System.Windows;
using Dark.Net;
using Hash.Core;
using Microsoft.Win32;

Expand Down Expand Up @@ -93,6 +94,11 @@ public static void Main() {
mutex.ReleaseMutex();
}

protected override void OnStartup(StartupEventArgs e) {
base.OnStartup(e);
DarkNet.Instance.SetCurrentProcessTheme(Theme.Auto);
}

internal static void OpenLink(string link)
{
ProcessStartInfo startInfo = new ProcessStartInfo(link)
Expand Down
3 changes: 3 additions & 0 deletions src/Hash.Wpf/Hash.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<ItemGroup>
<ProjectReference Include="..\Hash.Core\Hash.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DarkNet" Version="2.3.0" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Hash.Wpf/HashForContextWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Dark.Net;
using Hash.Core;
using Microsoft.Win32;

Expand All @@ -31,6 +32,7 @@ public partial class HashForContextWindow : Window
public HashForContextWindow()
{
InitializeComponent();
DarkNet.Instance.SetWindowThemeWpf(this, Theme.Auto);
}

private void OK_OnClick(object sender, RoutedEventArgs e)
Expand Down
34 changes: 22 additions & 12 deletions src/Hash.Wpf/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,36 @@
mc:Ignorable="d"
Title="HashCalculator" Icon="./Resources/Hash.ico"
Loaded="MainWindow_OnLoaded"
Background="{DynamicResource Window.Static.Background}"
BorderBrush="{DynamicResource Window.Static.BorderBrush}"
Foreground="{DynamicResource Window.Static.Foreground}"
MinHeight="387" MinWidth="520" Height="400" Width="520">
<Grid Background="#FFF0F0F0">
<Grid Background="{DynamicResource ABrush.Tone2.Background.Static}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Menu Grid.Row="0" Background="#FFE3E3E3">
<Menu Grid.Row="0" Background="{DynamicResource ABrush.Tone4.Background.Static}">
<MenuItem Header="ファイル(_F)" FontSize="13">
<MenuItem Header="設定(_S)" Background="#FFF0F0F0" BorderBrush="#FFF0F0F0" Click="menuFileSettings_OnClick"/>
<MenuItem Header="終了(_X)" Background="#FFF0F0F0" BorderBrush="#FFF0F0F0" Click="menuFileExit_OnClick"/>
<MenuItem Header="設定(_S)" Background="{DynamicResource ABrush.Tone2.Background.Static}" BorderBrush="{DynamicResource ABrush.Tone2.Background.Static}" Click="menuFileSettings_OnClick"/>
<MenuItem Header="終了(_X)" Background="{DynamicResource ABrush.Tone2.Background.Static}" BorderBrush="{DynamicResource ABrush.Tone2.Background.Static}" Click="menuFileExit_OnClick"/>
</MenuItem>
<MenuItem Header="ヘルプ(_H)" FontSize="13">
<MenuItem Header="Readme(_R)" Background="#FFF0F0F0" BorderBrush="#FFF0F0F0" Click="menuHelpReadme_OnClick"/>
<MenuItem Header="バージョン情報(_V)" Background="#FFF0F0F0" BorderBrush="#FFF0F0F0" Click="menuHelpVer_OnClick"/>
<MenuItem Header="Readme(_R)" Background="{DynamicResource ABrush.Tone2.Background.Static}" BorderBrush="{DynamicResource ABrush.Tone2.Background.Static}" Click="menuHelpReadme_OnClick"/>
<MenuItem Header="バージョン情報(_V)" Background="{DynamicResource ABrush.Tone2.Background.Static}" BorderBrush="{DynamicResource ABrush.Tone2.Background.Static}" Click="menuHelpVer_OnClick"/>
</MenuItem>
</Menu>
<Grid Grid.Row="1" Margin="5">
<Label x:Name="hashAndVer" Content="HashCalculator" FontSize="35" BorderThickness="1" Padding="10,0" HorizontalAlignment="Left" BorderBrush="Black" Background="White" Foreground="Lime" FontWeight="Bold"/>
<Label x:Name="hashAndVer" Content="HashCalculator" FontSize="35" BorderThickness="1" Padding="10,0" HorizontalAlignment="Left"
BorderBrush="{DynamicResource ABrush.Foreground.Deeper}" Background="{DynamicResource ABrush.Tone2.Background.Static}" FontWeight="Bold">
<Label.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="Lime" />
</DataTemplate>
</Label.ContentTemplate>
</Label>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top">
<Label Content="CreatedBy : Hibi__10000" Padding="0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
Expand All @@ -59,7 +69,7 @@
</StackPanel>
</StackPanel>
</Grid>
<TabControl Grid.Row="2" Margin="3" x:Name="Tab">
<TabControl Grid.Row="2" Margin="3" x:Name="Tab" Padding="2" Background="{DynamicResource PanelBackground2}">
<TabItem Header="Hash計算機">
<Grid Margin="5">
<Grid.RowDefinitions>
Expand All @@ -73,7 +83,7 @@
<TextBox x:Name="HashFileURL" Text="ファイルのパス" FontSize="14" TextWrapping="Wrap" Cursor="No" IsReadOnly="True" AllowDrop="False" AcceptsReturn="True"/>
</Grid>
<Grid Grid.Row="1" Margin="0,5" AllowDrop="True" Drop="DropPanel_OnDrop" DragEnter="DropPanel_OnDragEnter">
<Rectangle Stroke="Black"/>
<Rectangle Stroke="{DynamicResource ABrush.Foreground.Deeper}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Label Content="ここにファイルをドロップ" FontSize="30" Padding="5"/>
<Button Content="ファイルを選択" FontSize="25" Margin="10,5" Padding="10,0" Click="SelectFileButton_OnClick"/>
Expand Down Expand Up @@ -124,7 +134,7 @@
<Button Padding="10,0" Foreground="Red" Content="リセット" Click="compareReset_OnClick"/>
</Grid>
<Grid Grid.Row="1" Margin="0,0,0,1" HorizontalAlignment="Left">
<Rectangle Stroke="#FFACACAC"/>
<Rectangle Stroke="{DynamicResource TextBox.Static.Border}"/>
<Label Content="比較①" Padding="2,0"/>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal">
Expand All @@ -141,7 +151,7 @@
<TextBox x:Name="compare1hash" Text="" FontSize="14"/>
</Grid>
<Grid Grid.Row="4" Margin="0,0,0,1" HorizontalAlignment="Left">
<Rectangle Stroke="#FFACACAC"/>
<Rectangle Stroke="{DynamicResource TextBox.Static.Border}"/>
<Label Content="比較②" Padding="2,0"/>
</Grid>
<StackPanel Grid.Row="5" Orientation="Horizontal">
Expand Down Expand Up @@ -187,7 +197,7 @@
<TabItem Header="設定">
<Grid>
<Grid HorizontalAlignment="Left" VerticalAlignment="Top">
<Rectangle Stroke="Black"/>
<Rectangle Stroke="{DynamicResource ABrush.Foreground.Static}"/>
<Label Content="設定" FontSize="24" Padding="5,0"/>
</Grid>
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="40,50,0,0">
Expand Down
6 changes: 6 additions & 0 deletions src/Hash.Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Dark.Net;
using Hash.Core;
using Microsoft.Win32;

Expand All @@ -38,6 +39,11 @@ public partial class MainWindow : Window
public MainWindow(bool multiInstance)
{
InitializeComponent();
DarkNet.Instance.SetWindowThemeWpf(this, Theme.Auto);
new Dark.Net.Wpf.SkinManager().RegisterSkins(
lightThemeResources: new Uri("Themes/ColourDictionaries/LightTheme.xaml", UriKind.Relative),
darkThemeResources: new Uri("Themes/ColourDictionaries/SoftDark.xaml", UriKind.Relative)
);
if (multiInstance)
{
HashForContextEnable.IsEnabled = false;
Expand Down
22 changes: 22 additions & 0 deletions src/Hash.Wpf/Themes/Attached/CornerRadiusHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// MIT License
// https://github.com/AngryCarrot789/WPFDarkTheme/blob/5993251fed1780ead1a01630d2f0d792e71c8eab/LICENSE
//
// See NOTICE.md for the full license text.

// CornerRadiusHelper.cs
// https://github.com/AngryCarrot789/WPFDarkTheme/blob/5993251fed1780ead1a01630d2f0d792e71c8eab/Theme.WPF/Themes/Attached/CornerRadiusHelper.cs
//

using System.Windows;

namespace Hash.Wpf.Themes.Attached
{
public static class CornerRadiusHelper
{
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached("Value", typeof(CornerRadius), typeof(CornerRadiusHelper), new PropertyMetadata(new CornerRadius(0)));

public static void SetValue(DependencyObject element, CornerRadius value) => element.SetValue(ValueProperty, value);

public static CornerRadius GetValue(DependencyObject element) => (CornerRadius) element.GetValue(ValueProperty);
}
}
Loading

0 comments on commit 6034f7b

Please sign in to comment.