Browse Source

主题统一 - æŒ‰é’®äº¤äº’çŠ¶æ€æ”¹ç”¨DynamicResource + åˆ‡æ¢æŒ‰é’®çªå‡ºæ˜¾ç¤º

磊 曹 1 week ago
parent
commit
9f1d2b1664

+ 30 - 9
src/YZWater.Avalonia/Themes/IndustrialStyles.axaml

@@ -2,7 +2,7 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
 
     <!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
     <!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
-         YZWater3 å·¥ä¸šé£Žæ ¼æŽ§ä»¶æ ·å¼ (使用 DynamicResource è·Ÿéšä¸»é¢˜)
+         YZWater3 工业风格控件样å¼
          â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
          â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
 
 
     <!-- ─── 全局按钮: 手型光标 ─── -->
     <!-- ─── 全局按钮: 手型光标 ─── -->
@@ -22,10 +22,10 @@
         <Setter Property="MinHeight" Value="32"/>
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-success:pointerover /template/ ContentPresenter">
     <Style Selector="Button.btn-success:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#009688"/>
+        <Setter Property="Background" Value="{DynamicResource SuccessHoverBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-success:pressed /template/ ContentPresenter">
     <Style Selector="Button.btn-success:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#00796B"/>
+        <Setter Property="Background" Value="{DynamicResource SuccessPressedBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-success:disabled">
     <Style Selector="Button.btn-success:disabled">
         <Setter Property="Opacity" Value="0.4"/>
         <Setter Property="Opacity" Value="0.4"/>
@@ -43,10 +43,10 @@
         <Setter Property="MinHeight" Value="32"/>
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-danger:pointerover /template/ ContentPresenter">
     <Style Selector="Button.btn-danger:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#2D0000"/>
+        <Setter Property="Background" Value="{DynamicResource DangerHoverBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-danger:pressed /template/ ContentPresenter">
     <Style Selector="Button.btn-danger:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#3D0000"/>
+        <Setter Property="Background" Value="{DynamicResource DangerPressedBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-danger:disabled">
     <Style Selector="Button.btn-danger:disabled">
         <Setter Property="Opacity" Value="0.4"/>
         <Setter Property="Opacity" Value="0.4"/>
@@ -64,10 +64,10 @@
         <Setter Property="MinHeight" Value="32"/>
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-info:pointerover /template/ ContentPresenter">
     <Style Selector="Button.btn-info:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#1A2744"/>
+        <Setter Property="Background" Value="{DynamicResource InfoHoverBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-info:pressed /template/ ContentPresenter">
     <Style Selector="Button.btn-info:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#1E3050"/>
+        <Setter Property="Background" Value="{DynamicResource InfoPressedBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-info:disabled">
     <Style Selector="Button.btn-info:disabled">
         <Setter Property="Opacity" Value="0.4"/>
         <Setter Property="Opacity" Value="0.4"/>
@@ -85,13 +85,34 @@
         <Setter Property="MinHeight" Value="32"/>
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-warning:pointerover /template/ ContentPresenter">
     <Style Selector="Button.btn-warning:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#2D2000"/>
+        <Setter Property="Background" Value="{DynamicResource WarningHoverBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-warning:pressed /template/ ContentPresenter">
     <Style Selector="Button.btn-warning:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#3D2A00"/>
+        <Setter Property="Background" Value="{DynamicResource WarningPressedBrush}"/>
     </Style>
     </Style>
     <Style Selector="Button.btn-warning:disabled">
     <Style Selector="Button.btn-warning:disabled">
         <Setter Property="Opacity" Value="0.4"/>
         <Setter Property="Opacity" Value="0.4"/>
     </Style>
     </Style>
 
 
+    <!-- ─── åˆ‡æ¢æŒ‰é’® (主题/语言) ─── -->
+    <Style Selector="Button.btn-toggle">
+        <Setter Property="Background" Value="{DynamicResource ToggleBgBrush}"/>
+        <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
+        <Setter Property="BorderBrush" Value="{DynamicResource ToggleBorderBrush}"/>
+        <Setter Property="BorderThickness" Value="1"/>
+        <Setter Property="CornerRadius" Value="4"/>
+        <Setter Property="Padding" Value="10,6"/>
+        <Setter Property="MinHeight" Value="32"/>
+        <Setter Property="FontFamily" Value="{DynamicResource MonoFont}"/>
+        <Setter Property="FontSize" Value="11"/>
+        <Setter Property="FontWeight" Value="Bold"/>
+    </Style>
+    <Style Selector="Button.btn-toggle:pointerover /template/ ContentPresenter">
+        <Setter Property="Background" Value="{DynamicResource SuccessBrush}"/>
+        <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
+    </Style>
+    <Style Selector="Button.btn-toggle:pressed /template/ ContentPresenter">
+        <Setter Property="Background" Value="{DynamicResource SuccessPressedBrush}"/>
+    </Style>
+
 </Styles>
 </Styles>

+ 26 - 0
src/YZWater.Avalonia/Themes/IndustrialTheme.axaml

@@ -41,6 +41,21 @@
     <!-- 报警背景 -->
     <!-- 报警背景 -->
     <Color x:Key="AlarmBgColor">#1C0000</Color>
     <Color x:Key="AlarmBgColor">#1C0000</Color>
 
 
+    <!-- 按钮交互状æ€è‰² -->
+    <Color x:Key="SuccessHoverColor">#009688</Color>
+    <Color x:Key="SuccessPressedColor">#00796B</Color>
+    <Color x:Key="DangerHoverColor">#2D0000</Color>
+    <Color x:Key="DangerPressedColor">#3D0000</Color>
+    <Color x:Key="InfoHoverColor">#1A2744</Color>
+    <Color x:Key="InfoPressedColor">#1E3050</Color>
+    <Color x:Key="WarningHoverColor">#2D2000</Color>
+    <Color x:Key="WarningPressedColor">#3D2A00</Color>
+
+    <!-- åˆ‡æ¢æŒ‰é’®ä¸“用色 -->
+    <Color x:Key="ToggleBgColor">#1C2333</Color>
+    <Color x:Key="ToggleBorderColor">#37474F</Color>
+    <Color x:Key="ToggleActiveBgColor">#00897B</Color>
+
     <!-- 画刷 -->
     <!-- 画刷 -->
     <SolidColorBrush x:Key="AppBgBrush" Color="{StaticResource AppBgColor}"/>
     <SolidColorBrush x:Key="AppBgBrush" Color="{StaticResource AppBgColor}"/>
     <SolidColorBrush x:Key="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
     <SolidColorBrush x:Key="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
@@ -62,6 +77,17 @@
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <SolidColorBrush x:Key="AlarmBgBrush" Color="{StaticResource AlarmBgColor}"/>
     <SolidColorBrush x:Key="AlarmBgBrush" Color="{StaticResource AlarmBgColor}"/>
+    <SolidColorBrush x:Key="SuccessHoverBrush" Color="{StaticResource SuccessHoverColor}"/>
+    <SolidColorBrush x:Key="SuccessPressedBrush" Color="{StaticResource SuccessPressedColor}"/>
+    <SolidColorBrush x:Key="DangerHoverBrush" Color="{StaticResource DangerHoverColor}"/>
+    <SolidColorBrush x:Key="DangerPressedBrush" Color="{StaticResource DangerPressedColor}"/>
+    <SolidColorBrush x:Key="InfoHoverBrush" Color="{StaticResource InfoHoverColor}"/>
+    <SolidColorBrush x:Key="InfoPressedBrush" Color="{StaticResource InfoPressedColor}"/>
+    <SolidColorBrush x:Key="WarningHoverBrush" Color="{StaticResource WarningHoverColor}"/>
+    <SolidColorBrush x:Key="WarningPressedBrush" Color="{StaticResource WarningPressedColor}"/>
+    <SolidColorBrush x:Key="ToggleBgBrush" Color="{StaticResource ToggleBgColor}"/>
+    <SolidColorBrush x:Key="ToggleBorderBrush" Color="{StaticResource ToggleBorderColor}"/>
+    <SolidColorBrush x:Key="ToggleActiveBgBrush" Color="{StaticResource ToggleActiveBgColor}"/>
 
 
     <!-- 字体 -->
     <!-- 字体 -->
     <FontFamily x:Key="MonoFont">Consolas, Courier New, monospace</FontFamily>
     <FontFamily x:Key="MonoFont">Consolas, Courier New, monospace</FontFamily>

+ 26 - 0
src/YZWater.Avalonia/Themes/IndustrialThemeLight.axaml

@@ -41,6 +41,21 @@
     <!-- 报警背景 -->
     <!-- 报警背景 -->
     <Color x:Key="AlarmBgColor">#FEF2F2</Color>
     <Color x:Key="AlarmBgColor">#FEF2F2</Color>
 
 
+    <!-- 按钮交互状æ€è‰² -->
+    <Color x:Key="SuccessHoverColor">#009688</Color>
+    <Color x:Key="SuccessPressedColor">#00796B</Color>
+    <Color x:Key="DangerHoverColor">#FEE2E2</Color>
+    <Color x:Key="DangerPressedColor">#FECACA</Color>
+    <Color x:Key="InfoHoverColor">#DBEAFE</Color>
+    <Color x:Key="InfoPressedColor">#BFDBFE</Color>
+    <Color x:Key="WarningHoverColor">#FEF3C7</Color>
+    <Color x:Key="WarningPressedColor">#FDE68A</Color>
+
+    <!-- åˆ‡æ¢æŒ‰é’®ä¸“用色 -->
+    <Color x:Key="ToggleBgColor">#F0F2F5</Color>
+    <Color x:Key="ToggleBorderColor">#D0D5DD</Color>
+    <Color x:Key="ToggleActiveBgColor">#00897B</Color>
+
     <!-- 画刷 -->
     <!-- 画刷 -->
     <SolidColorBrush x:Key="AppBgBrush" Color="{StaticResource AppBgColor}"/>
     <SolidColorBrush x:Key="AppBgBrush" Color="{StaticResource AppBgColor}"/>
     <SolidColorBrush x:Key="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
     <SolidColorBrush x:Key="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
@@ -62,6 +77,17 @@
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <SolidColorBrush x:Key="AlarmBgBrush" Color="{StaticResource AlarmBgColor}"/>
     <SolidColorBrush x:Key="AlarmBgBrush" Color="{StaticResource AlarmBgColor}"/>
+    <SolidColorBrush x:Key="SuccessHoverBrush" Color="{StaticResource SuccessHoverColor}"/>
+    <SolidColorBrush x:Key="SuccessPressedBrush" Color="{StaticResource SuccessPressedColor}"/>
+    <SolidColorBrush x:Key="DangerHoverBrush" Color="{StaticResource DangerHoverColor}"/>
+    <SolidColorBrush x:Key="DangerPressedBrush" Color="{StaticResource DangerPressedColor}"/>
+    <SolidColorBrush x:Key="InfoHoverBrush" Color="{StaticResource InfoHoverColor}"/>
+    <SolidColorBrush x:Key="InfoPressedBrush" Color="{StaticResource InfoPressedColor}"/>
+    <SolidColorBrush x:Key="WarningHoverBrush" Color="{StaticResource WarningHoverColor}"/>
+    <SolidColorBrush x:Key="WarningPressedBrush" Color="{StaticResource WarningPressedColor}"/>
+    <SolidColorBrush x:Key="ToggleBgBrush" Color="{StaticResource ToggleBgColor}"/>
+    <SolidColorBrush x:Key="ToggleBorderBrush" Color="{StaticResource ToggleBorderColor}"/>
+    <SolidColorBrush x:Key="ToggleActiveBgBrush" Color="{StaticResource ToggleActiveBgColor}"/>
 
 
     <!-- 字体 -->
     <!-- 字体 -->
     <FontFamily x:Key="MonoFont">Consolas, Courier New, monospace</FontFamily>
     <FontFamily x:Key="MonoFont">Consolas, Courier New, monospace</FontFamily>

+ 12 - 8
src/YZWater.Avalonia/Views/MainWindow.axaml

@@ -74,17 +74,21 @@
                 </StackPanel>
                 </StackPanel>
 
 
                 <!-- ä¸»é¢˜åˆ‡æ¢ -->
                 <!-- ä¸»é¢˜åˆ‡æ¢ -->
-                <Button Grid.Column="1" Command="{Binding ToggleThemeCommand}" Padding="10,6"
-                        BorderThickness="0" Background="Transparent" Margin="8,0">
-                    <TextBlock Text="{Binding ThemeIcon}" FontSize="14"/>
+                <Button Grid.Column="1" Command="{Binding ToggleThemeCommand}" Classes="btn-toggle" Margin="8,0">
+                    <StackPanel Orientation="Horizontal" Spacing="6">
+                        <TextBlock Text="{Binding ThemeIcon}" FontSize="14" VerticalAlignment="Center"/>
+                        <TextBlock Text="THEME" FontSize="10" VerticalAlignment="Center"
+                                   Foreground="{DynamicResource TextSecondaryBrush}"/>
+                    </StackPanel>
                 </Button>
                 </Button>
 
 
                 <!-- è¯­è¨€åˆ‡æ¢ -->
                 <!-- è¯­è¨€åˆ‡æ¢ -->
-                <Button Grid.Column="2" Command="{Binding ToggleLanguageCommand}" Padding="10,6"
-                        BorderThickness="1" Background="Transparent" BorderBrush="{DynamicResource BorderBrush}"
-                        CornerRadius="4" Margin="0,0,8,0">
-                    <TextBlock Text="{Binding LangIcon}" FontSize="11" FontWeight="Bold"
-                               Foreground="{DynamicResource TextSecondaryBrush}"/>
+                <Button Grid.Column="2" Command="{Binding ToggleLanguageCommand}" Classes="btn-toggle" Margin="0,0,8,0">
+                    <StackPanel Orientation="Horizontal" Spacing="6">
+                        <TextBlock Text="{Binding LangIcon}" FontSize="12" FontWeight="Bold" VerticalAlignment="Center"/>
+                        <TextBlock Text="LANG" FontSize="10" VerticalAlignment="Center"
+                                   Foreground="{DynamicResource TextSecondaryBrush}"/>
+                    </StackPanel>
                 </Button>
                 </Button>
             </Grid>
             </Grid>
         </Border>
         </Border>