新增主题颜色设置,可设置浅色,暗色,已经其他色调。
This commit is contained in:
@@ -164,6 +164,10 @@ using HslCommunication.Profinet;
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
###### 主窗口的暗色主题
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
###### 其他功能等待添加
|
###### 其他功能等待添加
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,13 @@
|
|||||||
xmlns:y="clr-namespace:ClientsLibrary;assembly=ClientsLibrary"
|
xmlns:y="clr-namespace:ClientsLibrary;assembly=ClientsLibrary"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="550" Width="825" WindowState="Maximized" Activated="Window_Activated" Closing="Window_Closing" ContentRendered="Window_ContentRendered" Initialized="Window_Initialized"
|
Title="MainWindow" Height="550" Width="825" WindowState="Maximized" Activated="Window_Activated" Closing="Window_Closing" ContentRendered="Window_ContentRendered" Initialized="Window_Initialized"
|
||||||
Loaded="Window_Loaded">
|
Loaded="Window_Loaded"
|
||||||
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
|
TextElement.FontWeight="Regular"
|
||||||
|
TextElement.FontSize="13"
|
||||||
|
TextOptions.TextFormattingMode="Ideal"
|
||||||
|
TextOptions.TextRenderingMode="Auto"
|
||||||
|
Background="{DynamicResource MaterialDesignPaper}">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
@@ -20,6 +26,8 @@
|
|||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<Style TargetType="TextBlock" BasedOn="{StaticResource MaterialDesignCaptionTextBlock}" x:Key="Caption">
|
<Style TargetType="TextBlock" BasedOn="{StaticResource MaterialDesignCaptionTextBlock}" x:Key="Caption">
|
||||||
<Setter Property="Opacity" Value=".68"></Setter>
|
<Setter Property="Opacity" Value=".68"></Setter>
|
||||||
@@ -126,7 +134,7 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
<!--底部状态栏以及公告-->
|
<!--底部状态栏以及公告-->
|
||||||
<Grid DockPanel.Dock="Bottom" Background="WhiteSmoke">
|
<Grid DockPanel.Dock="Bottom">
|
||||||
<Grid Margin="2">
|
<Grid Margin="2">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -140,8 +148,8 @@
|
|||||||
<TextBlock x:Name="TextBlock_Version">1.0.0</TextBlock>
|
<TextBlock x:Name="TextBlock_Version">1.0.0</TextBlock>
|
||||||
<TextBlock Margin="20,0,0,0">客户端状态:</TextBlock>
|
<TextBlock Margin="20,0,0,0">客户端状态:</TextBlock>
|
||||||
<TextBlock x:Name="TextBlock_ClientStatus">正在连接服务器...</TextBlock>
|
<TextBlock x:Name="TextBlock_ClientStatus">正在连接服务器...</TextBlock>
|
||||||
<TextBlock Margin="20,0,0,0" Foreground="Blue">温馨提示:</TextBlock>
|
<TextBlock Margin="20,0,0,0" Foreground="DodgerBlue">温馨提示:</TextBlock>
|
||||||
<TextBlock x:Name="TextBlock_Information" Foreground="Blue"></TextBlock>
|
<TextBlock x:Name="TextBlock_Information" Foreground="DodgerBlue"></TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||||
@@ -156,7 +164,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Width="100" DockPanel.Dock="Left">
|
<Grid Width="100" DockPanel.Dock="Left">
|
||||||
<Border BorderThickness="0,1,1,1" BorderBrush="LightGray" Padding="5">
|
<Border BorderThickness="0,1,1,1" BorderBrush="DarkGray" Padding="5">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock>随便放点什么东西</TextBlock>
|
<TextBlock>随便放点什么东西</TextBlock>
|
||||||
<Button Style="{StaticResource MaterialDesignRaisedLightButton}" Grid.Column="1" Width="60" VerticalAlignment="Center"
|
<Button Style="{StaticResource MaterialDesignRaisedLightButton}" Grid.Column="1" Width="60" VerticalAlignment="Center"
|
||||||
|
|||||||
@@ -667,7 +667,7 @@ namespace 软件系统客户端Wpf
|
|||||||
UIControl_Home = new UserHome();
|
UIControl_Home = new UserHome();
|
||||||
all_main_render.Add(UIControl_Home);
|
all_main_render.Add(UIControl_Home);
|
||||||
|
|
||||||
UIControl_Palette = new UserPaletteSelector();
|
UIControl_Palette = new UserPaletteSelector() { DataContext = new PaletteSelectorViewModel() };
|
||||||
all_main_render.Add(UIControl_Palette);
|
all_main_render.Add(UIControl_Palette);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
57
软件系统客户端Wpf/Views/AnotherCommandImplementation.cs
Normal file
57
软件系统客户端Wpf/Views/AnotherCommandImplementation.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace 软件系统客户端Wpf.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No WPF project is complete without it's own version of this.
|
||||||
|
/// </summary>
|
||||||
|
public class AnotherCommandImplementation : ICommand
|
||||||
|
{
|
||||||
|
private readonly Action<object> _execute;
|
||||||
|
private readonly Func<object, bool> _canExecute;
|
||||||
|
|
||||||
|
public AnotherCommandImplementation(Action<object> execute) : this(execute, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnotherCommandImplementation(Action<object> execute, Func<object, bool> canExecute)
|
||||||
|
{
|
||||||
|
if (execute == null) throw new ArgumentNullException(nameof(execute));
|
||||||
|
|
||||||
|
_execute = execute;
|
||||||
|
_canExecute = canExecute ?? (x => true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter)
|
||||||
|
{
|
||||||
|
return _canExecute(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(object parameter)
|
||||||
|
{
|
||||||
|
_execute(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler CanExecuteChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
CommandManager.RequerySuggested += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
CommandManager.RequerySuggested -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Refresh()
|
||||||
|
{
|
||||||
|
CommandManager.InvalidateRequerySuggested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs
Normal file
42
软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using MaterialDesignColors;
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace 软件系统客户端Wpf.Views
|
||||||
|
{
|
||||||
|
public class PaletteSelectorViewModel
|
||||||
|
{
|
||||||
|
public PaletteSelectorViewModel()
|
||||||
|
{
|
||||||
|
Swatches = new SwatchesProvider().Swatches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand ToggleBaseCommand { get; } = new AnotherCommandImplementation(o => ApplyBase((bool)o));
|
||||||
|
|
||||||
|
private static void ApplyBase(bool isDark)
|
||||||
|
{
|
||||||
|
new PaletteHelper().SetLightDark(isDark);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Swatch> Swatches { get; }
|
||||||
|
|
||||||
|
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o));
|
||||||
|
|
||||||
|
private static void ApplyPrimary(Swatch swatch)
|
||||||
|
{
|
||||||
|
new PaletteHelper().ReplacePrimaryColor(swatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o));
|
||||||
|
|
||||||
|
private static void ApplyAccent(Swatch swatch)
|
||||||
|
{
|
||||||
|
new PaletteHelper().ReplaceAccentColor(swatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,9 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="700" d:DesignWidth="400">
|
d:DesignHeight="700" d:DesignWidth="400">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<Style x:Key="MaterialDesignFloatingHintTextBox" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}" TargetType="{x:Type TextBox}">
|
||||||
|
<Setter Property="FontSize" Value="24" />
|
||||||
|
</Style>
|
||||||
<Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}">
|
<Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}">
|
||||||
<Setter Property="Margin" Value="0" />
|
<Setter Property="Margin" Value="0" />
|
||||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||||
@@ -82,7 +85,8 @@
|
|||||||
<wpf:Card DockPanel.Dock="Top" Margin="2">
|
<wpf:Card DockPanel.Dock="Top" Margin="2">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<local:Palette DockPanel.Dock="Left" Width="200" />
|
<local:Palette DockPanel.Dock="Left" Width="200" />
|
||||||
<TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">This is your current palette. Configure your initial palette in App.xaml, but palettes can be changed at runtime.</TextBlock>
|
<TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色,可以在app.xaml中进行配置和初始化,
|
||||||
|
也可以在运行的时候进行更改。</TextBlock>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</wpf:Card>
|
</wpf:Card>
|
||||||
<Grid Margin="0 16 0 0">
|
<Grid Margin="0 16 0 0">
|
||||||
@@ -91,9 +95,9 @@
|
|||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Orientation="Horizontal" Margin="8">
|
<StackPanel Orientation="Horizontal" Margin="8">
|
||||||
<TextBlock VerticalAlignment="Center">Light</TextBlock>
|
<TextBlock VerticalAlignment="Center">浅色主题</TextBlock>
|
||||||
<ToggleButton Margin="8 0 16 0" Command="{Binding ToggleBaseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
|
<ToggleButton Margin="8 0 16 0" Command="{Binding ToggleBaseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
|
||||||
<TextBlock VerticalAlignment="Center">Dark</TextBlock>
|
<TextBlock VerticalAlignment="Center">暗色主题</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||||
<ItemsControl ItemsSource="{Binding Swatches, Mode=OneTime}">
|
<ItemsControl ItemsSource="{Binding Swatches, Mode=OneTime}">
|
||||||
|
|||||||
BIN
软件系统客户端Wpf/screenshots/client3.png
Normal file
BIN
软件系统客户端Wpf/screenshots/client3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 106 KiB |
@@ -73,9 +73,11 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Views\AnotherCommandImplementation.cs" />
|
||||||
<Compile Include="Views\Palette.xaml.cs">
|
<Compile Include="Views\Palette.xaml.cs">
|
||||||
<DependentUpon>Palette.xaml</DependentUpon>
|
<DependentUpon>Palette.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\PaletteSelectorViewModel.cs" />
|
||||||
<Compile Include="Views\UserChat.xaml.cs">
|
<Compile Include="Views\UserChat.xaml.cs">
|
||||||
<DependentUpon>UserChat.xaml</DependentUpon>
|
<DependentUpon>UserChat.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in New Issue
Block a user