更新 VPet.Solution

This commit is contained in:
Hakoyu 2023-12-30 23:50:37 +08:00
parent 6aac99b85f
commit 9fffaaaa95
33 changed files with 1413 additions and 882 deletions

View File

@ -1,4 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:pucore="clr-namespace:Panuon.WPF;assembly=Panuon.WPF">

View File

@ -1,4 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:pucore="clr-namespace:Panuon.WPF;assembly=Panuon.WPF">
@ -6,8 +7,12 @@
<pucore:SharedResourceDictionary Source="/Panuon.WPF.UI;component/Control.xaml" />
</ResourceDictionary.MergedDictionaries>
<DrawingBrush x:Key="ProgressBarForeground" Viewport="0,0,8,22" ViewportUnits="Absolute" Stretch="None"
TileMode="Tile">
<DrawingBrush
x:Key="ProgressBarForeground"
Stretch="None"
TileMode="Tile"
Viewport="0,0,8,22"
ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<RotateTransform Angle="2" />
</DrawingBrush.RelativeTransform>
@ -30,8 +35,12 @@
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush x:Key="SuccessProgressBarForeground" Viewport="0,0,8,22" ViewportUnits="Absolute" Stretch="None"
TileMode="Tile">
<DrawingBrush
x:Key="SuccessProgressBarForeground"
Stretch="None"
TileMode="Tile"
Viewport="0,0,8,22"
ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<RotateTransform Angle="2" />
</DrawingBrush.RelativeTransform>
@ -54,8 +63,12 @@
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush x:Key="WarningProgressBarForeground" Viewport="0,0,8,22" ViewportUnits="Absolute" Stretch="None"
TileMode="Tile">
<DrawingBrush
x:Key="WarningProgressBarForeground"
Stretch="None"
TileMode="Tile"
Viewport="0,0,8,22"
ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<RotateTransform Angle="2" />
</DrawingBrush.RelativeTransform>
@ -78,8 +91,12 @@
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush x:Key="DangerProgressBarForeground" Viewport="0,0,8,22" ViewportUnits="Absolute" Stretch="None"
TileMode="Tile">
<DrawingBrush
x:Key="DangerProgressBarForeground"
Stretch="None"
TileMode="Tile"
Viewport="0,0,8,22"
ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<RotateTransform Angle="2" />
</DrawingBrush.RelativeTransform>
@ -109,21 +126,27 @@
<Setter Property="pu:WindowXCaption.Buttons" Value="Close" />
<Setter Property="pu:WindowXCaption.CloseButtonStyle">
<Setter.Value>
<Style TargetType="Button" BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}">
<Style BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}" TargetType="Button">
<Setter Property="pu:ButtonHelper.HoverBackground" Value="{x:Null}" />
</Style>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ThemedButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Style
x:Key="ThemedButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource DARKPrimary}" />
<Setter Property="Foreground" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="Padding" Value="10,5" />
<Setter Property="pu:ButtonHelper.CornerRadius" Value="5" />
</Style>
<Style x:Key="TextButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Style
x:Key="TextButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryDarker}" />
<Setter Property="Cursor" Value="Hand" />
@ -131,11 +154,17 @@
<Setter Property="FontSize" Value="12" />
</Style>
<Style x:Key="DARKPrimaryTextButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource TextButtonStyle}">
<Style
x:Key="DARKPrimaryTextButtonStyle"
BasedOn="{StaticResource TextButtonStyle}"
TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="{DynamicResource DARKPrimaryText}" />
</Style>
<Style x:Key="IconInvertedForegroundRepeatButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource {x:Type RepeatButton}}">
<Style
x:Key="IconInvertedForegroundRepeatButtonStyle"
BasedOn="{StaticResource {x:Type RepeatButton}}"
TargetType="{x:Type RepeatButton}">
<Setter Property="Width" Value="25" />
<Setter Property="Height" Value="25" />
<Setter Property="Background" Value="Transparent" />
@ -146,18 +175,23 @@
<Setter Property="FontFamily" Value="pack://application:,,,/Res/#remixicon" />
</Style>
<Style x:Key="LinkButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource TextButtonStyle}">
<Style
x:Key="LinkButtonStyle"
BasedOn="{StaticResource TextButtonStyle}"
TargetType="{x:Type Button}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}"
TextDecorations="Underline" />
<TextBlock Text="{Binding}" TextDecorations="Underline" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StndardToggleButtonStyle" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Style
x:Key="StndardToggleButtonStyle"
BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ToggleButtonHelper.CheckedBackground" Value="{DynamicResource DARKPrimaryDarker}" />
<Setter Property="Foreground" Value="{DynamicResource DARKPrimaryText}" />
@ -165,7 +199,10 @@
<Setter Property="pu:ButtonHelper.CornerRadius" Value="5" />
</Style>
<Style x:Key="TextToggleButtonStyle" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Style
x:Key="TextToggleButtonStyle"
BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryDarker}" />
<Setter Property="Cursor" Value="Hand" />
@ -173,7 +210,10 @@
<Setter Property="FontSize" Value="14" />
</Style>
<Style x:Key="LinkToggleButtonStyle" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource TextToggleButtonStyle}">
<Style
x:Key="LinkToggleButtonStyle"
BasedOn="{StaticResource TextToggleButtonStyle}"
TargetType="{x:Type ToggleButton}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
@ -193,7 +233,10 @@
<Setter Property="ItemsCornerRadius" Value="2" />
</Style>
<Style x:Key="StandardComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
<Style
x:Key="StandardComboBoxStyle"
BasedOn="{StaticResource {x:Type ComboBox}}"
TargetType="{x:Type ComboBox}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="{DynamicResource DARKPrimaryText}" />
@ -217,8 +260,7 @@
<Setter Property="pu:ShadowHelper.Opacity" Value="0.5" />
<Setter Property="pu:ComboBoxHelper.ToggleArrowTransformControlStyle">
<Setter.Value>
<Style TargetType="pu:TransformControl"
BasedOn="{StaticResource {x:Static pu:ComboBoxHelper.ToggleArrowTransformControlStyleKey}}">
<Style BasedOn="{StaticResource {x:Static pu:ComboBoxHelper.ToggleArrowTransformControlStyleKey}}" TargetType="pu:TransformControl">
<Setter Property="Foreground" Value="{DynamicResource PrimaryText}" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Content" Value="&#xe91f;" />
@ -226,7 +268,10 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StandardTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Style
x:Key="StandardTextBoxStyle"
BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="TextBox">
<Setter Property="FontSize" Value="14" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="{DynamicResource DARKPrimaryText}" />
@ -238,7 +283,10 @@
<Setter Property="pu:ShadowHelper.BlurRadius" Value="15" />
<Setter Property="pu:ShadowHelper.Opacity" Value="0.5" />
</Style>
<Style x:Key="StandardSliderStyle" TargetType="Slider" BasedOn="{StaticResource {x:Type Slider}}">
<Style
x:Key="StandardSliderStyle"
BasedOn="{StaticResource {x:Type Slider}}"
TargetType="Slider">
<Setter Property="Background" Value="{DynamicResource DARKPrimaryTrans4}" />
<Setter Property="Foreground" Value="{DynamicResource DARKPrimaryDark}" />
<Setter Property="pu:SliderHelper.ThumbShadowColor" Value="{DynamicResource ShadowColor}" />
@ -251,12 +299,18 @@
<Setter Property="pu:ShadowHelper.Opacity" Value="0.5" />
</Style>
<Style x:Key="StandardRadioButtonStyle" TargetType="RadioButton" BasedOn="{StaticResource {x:Type RadioButton}}">
<Style
x:Key="StandardRadioButtonStyle"
BasedOn="{StaticResource {x:Type RadioButton}}"
TargetType="RadioButton">
<Setter Property="pu:RadioButtonHelper.CheckedToggleBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:RadioButtonHelper.CheckedBorderBrush" Value="{DynamicResource DARKPrimary}" />
</Style>
<Style x:Key="SideMenuListBoxStyle" TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Style
x:Key="SideMenuListBoxStyle"
BasedOn="{StaticResource {x:Type ListBox}}"
TargetType="ListBox">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="pu:ListBoxHelper.ItemsHeight" Value="30" />
@ -267,7 +321,10 @@
<Setter Property="pu:ListBoxHelper.ItemsSelectedForeground" Value="{DynamicResource DARKPrimaryText}" />
</Style>
<Style x:Key="ToolBarMenuStyle" TargetType="Menu" BasedOn="{StaticResource {x:Type Menu}}">
<Style
x:Key="ToolBarMenuStyle"
BasedOn="{StaticResource {x:Type Menu}}"
TargetType="Menu">
<Setter Property="Height" Value="55" />
<Setter Property="FontSize" Value="24" />
<Setter Property="VerticalContentAlignment" Value="Center" />

View File

@ -1,4 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:pucore="clr-namespace:Panuon.WPF;assembly=Panuon.WPF">
@ -8,205 +9,131 @@
</ResourceDictionary.MergedDictionaries>
<Style x:Key="BaseWindowXStyle"
TargetType="pu:WindowX">
<Setter Property="pu:WindowXCaption.Background"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:WindowXCaption.Foreground"
Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:WindowXCaption.Buttons"
Value="Close" />
<Style x:Key="BaseWindowXStyle" TargetType="pu:WindowX">
<Setter Property="pu:WindowXCaption.Background" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:WindowXCaption.Foreground" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:WindowXCaption.Buttons" Value="Close" />
<Setter Property="pu:WindowXCaption.CloseButtonStyle">
<Setter.Value>
<Style TargetType="Button"
BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}">
<Setter Property="pu:ButtonHelper.HoverBackground"
Value="{x:Null}" />
<Style BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}" TargetType="Button">
<Setter Property="pu:ButtonHelper.HoverBackground" Value="{x:Null}" />
</Style>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StandardComboBoxStyle"
TargetType="{x:Type ComboBox}"
BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="FontSize"
Value="14" />
<Setter Property="Height"
Value="30" />
<Setter Property="Background"
Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="BorderThickness"
Value="1.5" />
<Setter Property="BorderBrush"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="Padding"
Value="7,0,15,0" />
<Setter Property="pu:ComboBoxHelper.CornerRadius"
Value="5" />
<Setter Property="pu:ComboBoxHelper.WatermarkForeground"
Value="#DCDCDC" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedBackground"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedForeground"
Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:ComboBoxHelper.ItemsHoverBackground"
Value="{DynamicResource DARKPrimaryTrans4}" />
<Setter Property="pu:ComboBoxHelper.ItemsPadding"
Value="22,0" />
<Setter Property="pu:DropDownHelper.BorderThickness"
Value="1" />
<Setter Property="pu:DropDownHelper.Background"
Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:DropDownHelper.ShadowColor"
Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:DropDownHelper.CornerRadius"
Value="5" />
<Setter Property="pu:DropDownHelper.MinHeight"
Value="100" />
<Setter Property="pu:DropDownHelper.ClipDockSideShadow"
Value="False" />
<Setter Property="pu:DropDownHelper.BorderBrush"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ShadowHelper.BlurRadius"
Value="15" />
<Setter Property="pu:ShadowHelper.Opacity"
Value="0.5" />
<Style
x:Key="StandardComboBoxStyle"
BasedOn="{StaticResource {x:Type ComboBox}}"
TargetType="{x:Type ComboBox}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="BorderThickness" Value="1.5" />
<Setter Property="BorderBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="Padding" Value="7,0,15,0" />
<Setter Property="pu:ComboBoxHelper.CornerRadius" Value="5" />
<Setter Property="pu:ComboBoxHelper.WatermarkForeground" Value="#DCDCDC" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedBackground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ComboBoxHelper.ItemsSelectedForeground" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:ComboBoxHelper.ItemsHoverBackground" Value="{DynamicResource DARKPrimaryTrans4}" />
<Setter Property="pu:ComboBoxHelper.ItemsPadding" Value="22,0" />
<Setter Property="pu:DropDownHelper.BorderThickness" Value="1" />
<Setter Property="pu:DropDownHelper.Background" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:DropDownHelper.ShadowColor" Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:DropDownHelper.CornerRadius" Value="5" />
<Setter Property="pu:DropDownHelper.MinHeight" Value="100" />
<Setter Property="pu:DropDownHelper.ClipDockSideShadow" Value="False" />
<Setter Property="pu:DropDownHelper.BorderBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ShadowHelper.BlurRadius" Value="15" />
<Setter Property="pu:ShadowHelper.Opacity" Value="0.5" />
<Setter Property="pu:ComboBoxHelper.ToggleArrowTransformControlStyle">
<Setter.Value>
<Style TargetType="pu:TransformControl"
BasedOn="{StaticResource {x:Static pu:ComboBoxHelper.ToggleArrowTransformControlStyleKey}}">
<Setter Property="Foreground"
Value="{DynamicResource PrimaryText}" />
<Setter Property="FontSize"
Value="10" />
<Setter Property="Content"
Value="&#xe91f;" />
<Style BasedOn="{StaticResource {x:Static pu:ComboBoxHelper.ToggleArrowTransformControlStyleKey}}" TargetType="pu:TransformControl">
<Setter Property="Foreground" Value="{DynamicResource PrimaryText}" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Content" Value="&#xe91f;" />
</Style>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StandardSliderStyle"
TargetType="Slider"
BasedOn="{StaticResource {x:Type Slider}}">
<Setter Property="Background"
Value="{DynamicResource DARKPrimaryTrans4}" />
<Setter Property="Foreground"
Value="{DynamicResource DARKPrimaryDark}" />
<Setter Property="pu:SliderHelper.ThumbShadowColor"
Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:SliderHelper.TrackThickness"
Value="2.5" />
<Setter Property="pu:SliderHelper.ThumbBorderBrush"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:SliderHelper.ThumbBorderThickness"
Value="2.5" />
<Setter Property="pu:SliderHelper.CoveredBackground"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ShadowHelper.ShadowDepth"
Value="3" />
<Setter Property="pu:ShadowHelper.Direction"
Value="270" />
<Setter Property="pu:ShadowHelper.Opacity"
Value="0.5" />
<Style
x:Key="StandardSliderStyle"
BasedOn="{StaticResource {x:Type Slider}}"
TargetType="Slider">
<Setter Property="Background" Value="{DynamicResource DARKPrimaryTrans4}" />
<Setter Property="Foreground" Value="{DynamicResource DARKPrimaryDark}" />
<Setter Property="pu:SliderHelper.ThumbShadowColor" Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:SliderHelper.TrackThickness" Value="2.5" />
<Setter Property="pu:SliderHelper.ThumbBorderBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:SliderHelper.ThumbBorderThickness" Value="2.5" />
<Setter Property="pu:SliderHelper.CoveredBackground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ShadowHelper.ShadowDepth" Value="3" />
<Setter Property="pu:ShadowHelper.Direction" Value="270" />
<Setter Property="pu:ShadowHelper.Opacity" Value="0.5" />
</Style>
<Style x:Key="StandardRadioButtonStyle"
TargetType="RadioButton"
BasedOn="{StaticResource {x:Type RadioButton}}">
<Setter Property="pu:RadioButtonHelper.CheckedToggleBrush"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:RadioButtonHelper.CheckedBorderBrush"
Value="{DynamicResource DARKPrimary}" />
<Style
x:Key="StandardRadioButtonStyle"
BasedOn="{StaticResource {x:Type RadioButton}}"
TargetType="RadioButton">
<Setter Property="pu:RadioButtonHelper.CheckedToggleBrush" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:RadioButtonHelper.CheckedBorderBrush" Value="{DynamicResource DARKPrimary}" />
</Style>
<Style x:Key="SideMenuListBoxStyle"
TargetType="ListBox"
BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="pu:ListBoxHelper.ItemsHeight"
Value="30" />
<Setter Property="pu:ListBoxHelper.ItemsPadding"
Value="15,0" />
<Setter Property="pu:ListBoxHelper.ItemsCornerRadius"
Value="5" />
<Setter Property="pu:ListBoxHelper.ItemsHoverBackground"
Value="{x:Null}" />
<Setter Property="pu:ListBoxHelper.ItemsSelectedBackground"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ListBoxHelper.ItemsSelectedForeground"
Value="{DynamicResource DARKPrimaryText}" />
<Style
x:Key="SideMenuListBoxStyle"
BasedOn="{StaticResource {x:Type ListBox}}"
TargetType="ListBox">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="pu:ListBoxHelper.ItemsHeight" Value="30" />
<Setter Property="pu:ListBoxHelper.ItemsPadding" Value="15,0" />
<Setter Property="pu:ListBoxHelper.ItemsCornerRadius" Value="5" />
<Setter Property="pu:ListBoxHelper.ItemsHoverBackground" Value="{x:Null}" />
<Setter Property="pu:ListBoxHelper.ItemsSelectedBackground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:ListBoxHelper.ItemsSelectedForeground" Value="{DynamicResource DARKPrimaryText}" />
</Style>
<Style x:Key="ToolBarMenuStyle"
TargetType="Menu"
BasedOn="{StaticResource {x:Type Menu}}">
<Setter Property="Height"
Value="55" />
<Setter Property="FontSize"
Value="24" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="pu:MenuHelper.TopLevelDropDownVerticalOffset"
Value="-25" />
<Setter Property="BorderBrush"
Value="{DynamicResource DARKPrimaryDarker}" />
<Setter Property="Background"
Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:MenuHelper.CornerRadius"
Value="5" />
<Setter Property="pu:MenuHelper.TopLevelDropDownPlacement"
Value="TopRight" />
<Setter Property="pu:MenuHelper.TopLevelItemsPadding"
Value="15,0" />
<Setter Property="pu:MenuHelper.TopLevelItemsBackground"
Value="Transparent" />
<Setter Property="pu:MenuHelper.TopLevelItemsHoverBackground"
Value="{DynamicResource SecondaryLighter}" />
<Setter Property="pu:MenuHelper.TopLevelItemsHoverForeground"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:MenuHelper.TopLevelItemsOpenedBackground"
Value="{DynamicResource SecondaryLighter}" />
<Setter Property="pu:MenuHelper.TopLevelItemsOpenedForeground"
Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:MenuHelper.SubmenuItemsPadding"
Value="15,0" />
<Setter Property="pu:MenuHelper.SubmenuItemsHeight"
Value="55" />
<Setter Property="pu:MenuHelper.SubmenuItemsIconWidth"
Value="NaN" />
<Setter Property="pu:MenuHelper.SubmenuItemsWidth"
Value="200" />
<Setter Property="pu:DropDownHelper.CornerRadius"
Value="5" />
<Setter Property="pu:MenuHelper.SubmenuItemsBackground"
Value="Transparent" />
<Setter Property="pu:MenuHelper.SubmenuItemsHoverBackground"
Value="{DynamicResource SecondaryLighter}" />
<Style
x:Key="ToolBarMenuStyle"
BasedOn="{StaticResource {x:Type Menu}}"
TargetType="Menu">
<Setter Property="Height" Value="55" />
<Setter Property="FontSize" Value="24" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="pu:MenuHelper.TopLevelDropDownVerticalOffset" Value="-25" />
<Setter Property="BorderBrush" Value="{DynamicResource DARKPrimaryDarker}" />
<Setter Property="Background" Value="{DynamicResource DARKPrimaryText}" />
<Setter Property="pu:MenuHelper.CornerRadius" Value="5" />
<Setter Property="pu:MenuHelper.TopLevelDropDownPlacement" Value="TopRight" />
<Setter Property="pu:MenuHelper.TopLevelItemsPadding" Value="15,0" />
<Setter Property="pu:MenuHelper.TopLevelItemsBackground" Value="Transparent" />
<Setter Property="pu:MenuHelper.TopLevelItemsHoverBackground" Value="{DynamicResource SecondaryLighter}" />
<Setter Property="pu:MenuHelper.TopLevelItemsHoverForeground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:MenuHelper.TopLevelItemsOpenedBackground" Value="{DynamicResource SecondaryLighter}" />
<Setter Property="pu:MenuHelper.TopLevelItemsOpenedForeground" Value="{DynamicResource DARKPrimary}" />
<Setter Property="pu:MenuHelper.SubmenuItemsPadding" Value="15,0" />
<Setter Property="pu:MenuHelper.SubmenuItemsHeight" Value="55" />
<Setter Property="pu:MenuHelper.SubmenuItemsIconWidth" Value="NaN" />
<Setter Property="pu:MenuHelper.SubmenuItemsWidth" Value="200" />
<Setter Property="pu:DropDownHelper.CornerRadius" Value="5" />
<Setter Property="pu:MenuHelper.SubmenuItemsBackground" Value="Transparent" />
<Setter Property="pu:MenuHelper.SubmenuItemsHoverBackground" Value="{DynamicResource SecondaryLighter}" />
<!--<Setter Property="pu:MenuHelper.SubmenuItemsHoverForeground"
Value="{DynamicResource DARKPrimary}" />-->
<Setter Property="pu:MenuHelper.SubmenuItemsOpenedBackground"
Value="{DynamicResource SecondaryLighter}" />
<Setter Property="pu:MenuHelper.SubmenuItemsOpenedBackground" Value="{DynamicResource SecondaryLighter}" />
<!--<Setter Property="pu:MenuHelper.SubmenuItemsOpenedForeground"
Value="{DynamicResource DARKPrimary}" />-->
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorVisibility"
Value="Visible" />
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorBrush"
Value="#CCCECF" />
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorMargin"
Value="10,0" />
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorVisibility" Value="Visible" />
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorBrush" Value="#CCCECF" />
<Setter Property="pu:MenuHelper.SubmenuItemsSeparatorMargin" Value="10,0" />
<!--<Setter Property="pu:MenuHelper.ShadowColor"
Value="{DynamicResource ShadowColor}" />-->
<Setter Property="pu:DropDownHelper.ShadowColor"
Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:ShadowHelper.Opacity"
Value="0.7" />
<Setter Property="pu:ShadowHelper.BlurRadius"
Value="25" />
<Setter Property="pu:DropDownHelper.ShadowColor" Value="{DynamicResource ShadowColor}" />
<Setter Property="pu:ShadowHelper.Opacity" Value="0.7" />
<Setter Property="pu:ShadowHelper.BlurRadius" Value="25" />
</Style>
</ResourceDictionary>

View File

@ -1,4 +1,5 @@
<Application x:Class="VPet_Simulator.Windows.App"
<Application
x:Class="VPet_Simulator.Windows.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VPet_Simulator.Windows"
@ -17,7 +18,8 @@
</FontFamily>
</ResourceDictionary>
<ResourceDictionary>
<pu:GlobalSettings x:Key="globalSettings"
<pu:GlobalSettings
x:Key="globalSettings"
FontFamily="{StaticResource MainFont}"
FontSize="14"
IconFontFamily="/VPet-Simulator.Windows;component/Res/#remixicon"

View File

@ -1,16 +1,15 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:VPet.House.Converters">
xmlns:c="clr-namespace:HKW.WPF.Converters">
<c:MarginConverter x:Key="MarginConverter" />
<c:RatioMarginConverter x:Key="RatioMarginConverter" />
<c:MarginConverter x:Key="RatioMarginConverter" HaveRatio="True" />
<c:CalculatorConverter x:Key="CalculatorConverter" />
<c:StringFormatConverter x:Key="StringFormatConverter" />
<c:BrushToMediaColorConverter x:Key="BrushToMediaColorConverter" />
<c:MaxConverter x:Key="MaxConverter" />
<c:FalseToHiddenConverter x:Key="FalseToHiddenConverter" />
<c:BoolToVisibilityConverter x:Key="FalseToHiddenConverter" />
<c:EqualsConverter x:Key="EqualsConverter" />
<c:NotEqualsConverter x:Key="NotEqualsConverter" />
<c:NullToFalseConverter x:Key="NullToFalseConverter" />
<c:EqualsConverter x:Key="NotEqualsConverter" Inverter="True" />
<c:ValueToBoolConverter x:Key="NullToFalse" />
<c:BoolInverter x:Key="BoolInverter" />
</ResourceDictionary>

View File

@ -0,0 +1,52 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 全部为布尔值转换器
/// </summary>
public class AllIsBoolConverter : MultiValueToBoolConverter<AllIsBoolConverter>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty BoolOnNullProperty = DependencyProperty.Register(
nameof(BoolOnNull),
typeof(bool),
typeof(AllIsBoolConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 目标为空时的指定值
/// </summary>
[DefaultValue(false)]
public bool BoolOnNull
{
get => (bool)GetValue(BoolOnNullProperty);
set => SetValue(BoolOnNullProperty, value);
}
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public override object Convert(
object[] values,
Type targetType,
object parameter,
CultureInfo culture
)
{
var boolValue = TargetBoolValue;
var nullValue = BoolOnNull;
return values.All(o => Utils.GetBool(o, boolValue, nullValue));
}
}

View File

@ -0,0 +1,97 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 全部为布尔值转换器
/// </summary>
public class AllIsBoolToVisibilityConverter
: MultiValueToBoolConverter<AllIsBoolToVisibilityConverter>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty BoolOnNullProperty = DependencyProperty.Register(
nameof(BoolOnNull),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 目标为空时的指定值
/// </summary>
[DefaultValue(false)]
public bool BoolOnNull
{
get => (bool)GetValue(BoolOnNullProperty);
set => SetValue(BoolOnNullProperty, value);
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty VisibilityOnTrueProperty =
DependencyProperty.Register(
nameof(VisibilityOnTrue),
typeof(Visibility),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(Visibility.Visible)
);
/// <summary>
/// 目标为空时的指定值
/// </summary>
[DefaultValue(Visibility.Visible)]
public Visibility VisibilityOnTrue
{
get => (Visibility)GetValue(TargetBoolValueProperty);
set => SetValue(TargetBoolValueProperty, value);
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty VisibilityOnFalseProperty =
DependencyProperty.Register(
nameof(VisibilityOnFalse),
typeof(Visibility),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(Visibility.Hidden)
);
/// <summary>
/// 目标为空时的指定值
/// </summary>
[DefaultValue(Visibility.Hidden)]
public Visibility VisibilityOnFalse
{
get => (Visibility)GetValue(TargetBoolValueProperty);
set => SetValue(TargetBoolValueProperty, value);
}
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public override object Convert(
object[] values,
Type targetType,
object parameter,
CultureInfo culture
)
{
var boolValue = TargetBoolValue;
var nullValue = BoolOnNull;
return values.All(o => Utils.GetBool(o, boolValue, nullValue))
? VisibilityOnTrue
: VisibilityOnFalse;
}
}

View File

@ -1,19 +1,41 @@
using System.Globalization;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
public class BoolInverter : IValueConverter
public class BoolInverter : ValueConverterBase
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
/// <summary>
///
/// </summary>
public static readonly DependencyProperty NullValueProperty = DependencyProperty.Register(
nameof(NullValue),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 为空值时布尔值
/// </summary>
[DefaultValue(false)]
public bool NullValue
{
get => (bool)GetValue(NullValueProperty);
set => SetValue(NullValueProperty, value);
}
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (value is not bool b)
return false;
return NullValue;
return !b;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,63 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace HKW.WPF.Converters;
public class BoolToVisibilityConverter : BoolToValueConverterBase<BoolToVisibilityConverter>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty TrueVisibilityValueProperty =
DependencyProperty.Register(
nameof(TrueVisibilityValue),
typeof(Visibility),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(Visibility.Visible)
);
/// <summary>
/// 为真时的可见度
/// </summary>
[DefaultValue(Visibility.Visible)]
public Visibility TrueVisibilityValue
{
get => (Visibility)GetValue(TrueVisibilityValueProperty);
set => SetValue(TrueVisibilityValueProperty, value);
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty FalseVisibilityValueProperty =
DependencyProperty.Register(
nameof(FalseVisibilityValue),
typeof(Visibility),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(Visibility.Hidden)
);
/// <summary>
/// 为假时的可见度
/// </summary>
[DefaultValue(Visibility.Hidden)]
public Visibility FalseVisibilityValue
{
get => (Visibility)GetValue(FalseVisibilityValueProperty);
set => SetValue(FalseVisibilityValueProperty, value);
}
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
return Utils.GetBool(value, BoolValue, NullValue)
? TrueVisibilityValue
: FalseVisibilityValue;
}
}

View File

@ -1,22 +1,39 @@
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
public class BrushToMediaColorConverter : IValueConverter
/// <summary>
/// 画笔颜色至媒体颜色转换器
/// </summary>
public class BrushToMediaColorConverter : ValueConverterBase
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
/// <inheritdoc/>
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (value is not SolidColorBrush brush)
throw new ArgumentException("Not SolidColorBrush", nameof(value));
throw new ArgumentException(
$"Not type: {typeof(SolidColorBrush).FullName}",
nameof(value)
);
return brush.Color;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
/// <inheritdoc/>
public override object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (value is not Color color)
throw new ArgumentException("Not media color", nameof(value));
throw new ArgumentException($"Not type: {typeof(Color).FullName}", nameof(value));
return new SolidColorBrush(color);
}
}

View File

@ -1,8 +1,7 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
/// <summary>
/// 计算器转换器
@ -30,9 +29,15 @@ namespace VPet.House.Converters;
/// ]]></code></para>
/// </summary>
/// <exception cref="Exception">绑定的数量不正确</exception>
public class CalculatorConverter : IMultiValueConverter
public class CalculatorConverter : MultiValueConverterBase
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
/// <inheritdoc/>
public override object Convert(
object[] values,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (values.Any(i => i == DependencyProperty.UnsetValue))
return 0.0;
@ -72,6 +77,14 @@ public class CalculatorConverter : IMultiValueConverter
return result;
}
/// <summary>
/// 计算
/// </summary>
/// <param name="value1">值1</param>
/// <param name="operatorChar">符号</param>
/// <param name="value2">值2</param>
/// <returns>结果</returns>
/// <exception cref="NotImplementedException"></exception>
public static double Operation(double value1, char operatorChar, double value2)
{
return operatorChar switch
@ -84,14 +97,4 @@ public class CalculatorConverter : IMultiValueConverter
_ => throw new NotImplementedException(),
};
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,47 @@
using System.ComponentModel;
using System.Windows;
namespace HKW.WPF.Converters;
public abstract class BoolToValueConverterBase<T> : ValueConverterBase
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty BoolValueProperty = DependencyProperty.Register(
nameof(BoolValue),
typeof(bool),
typeof(T),
new PropertyMetadata(true)
);
/// <summary>
/// 目标布尔值
/// </summary>
[DefaultValue(true)]
public bool BoolValue
{
get => (bool)GetValue(BoolValueProperty);
set => SetValue(BoolValueProperty, value);
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty NullValueProperty = DependencyProperty.Register(
nameof(NullValue),
typeof(bool),
typeof(T),
new PropertyMetadata(false)
);
/// <summary>
/// 为空值时布尔值
/// </summary>
[DefaultValue(false)]
public bool NullValue
{
get => (bool)GetValue(NullValueProperty);
set => SetValue(NullValueProperty, value);
}
}

View File

@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 可反转值转换器
/// </summary>
public abstract class CanInverterMultiValueConverter<T> : MultiValueConverterBase
where T : CanInverterMultiValueConverter<T>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty InverterProperty = DependencyProperty.Register(
nameof(Inverter),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 反转
/// </summary>
[DefaultValue(false)]
public bool Inverter
{
get => (bool)GetValue(InverterProperty);
set => SetValue(InverterProperty, value);
}
}

View File

@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 可反转值转换器
/// </summary>
public abstract class CanInverterValueConverter<T> : ValueConverterBase
where T : CanInverterValueConverter<T>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty InverterProperty = DependencyProperty.Register(
nameof(Inverter),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 反转
/// </summary>
[DefaultValue(false)]
public bool Inverter
{
get => (bool)GetValue(InverterProperty);
set => SetValue(InverterProperty, value);
}
}

View File

@ -0,0 +1,15 @@
using System.Globalization;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 值转换器基础
/// </summary>
public abstract class ConverterBase : DependencyObject
{
/// <summary>
/// 未设置值
/// </summary>
public static readonly object UnsetValue = DependencyProperty.UnsetValue;
}

View File

@ -0,0 +1,32 @@
using System.ComponentModel;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 含有比率的转换器
/// </summary>
/// <typeparam name="T">转换器类型</typeparam>
public abstract class HaveRatioConverter<T> : MultiValueConverterBase
where T : HaveRatioConverter<T>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty HaveRatioProperty = DependencyProperty.Register(
nameof(HaveRatio),
typeof(bool),
typeof(T),
new PropertyMetadata(false)
);
/// <summary>
/// 含有比例
/// </summary>
[DefaultValue(false)]
public bool HaveRatio
{
get => (bool)GetValue(HaveRatioProperty);
set => SetValue(HaveRatioProperty, value);
}
}

View File

@ -0,0 +1,45 @@
using System.Globalization;
using System.Windows.Data;
namespace HKW.WPF.Converters;
/// <summary>
/// 多个值转换器
/// </summary>
public abstract class MultiValueConverterBase : ConverterBase, IMultiValueConverter
{
/// <summary>
/// 转换
/// </summary>
/// <param name="values">值</param>
/// <param name="targetType">目标类型</param>
/// <param name="parameter">参数</param>
/// <param name="culture">文化</param>
/// <returns>转换后的值</returns>
public abstract object Convert(
object[] values,
Type targetType,
object parameter,
CultureInfo culture
);
/// <summary>
/// 转换回调
/// </summary>
/// <param name="value">值</param>
/// <param name="targetType">目标类型</param>
/// <param name="parameter">参数</param>
/// <param name="culture">文化</param>
/// <returns>转换后的值</returns>
public virtual object[] ConvertBack(
object value,
Type[] targetType,
object parameter,
CultureInfo culture
)
{
throw new NotSupportedException(
"Converter '" + this.GetType().Name + "' does not support backward conversion."
);
}
}

View File

@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 转换至布尔转换器基础
/// </summary>
public abstract class MultiValueToBoolConverter<T> : MultiValueConverterBase
where T : MultiValueToBoolConverter<T>
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty TargetBoolValueProperty = DependencyProperty.Register(
nameof(TargetBoolValue),
typeof(bool),
typeof(T),
new PropertyMetadata(false)
);
/// <summary>
/// 指定值
/// </summary>
[DefaultValue(false)]
public bool TargetBoolValue
{
get => (bool)GetValue(TargetBoolValueProperty);
set => SetValue(TargetBoolValueProperty, value);
}
}

View File

@ -0,0 +1,45 @@
using System.Globalization;
using System.Windows.Data;
namespace HKW.WPF.Converters;
/// <summary>
/// 值转换器
/// </summary>
public abstract class ValueConverterBase : ConverterBase, IValueConverter
{
/// <summary>
/// 转换
/// </summary>
/// <param name="value">值</param>
/// <param name="targetType">目标类型</param>
/// <param name="parameter">参数</param>
/// <param name="culture">文化</param>
/// <returns>转换后的值</returns>
public abstract object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
);
/// <summary>
/// 转换回调
/// </summary>
/// <param name="value">值</param>
/// <param name="targetType">目标类型</param>
/// <param name="parameter">参数</param>
/// <param name="culture">文化</param>
/// <returns>转换后的值</returns>
public virtual object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
throw new NotSupportedException(
"Converter '" + GetType().Name + "' does not support backward conversion."
);
}
}

View File

@ -1,28 +1,37 @@
using System.Windows.Data;
using System.Globalization;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
public class EqualsConverter : IMultiValueConverter
/// <summary>
/// 相等转换器
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource RatioMarginConverter}">
/// <Binding Path="Value1" />
/// <Binding Path="Value2" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class EqualsConverter : CanInverterMultiValueConverter<EqualsConverter>
{
public object Convert(
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
CultureInfo culture
)
{
if (values.Length != 2)
throw new NotImplementedException("Values length must be 2");
return values[0].Equals(values[1]);
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
return values[0].Equals(values[1]) ^ Inverter;
}
}

View File

@ -1,20 +0,0 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace VPet.House.Converters;
public class FalseToCollapsedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool.TryParse(value.ToString(), out var result) && result)
? Visibility.Visible
: Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Visibility visibility && visibility == Visibility.Collapsed;
}
}

View File

@ -1,20 +0,0 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace VPet.House.Converters;
public class FalseToHiddenConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool.TryParse(value.ToString(), out var result) && result)
? Visibility.Visible
: Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Visibility visibility && visibility == Visibility.Hidden;
}
}

View File

@ -0,0 +1,62 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows;
namespace HKW.WPF.Converters;
/// <summary>
/// 是布尔值转换器
/// </summary>
public class IsBoolConverter : ValueConverterBase
{
/// <summary>
///
/// </summary>
public static readonly DependencyProperty BoolValueProperty = DependencyProperty.Register(
nameof(BoolValue),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(true)
);
/// <summary>
/// 目标布尔值
/// </summary>
[DefaultValue(true)]
public bool BoolValue
{
get => (bool)GetValue(BoolValueProperty);
set => SetValue(BoolValueProperty, value);
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty NullValueProperty = DependencyProperty.Register(
nameof(NullValue),
typeof(bool),
typeof(AllIsBoolToVisibilityConverter),
new PropertyMetadata(false)
);
/// <summary>
/// 为空值时布尔值
/// </summary>
[DefaultValue(false)]
public bool NullValue
{
get => (bool)GetValue(NullValueProperty);
set => SetValue(NullValueProperty, value);
}
/// <inheritdoc/>
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
return Utils.GetBool(value, BoolValue, NullValue);
}
}

View File

@ -1,7 +1,7 @@
using System.Windows;
using System.Windows.Data;
using System.Globalization;
using System.Windows;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
/// <summary>
/// 边距转换器
@ -15,20 +15,83 @@ namespace VPet.House.Converters;
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class MarginConverter : IMultiValueConverter
public class MarginConverter : HaveRatioConverter<MarginConverter>
{
public object Convert(
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
CultureInfo culture
)
{
if (values.Any(i => i == DependencyProperty.UnsetValue))
return new Thickness();
if (values.Length == 0)
{
return new Thickness();
}
else if (values.Length == 1)
if (HaveRatio)
{
if (values.Length == 1)
{
return new Thickness();
}
var ratio = System.Convert.ToDouble(values[0]);
if (values.Length == 2)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = default,
Right = default,
Bottom = default
};
}
else if (values.Length == 3)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = default,
Bottom = default
};
}
else if (values.Length == 4)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = default
};
}
else if (values.Length == 5)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = System.Convert.ToDouble(values[4]) * ratio
};
}
else
throw new NotImplementedException();
}
else
{
if (values.Length == 1)
{
return new Thickness()
{
@ -71,14 +134,5 @@ public class MarginConverter : IMultiValueConverter
else
throw new NotImplementedException();
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -1,10 +1,12 @@
using System.Windows.Data;
namespace VPet.House.Converters;
using System.Windows;
public class MaxConverter : IMultiValueConverter
namespace HKW.WPF.Converters;
public class MaxConverter : MultiValueConverterBase
{
public object Convert(
public override object Convert(
object[] values,
Type targetType,
object parameter,
@ -13,14 +15,4 @@ public class MaxConverter : IMultiValueConverter
{
return values.Max(i => (double)i);
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -1,22 +1,55 @@
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
public class MediaColorToBrushConverter : IValueConverter
/// <summary>
/// 媒体颜色至画笔颜色转换器
/// </summary>
public class MediaColorToBrushConverter : ValueConverterBase
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (value is not Color color)
throw new ArgumentException("Not media color", nameof(value));
throw new ArgumentException($"Not type: {typeof(Color).FullName}", nameof(value));
return new SolidColorBrush(color);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public override object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
if (value is not SolidColorBrush brush)
throw new ArgumentException("Not SolidColorBrush", nameof(value));
throw new ArgumentException(
$"Not type: {typeof(SolidColorBrush).FullName}",
nameof(value)
);
return brush.Color;
}
}

View File

@ -1,28 +0,0 @@
using System.Windows.Data;
namespace VPet.House.Converters;
public class NotEqualsConverter : IMultiValueConverter
{
public object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
)
{
if (values.Length != 2)
throw new NotImplementedException("Values length must be 2");
return !values[0].Equals(values[1]);
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -1,17 +0,0 @@
using System.Globalization;
using System.Windows.Data;
namespace VPet.House.Converters;
public class NullToFalseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is not null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -1,91 +0,0 @@
using System.Windows;
using System.Windows.Data;
namespace VPet.House.Converters;
/// <summary>
/// 边距转换器
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource RatioMarginConverter}">
/// <Binding Path="Left" />
/// <Binding Path="Top" />
/// <Binding Path="Right" />
/// <Binding Path="Bottom" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class RatioMarginConverter : IMultiValueConverter
{
public object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
)
{
if (values.Any(i => i == DependencyProperty.UnsetValue))
return new Thickness();
if (values.Length == 0)
{
return new Thickness();
}
else if (values.Length == 1)
{
return new Thickness();
}
var ratio = System.Convert.ToDouble(values[0]);
if (values.Length == 2)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = default,
Right = default,
Bottom = default
};
}
else if (values.Length == 3)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = default,
Bottom = default
};
}
else if (values.Length == 4)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = default
};
}
else if (values.Length == 5)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = System.Convert.ToDouble(values[4]) * ratio
};
}
else
throw new NotImplementedException();
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -1,9 +1,9 @@
using System.Windows.Data;
using System.Globalization;
namespace VPet.House.Converters;
namespace HKW.WPF.Converters;
/// <summary>
/// 边距转换
/// 字符串格式化
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource MarginConverter}">
@ -18,13 +18,21 @@ namespace VPet.House.Converters;
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class StringFormatConverter : IMultiValueConverter
public class StringFormatConverter : MultiValueConverterBase
{
public object Convert(
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public override object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
CultureInfo culture
)
{
var formatStr = (string)parameter;
@ -38,14 +46,4 @@ public class StringFormatConverter : IMultiValueConverter
return string.Format(formatStr, values);
}
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,22 @@
using HKW.WPF.Converters;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HKW.WPF.Converters;
public class ValueToBoolConverter : ValueConverterBase
{
public override object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -76,4 +76,16 @@ public static class Utils
}
return bitmapImage;
}
public static bool GetBool(object value, bool boolValue, bool nullValue)
{
if (value is null)
return nullValue;
else if (value is bool b)
return b == boolValue;
else if (bool.TryParse(value.ToString(), out b))
return b == boolValue;
else
return false;
}
}

View File

@ -74,6 +74,26 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\AllIsBoolConverter.cs" />
<Compile Include="Converters\AllIsBoolToVisibilityConverter.cs" />
<Compile Include="Converters\ConverterBase\BoolToValueConverterBase.cs" />
<Compile Include="Converters\BrushToMediaColorConverter.cs" />
<Compile Include="Converters\CalculatorConverter.cs" />
<Compile Include="Converters\ConverterBase\CanInverterMultiValueConverter.cs" />
<Compile Include="Converters\ConverterBase\CanInverterValueConverter.cs" />
<Compile Include="Converters\ConverterBase\ConverterBase.cs" />
<Compile Include="Converters\ConverterBase\HaveRatioConverter.cs" />
<Compile Include="Converters\ConverterBase\MultiValueConverterBase.cs" />
<Compile Include="Converters\ConverterBase\MultiValueToBoolConverter.cs" />
<Compile Include="Converters\ConverterBase\ValueConverterBase.cs" />
<Compile Include="Converters\EqualsConverter.cs" />
<Compile Include="Converters\IsBoolConverter.cs" />
<Compile Include="Converters\MarginConverter.cs" />
<Compile Include="Converters\MediaColorToBrushConverter.cs" />
<Compile Include="Converters\StringFormatConverter.cs" />
<Compile Include="Converters\BoolToVisibilityConverter.cs" />
<Compile Include="Converters\MaxConverter.cs" />
<Compile Include="Converters\ValueToBoolConverter.cs" />
<Compile Include="Converters\BoolInverter.cs" />
<Compile Include="Models\GraphicsSettingModel.cs" />
<Compile Include="Models\InteractiveSettingModel.cs" />
@ -146,18 +166,6 @@
<Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\BrushToMediaColorConverter.cs" />
<Compile Include="Converters\CalculatorConverter.cs" />
<Compile Include="Converters\EqualsConverter.cs" />
<Compile Include="Converters\FalseToCollapsedConverter.cs" />
<Compile Include="Converters\FalseToHiddenConverter.cs" />
<Compile Include="Converters\MediaColorToBrushConverter.cs" />
<Compile Include="Converters\NotEqualsConverter.cs" />
<Compile Include="Converters\NullToFalseConverter.cs" />
<Compile Include="Converters\StringFormatConverter.cs" />
<Compile Include="Converters\RatioMarginConverter.cs" />
<Compile Include="Converters\MaxConverter.cs" />
<Compile Include="Converters\MarginConverter.cs" />
<Compile Include="SimpleObservable\ObservableClass\INotifyPropertyChangedX.cs" />
<Compile Include="SimpleObservable\ObservableClass\INotifyPropertyChangingX.cs" />
<Compile Include="SimpleObservable\ObservableClass\ObservableClass.cs" />