娴忚浠g爜

涓婚缁熶竴 - 鎸夐挳浜や簰鐘舵佹敼鐢―ynamicResource + 鍒囨崲鎸夐挳绐佸嚭鏄剧ず

纾 鏇 1 鍛ㄤ箣鍓
鐖惰妭鐐
褰撳墠鎻愪氦
9f1d2b1664

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

@@ -2,7 +2,7 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
     <!-- 鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺
-         YZWater3 宸ヤ笟椋庢牸鎺т欢鏍峰紡 (浣跨敤 DynamicResource 璺熼殢涓婚)
+         YZWater3 宸ヤ笟椋庢牸鎺т欢鏍峰紡
          鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺愨晲鈺 -->
 
     <!-- 鈹鈹鈹 鍏ㄥ眬鎸夐挳: 鎵嬪瀷鍏夋爣 鈹鈹鈹 -->
@@ -22,10 +22,10 @@
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     <Style Selector="Button.btn-success:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#009688"/>
+        <Setter Property="Background" Value="{DynamicResource SuccessHoverBrush}"/>
     </Style>
     <Style Selector="Button.btn-success:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#00796B"/>
+        <Setter Property="Background" Value="{DynamicResource SuccessPressedBrush}"/>
     </Style>
     <Style Selector="Button.btn-success:disabled">
         <Setter Property="Opacity" Value="0.4"/>
@@ -43,10 +43,10 @@
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     <Style Selector="Button.btn-danger:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#2D0000"/>
+        <Setter Property="Background" Value="{DynamicResource DangerHoverBrush}"/>
     </Style>
     <Style Selector="Button.btn-danger:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#3D0000"/>
+        <Setter Property="Background" Value="{DynamicResource DangerPressedBrush}"/>
     </Style>
     <Style Selector="Button.btn-danger:disabled">
         <Setter Property="Opacity" Value="0.4"/>
@@ -64,10 +64,10 @@
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     <Style Selector="Button.btn-info:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#1A2744"/>
+        <Setter Property="Background" Value="{DynamicResource InfoHoverBrush}"/>
     </Style>
     <Style Selector="Button.btn-info:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#1E3050"/>
+        <Setter Property="Background" Value="{DynamicResource InfoPressedBrush}"/>
     </Style>
     <Style Selector="Button.btn-info:disabled">
         <Setter Property="Opacity" Value="0.4"/>
@@ -85,13 +85,34 @@
         <Setter Property="MinHeight" Value="32"/>
     </Style>
     <Style Selector="Button.btn-warning:pointerover /template/ ContentPresenter">
-        <Setter Property="Background" Value="#2D2000"/>
+        <Setter Property="Background" Value="{DynamicResource WarningHoverBrush}"/>
     </Style>
     <Style Selector="Button.btn-warning:pressed /template/ ContentPresenter">
-        <Setter Property="Background" Value="#3D2A00"/>
+        <Setter Property="Background" Value="{DynamicResource WarningPressedBrush}"/>
     </Style>
     <Style Selector="Button.btn-warning:disabled">
         <Setter Property="Opacity" Value="0.4"/>
     </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>

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

@@ -41,6 +41,21 @@
     <!-- 鎶ヨ鑳屾櫙 -->
     <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="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
@@ -62,6 +77,17 @@
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <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>

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

@@ -41,6 +41,21 @@
     <!-- 鎶ヨ鑳屾櫙 -->
     <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="SurfaceBgBrush" Color="{StaticResource SurfaceBgColor}"/>
@@ -62,6 +77,17 @@
     <SolidColorBrush x:Key="TankSedimentBrush" Color="{StaticResource TankSedimentColor}"/>
     <SolidColorBrush x:Key="TankOutletBrush" Color="{StaticResource TankOutletColor}"/>
     <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>

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

@@ -74,17 +74,21 @@
                 </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 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>
             </Grid>
         </Border>