Skip to content

Commit

Permalink
控件样式基本完毕
Browse files Browse the repository at this point in the history
暗黑主题实装
  • Loading branch information
Hakoyu authored and Hakoyu committed Nov 30, 2022
1 parent 019c315 commit b3927f1
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 125 deletions.
2 changes: 1 addition & 1 deletion App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Panuon.WPF.UI;component/Control.xaml" />
<ResourceDictionary Source="pack://application:,,,/ThemeResources/ControlsStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/ThemeResources/WhiteStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/ThemeResources/BlackStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
2 changes: 2 additions & 0 deletions Pages/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ void ClearDataGridSelected()
void AddUserGroup(string icon, string name)
{
ListBoxItem item = new();
// 调用全局资源需要写全
item.Style = (Style)Application.Current.Resources["ListBoxItem_Style"];
SetListBoxItemData(item, name);
ContextMenu contextMenu = new();
MenuItem menuItem = new();
Expand Down
164 changes: 84 additions & 80 deletions Pages/ModManager.xaml

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions Pages/ModManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ private void Button_GroupMenu_Click(object sender, RoutedEventArgs e)
{
if (groupMenuOpen)
{
Button_GroupMenu.Content = "📘";
Button_GroupMenuIcon.Text = "📘";
Grid_GroupMenu.Width = 30;
}
else
{
Button_GroupMenu.Content = "📖";
Button_GroupMenuIcon.Text = "📖";
Grid_GroupMenu.Width = double.NaN;
}
groupMenuOpen = !groupMenuOpen;
Expand Down Expand Up @@ -340,6 +340,22 @@ private void DataGridItem_MouseDown(object sender, MouseButtonEventArgs e)
if (sender is DataGridRow row)
ModInfoShowChange(row.Tag.ToString()!);
}
private void DataGridItem_MouseMove(object sender, MouseEventArgs e)
{
// 连续点击无效,需要 e.Handled = true
//e.Handled = true;
if (sender is DataGridRow row)
row.Background = (Brush)Application.Current.Resources["ColorLight"];
//ModInfoShowChange(row.Tag.ToString()!);
}
private void DataGridItem_MouseLeave(object sender, MouseEventArgs e)
{
// 连续点击无效,需要 e.Handled = true
//e.Handled = true;
if (sender is DataGridRow row)
row.Background = (Brush)Application.Current.Resources["ColorBG"];
//ModInfoShowChange(row.Tag.ToString()!);
}

private void Button_Enabled_Click(object sender, RoutedEventArgs e)
{
Expand Down
6 changes: 0 additions & 6 deletions StarsectorTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<ItemGroup>
<None Remove="Resources\Config.toml" />
<None Remove="Resources\ModGroup.toml" />
<None Remove="Windows\ui_border2_n.png" />
<None Remove="Windows\标题栏按钮.png" />
<None Remove="Windows\窗口外观.png" />
</ItemGroup>

<ItemGroup>
Expand All @@ -36,9 +33,6 @@

<ItemGroup>
<Resource Include="Resources\Config.toml" />
<Resource Include="Windows\ui_border2_n.png" />
<Resource Include="Windows\标题栏按钮.png" />
<Resource Include="Windows\窗口外观.png" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 9 additions & 5 deletions ThemeResources/BlackStyle.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="GroupBox_Style" TargetType="GroupBox" BasedOn="{StaticResource GroupBox_Style}">
<Setter Property="Background" Value="#33000000" />
<Setter Property="BorderBrush" Value="#6600008B" />
<Setter Property="Foreground" Value="#FFFFFFFF" />
</Style>
<SolidColorBrush x:Key="ColorBG" Color="#FF1E1E1E"/>
<SolidColorBrush x:Key="ColorBB" Color="#FF303030"/>
<SolidColorBrush x:Key="ColorFG" Color="Azure"/>
<SolidColorBrush x:Key="ColorDeep" Color="#33000000"/>
<SolidColorBrush x:Key="ColorLight" Color="#33FFFFFF"/>
<SolidColorBrush x:Key="ColorSelected" Color="#3301FFFF"/>
<SolidColorBrush x:Key="ColorLightYellow" Color="#33FFFF10"/>
<SolidColorBrush x:Key="ColorLightRed" Color="#33FF0000"/>
<SolidColorBrush x:Key="ColorLightBlue" Color="#4C0000FF"/>
</ResourceDictionary>
118 changes: 107 additions & 11 deletions ThemeResources/ControlsStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,114 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:purs="clr-namespace:Panuon.WPF.UI.Resources;assembly=Panuon.WPF.UI">
<!--#region GroupBox-->
<Style x:Key="GroupBox_Style" TargetType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}">
<Setter Property="Padding" Value="5" />
<Setter Property="FontSize" Value="12" />
<Setter Property="pu:GroupBoxHelper.HeaderHeight" Value="20" />
<Setter Property="pu:GroupBoxHelper.HeaderFontSize" Value="16" />
<Setter Property="pu:GroupBoxHelper.HeaderHorizontalContentAlignment" Value="Center" />
<Setter Property="pu:GroupBoxHelper.HeaderPadding" Value="0" />
<Setter Property="Background" Value="{DynamicResource ColorBG}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="pu:GroupBoxHelper.HeaderHeight" Value="20"/>
<Setter Property="pu:GroupBoxHelper.HeaderFontSize" Value="16"/>
<Setter Property="pu:GroupBoxHelper.HeaderHorizontalContentAlignment" Value="Center"/>
<Setter Property="pu:GroupBoxHelper.HeaderPadding" Value="0"/>
<Setter Property="pu:GroupBoxHelper.HeaderFontWeight" Value="Bold"/>
</Style>
<!--#endregion-->
<!--#Label-->

<!--#endregion-->
<Style x:Key="Label_Style" TargetType="Label" BasedOn="{StaticResource {x:Type Label}}">
<Setter Property="Background" Value="{DynamicResource ColorBG}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="pu:IconHelper.FontSize" Value="16"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,10,0"/>
</Style>
<Style x:Key="Button_Style" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="{DynamicResource ColorLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="pu:IconHelper.FontSize" Value="16"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
</Style>
<Style x:Key="ListBox_Style" TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="Background" Value="{DynamicResource ColorBB}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="ListBoxItem_Style" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Background" Value="{DynamicResource ColorLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Padding" Value="0,0,5,0"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
<Setter Property="pu:IconHelper.FontSize" Value="16"/>
<Setter Property="pu:ListBoxItemHelper.HoverBackground" Value="{DynamicResource ColorLight}"/>
<Setter Property="pu:ListBoxItemHelper.HoverShadowColor" Value="Aqua"/>
<Setter Property="pu:ListBoxItemHelper.SelectedBackground" Value="{DynamicResource ColorSelected}"/>
</Style>
<Style x:Key="ComboBox_Style" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="Background" Value="{DynamicResource ColorBB}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="ComboBoxItem_Style" TargetType="ComboBoxItem" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
<Setter Property="Background" Value="{DynamicResource ColorLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Padding" Value="0,0,5,0"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
<Setter Property="pu:IconHelper.FontSize" Value="16"/>
<Setter Property="pu:ComboBoxItemHelper.HoverBackground" Value="{DynamicResource ColorLight}"/>
<Setter Property="pu:ComboBoxItemHelper.SelectedBackground" Value="{DynamicResource ColorSelected}"/>
</Style>
<Style x:Key="Expander_Style" TargetType="Expander" BasedOn="{StaticResource {x:Type Expander}}">
<Setter Property="Background" Value="{DynamicResource ColorBB}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="DataGrid_Style" TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Background" Value="{DynamicResource ColorBG}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="RowHeaderWidth" Value="0"/>
<Setter Property="RowBackground" Value="{DynamicResource ColorBG}"/>
<Setter Property="pu:IconHelper.FontSize" Value="16"/>
<Setter Property="pu:ScrollViewerHelper.ScrollBarPosition" Value="Outside" />
<Setter Property="pu:DataGridHelper.ColumnHeaderFontSize" Value="16"/>
<Setter Property="pu:DataGridHelper.ColumnHeaderSeparatorVisibility" Value="Collapsed" />
<Setter Property="pu:DataGridHelper.ColumnHeaderBackground" Value="{DynamicResource ColorBG}"/>
<Setter Property="pu:DataGridHelper.ColumnHeaderForeground" Value="{DynamicResource ColorFG}"/>
<Setter Property="pu:DataGridHelper.ColumnHeaderHoverBackground" Value="{DynamicResource ColorLight}"/>
<Setter Property="pu:DataGridHelper.ColumnHeaderClickBackground" Value="{DynamicResource ColorSelected}"/>
<!--<Setter Property="pu:DataGridHelper.CellHoverBackground" Value="{DynamicResource ColorLight}"/>-->
<Setter Property="pu:DataGridHelper.CellSelectedBackground" Value="{DynamicResource ColorSelected}"/>
</Style>
<Style x:Key="TextBox_Style" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Background" Value="{DynamicResource ColorLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="pu:IconHelper.Margin" Value="4,-2,5,0"/>
</Style>
<Style x:Key="Window_Style" TargetType="Window" BasedOn="{StaticResource {x:Type Window}}">
<Setter Property="Background" Value="{DynamicResource ColorBG}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ColorBB}"/>
<Setter Property="Foreground" Value="{DynamicResource ColorFG}"/>
<Setter Property="FontSize" Value="12"/>
</Style>
<Style x:Key="Grid_Style" TargetType="Grid">
<Setter Property="Background" Value="{DynamicResource ColorBG}"/>
</Style>
</ResourceDictionary>
43 changes: 25 additions & 18 deletions Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:local="clr-namespace:StarsectorTools"
xmlns:I18n="clr-namespace:StarsectorTools.Langs.Windows.MainWindow"
mc:Ignorable="d"
Title="StarsectorTools" Height="500" Width="1000" WindowStyle="None" WindowStartupLocation="CenterScreen" Background="#33FFFFFF" Padding="5" FontFamily="Consolas" MouseLeftButtonDown="Window_MouseLeftButtonDown">
Title="StarsectorTools" Height="500" Width="1000" WindowStyle="None" WindowStartupLocation="CenterScreen" Padding="5" FontFamily="Consolas" MouseLeftButtonDown="Window_MouseLeftButtonDown" Style="{StaticResource Window_Style}">
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="-1" ResizeBorderThickness="5" CaptionHeight="0"/>
</WindowChrome.WindowChrome>
Expand All @@ -21,29 +22,35 @@
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Style="{StaticResource WindowMainPanelStyle}" >
<Grid x:Name="Grid_TitleBar" VerticalAlignment="Top" MouseLeftButtonDown="Grid_TitleBar_MouseLeftButtonDown" Background="#4CFFFFFF">
<Grid Style="{StaticResource WindowMainPanelStyle}">
<Grid x:Name="Grid_TitleBar" VerticalAlignment="Top" MouseLeftButtonDown="Grid_TitleBar_MouseLeftButtonDown" Background="{DynamicResource ColorBB}">
<Grid HorizontalAlignment="Center">
<Image x:Name="Image_Title" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="20" Source="/Resources/recycling.ico" Margin="5,5,0,0"/>
<Label x:Name="Label_Title" Content="{x:Static I18n:MainWindow_I18n.StarsectorTools}" Padding="0,0,0,0" VerticalContentAlignment="Center" Background="{x:Null}" HorizontalAlignment="Center" Margin="30,0,0,0" FontSize="16"/>
<Label x:Name="Label_Title" Content="{x:Static I18n:MainWindow_I18n.StarsectorTools}" Style="{StaticResource Label_Style}" Padding="0" Background="{x:Null}" HorizontalAlignment="Center" Margin="30,0,0,0" FontSize="20" FontWeight="Bold" />
</Grid>
<Button x:Name="Button_TitleMin" Content="" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#4CEAEAEA" Width="40" Height="30" BorderBrush="{x:Null}" Margin="0,0,80,0" Click="Button_TitleMin_Click" FontSize="16"/>
<Button x:Name="Button_TitleMax" Content="🔲" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#4CEAEAEA" Width="40" Height="30" BorderBrush="{x:Null}" Margin="0,0,40,0" Click="Button_TitleMax_Click" FontSize="16"/>
<Button x:Name="Button_TitleClose" Content="" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#4CEAEAEA" Width="40" Height="30" BorderBrush="{x:Null}" Click="Button_TitleClose_Click" FontSize="16"/>
<Button x:Name="Button_MainMenu" Content="📘" HorizontalAlignment="Left" VerticalAlignment="Center" Height="30" Width="30" Background="#4CEAEAEA" Click="Button_MainMenu_Click" FontSize="16"/>
<Button x:Name="Button_TitleMin" Content="" HorizontalAlignment="Right" Style="{StaticResource Button_Style}" Width="40" Height="30" Margin="0,0,80,0" Click="Button_TitleMin_Click" FontSize="16" pu:ButtonHelper.HoverBackground="Aqua" pu:ButtonHelper.ClickBackground="LightBlue"/>
<Button x:Name="Button_TitleMax" Content="🔲" HorizontalAlignment="Right" Style="{StaticResource Button_Style}" Width="40" Height="30" Margin="0,0,40,0" Click="Button_TitleMax_Click" FontSize="16" pu:ButtonHelper.HoverBackground="Aqua" pu:ButtonHelper.ClickBackground="LightBlue"/>
<Button x:Name="Button_TitleClose" Content="" Style="{StaticResource Button_Style}" HorizontalAlignment="Right" Width="40" Height="30" Click="Button_TitleClose_Click" FontSize="16" pu:ButtonHelper.HoverBackground="Red" pu:ButtonHelper.ClickBackground="IndianRed"/>
<Button x:Name="Button_MainMenu" HorizontalAlignment="Left" VerticalAlignment="Center" Height="30" Width="30" Click="Button_MainMenu_Click" FontSize="16" Style="{StaticResource Button_Style}">
<pu:ButtonHelper.Icon>
<emoji:TextBlock x:Name="Button_MainMenuIcon" Text="📘" FontSize="16"/>
</pu:ButtonHelper.Icon>
</Button>
</Grid>
<Grid Margin="0,30,0,0">
<Grid x:Name="Grid_Menu" Width="30" HorizontalAlignment="Left" SizeChanged="Grid_Menu_SizeChanged">
<ListBox x:Name="ListBox_Menu" Margin="0,0,0,30" HorizontalAlignment="Left" BorderThickness="0" Background="#4CEAEAEA"
pu:IconHelper.Margin="0,0,15,0" SelectionChanged="ListBox_Menu_SelectionChanged" >
<ListBoxItem pu:ListBoxItemHelper.Icon="1" Content="ModManager" />
<ListBoxItem pu:ListBoxItemHelper.Icon="2" Content="Trending" />
<ListBoxItem pu:ListBoxItemHelper.Icon="3" Content="Streaming" />
<ListBoxItem pu:ListBoxItemHelper.Icon="4" Content="Playlist" />
<ListBoxItem pu:ListBoxItemHelper.Icon="5" Content="Bookmark" />
<Grid x:Name="Grid_Menu" HorizontalAlignment="Left" SizeChanged="Grid_Menu_SizeChanged" Width="30">
<ListBox x:Name="ListBox_Menu" Margin="0,0,0,30" HorizontalAlignment="Left" FontSize="16" SelectionChanged="ListBox_Menu_SelectionChanged" Style="{StaticResource ListBox_Style}">
<ListBoxItem Content="ModManager" Style="{StaticResource ListBoxItem_Style}" BorderBrush="#FFA42C2C" >
<pu:ListBoxItemHelper.Icon>
<emoji:TextBlock Text="🌐" FontSize="16"/>
</pu:ListBoxItemHelper.Icon>
</ListBoxItem>
</ListBox>
<Button x:Name="Button_SettingsMenu" Content="" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="30" Background="#4CEAEAEA" Click="Button_SettingsMenu_Click" FontSize="16"/>
<Label Content="{x:Static I18n:MainWindow_I18n.Settings}" Margin="30,0,0,0" VerticalAlignment="Bottom" Background="#4CEAEAEA" Height="30"/>
<Button x:Name="Button_SettingsMenu" Content="设置" VerticalAlignment="Bottom" Height="30" Click="Button_SettingsMenu_Click" FontSize="16" Style="{StaticResource Button_Style}" Margin="0,0,0,0" HorizontalContentAlignment="Left" >
<pu:ButtonHelper.Icon>
<emoji:TextBlock Text="" FontSize="16"/>
</pu:ButtonHelper.Icon>
</Button>
</Grid>
<Frame x:Name="Frame_MainFrame" NavigationUIVisibility="Hidden" Margin="30,0,0,0" ContentRendered="Frame_MainFrame_ContentRendered" />
</Grid>
Expand Down
Loading

0 comments on commit b3927f1

Please sign in to comment.