From e64d24005284e88daec445c7e79e6b93929d2463 Mon Sep 17 00:00:00 2001
From: chr <chrry550@163.com>
Date: 星期三, 28 二月 2024 15:35:32 +0800
Subject: [PATCH] 优化程序UI;

---
 WPFProject.csproj            |    3 +
 Controls/IconTabItem.cs      |  117 +++++++++++++++++++++++---------------
 MainWindow.xaml.cs           |    6 ++
 Resources/Icon/xinzeng_1.png |    0 
 Controls/MenuTabControl.xaml |   21 ++++---
 MainWindow.xaml              |    4 
 Resources/Font/iconfont.ttf  |    0 
 Controls/InnerWindow.xaml    |    2 
 Controls/MinInnerWindow.xaml |    2 
 9 files changed, 96 insertions(+), 59 deletions(-)

diff --git a/Controls/IconTabItem.cs b/Controls/IconTabItem.cs
index 4bddc27..fef59e2 100644
--- a/Controls/IconTabItem.cs
+++ b/Controls/IconTabItem.cs
@@ -1,46 +1,71 @@
-锘縰sing System.Windows;
-using System.Windows.Controls;
-
-namespace WPFProject.Controls
-{
-    public class IconTabItem : TabItem
-    {
-        public IconTabItem() : base()
-        {
-            Visibility = Visibility.Collapsed;
-        }
-
-        private string _icon;
-        public string Icon
-        {
-            get => _icon;
-            set => _icon = value;
-        }
-
-        private bool _isFont;
-        public bool IsFont
-        {
-            get => _isFont;
-            set => _isFont = value;
-        }
-
-        private Window _Body;
-        public Window Body
-        {
-            get => _Body;
-            set => _Body = value;
-        }
-
-        // 鍗旽eader鐨勫瓧浣撳ぇ灏�
-        public double HeaderFontSize
-        {
-            get { return (double)GetValue(HeaderFontSizeProperty); }
-            set { SetValue(HeaderFontSizeProperty, value); }
-        }
-
-        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty HeaderFontSizeProperty =
-            DependencyProperty.Register("HeaderFontSize", typeof(double), typeof(IconTabItem), new PropertyMetadata(20.0));
-
-    }
-}
+锘縰sing System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace WPFProject.Controls
+{
+    public class IconTabItem : TabItem , INotifyPropertyChanged
+    {
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        protected virtual void RaisePropertyChanged(string name)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+        }
+
+        protected void RaiseAndSetIfChanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
+        {
+            old = @new;
+            if (propertyName != null)
+            {
+                RaisePropertyChanged(propertyName);
+            }
+        }
+
+        public IconTabItem() : base()
+        {
+            Visibility = Visibility.Collapsed;
+        }
+
+        private bool _isFont;
+        public bool IsFont
+        {
+            get => _isFont;
+            set => _isFont = value;
+        }
+
+        private Window _Body;
+        public Window Body
+        {
+            get => _Body;
+            set => _Body = value;
+        }
+
+        private BitmapImage _icon;
+        public BitmapImage Icon
+        {
+            get { return (BitmapImage)GetValue(IconProperty); }
+            set { SetValue(IconProperty, value); }
+        }
+
+        public static readonly DependencyProperty IconProperty =
+            DependencyProperty.Register("Icon", typeof(BitmapImage), typeof(IconTabItem), new PropertyMetadata(
+                new BitmapImage(new System.Uri("pack://application:,,,/Resources/Icon/xinzeng_1.png"))));
+
+
+        // 鍗旽eader鐨勫瓧浣撳ぇ灏�
+        public double HeaderFontSize
+        {
+            get { return (double)GetValue(HeaderFontSizeProperty); }
+            set { SetValue(HeaderFontSizeProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty HeaderFontSizeProperty =
+            DependencyProperty.Register("HeaderFontSize", typeof(double), typeof(IconTabItem), new PropertyMetadata(10.0));
+
+    }
+}
diff --git a/Controls/InnerWindow.xaml b/Controls/InnerWindow.xaml
index 8ca1095..3e4e262 100644
--- a/Controls/InnerWindow.xaml
+++ b/Controls/InnerWindow.xaml
@@ -51,7 +51,7 @@
 
                         <StackPanel Grid.Column="1" Orientation="Horizontal">
                             <Button Style="{StaticResource ChildWindowButton}" Click="Min_Click">&#xe650;</Button>
-                            <Button Style="{StaticResource ChildWindowButton}" Click="Max_Click" >&#xe534;</Button>
+                            <Button Style="{StaticResource ChildWindowButton}" Click="Max_Click" >&#xe602;</Button>
                             <Button Style="{StaticResource ChildWindowCloseButton}" Click="CLose_Click">&#xe609;</Button>
                         </StackPanel>
                     </Grid>
diff --git a/Controls/MenuTabControl.xaml b/Controls/MenuTabControl.xaml
index 3d99a3a..4f26381 100644
--- a/Controls/MenuTabControl.xaml
+++ b/Controls/MenuTabControl.xaml
@@ -97,18 +97,22 @@
                 <Setter Property="Margin" Value="0"/>
                 <Setter Property="Background" Value="{StaticResource ButtonColor}"/>
                 <Setter Property="Foreground" Value="{StaticResource ButtonFont}"/>
+                <Setter Property="HeaderFontSize" Value="15"/>
                 <Setter Property="Template">
                     <Setter.Value>
-                        <ControlTemplate TargetType="{x:Type ctl:IconTabItem}">
+                        <ControlTemplate x:Name="ct" TargetType="{x:Type ctl:IconTabItem}">
                             <Border x:Name="templateRoot" BorderThickness="1,1,1,1" Padding="10" 
                                 BorderBrush="Gray" 
                                 Background="{TemplateBinding Background}">
-                                <Label x:Name="txt" Visibility="Visible" BorderThickness="0" 
-                                   VerticalContentAlignment="Center" 
-                                   HorizontalAlignment="Left" 
-                                   FontSize="{TemplateBinding HeaderFontSize}"
-                                   Content="{TemplateBinding Header}" ToolTip="{TemplateBinding Header}" 
-                                   Foreground="{TemplateBinding Foreground}" />
+                                <StackPanel HorizontalAlignment="Center">
+                                    <Image Width="30" Height="30" Source="{TemplateBinding Icon}"/>
+                                    <Label x:Name="txt" Visibility="Visible" BorderThickness="0" 
+                                       VerticalContentAlignment="Center" 
+                                       HorizontalAlignment="Left" 
+                                       FontSize="{TemplateBinding HeaderFontSize}"
+                                       Content="{TemplateBinding Header}" ToolTip="{TemplateBinding Header}" 
+                                       Foreground="{TemplateBinding Foreground}" />
+                                </StackPanel>
                             </Border>
                             <ControlTemplate.Triggers>
                                 <MultiDataTrigger>
@@ -134,8 +138,7 @@
             </Style>
         </ResourceDictionary>
     </UserControl.Resources>
-    
-    
+
     <Grid>
         <TabControl x:Name="tabLevel_1" 
                     Style="{StaticResource ControlStyle}" 
diff --git a/Controls/MinInnerWindow.xaml b/Controls/MinInnerWindow.xaml
index 1fdd3ac..666c587 100644
--- a/Controls/MinInnerWindow.xaml
+++ b/Controls/MinInnerWindow.xaml
@@ -18,7 +18,7 @@
 
     <StackPanel Background="{StaticResource ChildBorder}" Orientation="Horizontal">
         <Label BorderBrush="{StaticResource MainBorder}" Foreground="#FFF" BorderThickness="2,0,0,0" VerticalContentAlignment="Center" ToolTip="{Binding Title}" Content="{Binding Title}"/>
-        <Button Style="{StaticResource ChildWindowButton}" Click="Max_Click" >&#xe534;</Button>
+        <Button Style="{StaticResource ChildWindowButton}" Click="Max_Click" >&#xe602;</Button>
         <Button Style="{StaticResource ChildWindowCloseButton}" Click="CLose_Click">&#xe609;</Button>
     </StackPanel>
 </UserControl>
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 29b7af1..1db740a 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -38,9 +38,9 @@
             </Grid.ColumnDefinitions>
             <StackPanel Grid.Column="0"></StackPanel>
             <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
-                <Button Style="{StaticResource WindowButton}" Click="Button_Click_2">111</Button>
+                <Button Style="{StaticResource WindowButton}" x:Name="openCloseButton"  Click="Button_Click_2">&#xe60e;</Button>
                 <Button Style="{StaticResource WindowButton}" Click="Button_Click">&#xe650;</Button>
-                <Button Style="{StaticResource WindowButton}" Click="Button_Click">&#xe534;</Button>
+                <Button Style="{StaticResource WindowButton}" Click="Button_Click">&#xe602;</Button>
                 <Button Style="{StaticResource WindowCloseButton}" Click="Button_Click_1">&#xe609;</Button>
             </StackPanel>
         </Grid>
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 2f6aea2..d1cc03f 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Windows;
+using System.Windows.Media;
 using WPFProject.Events;
 
 namespace WPFProject
@@ -36,6 +37,11 @@
 
         private void Button_Click_2(object sender, RoutedEventArgs e)
         {
+            
+            double temp = openCloseButton.RenderTransform.Value.Determinant;
+            openCloseButton.RenderTransformOrigin = new Point(0.5, 0.5);
+            ScaleTransform verticalFlipTransform = new ScaleTransform(1, temp*-1);
+            openCloseButton.RenderTransform = verticalFlipTransform;
             mainControl.ChangeItemVisibility();
         }
     }
diff --git a/Resources/Font/iconfont.ttf b/Resources/Font/iconfont.ttf
index 5d4f8ec..9ee5c66 100644
--- a/Resources/Font/iconfont.ttf
+++ b/Resources/Font/iconfont.ttf
Binary files differ
diff --git a/Resources/Icon/xinzeng_1.png b/Resources/Icon/xinzeng_1.png
new file mode 100644
index 0000000..0b16aa2
--- /dev/null
+++ b/Resources/Icon/xinzeng_1.png
Binary files differ
diff --git a/WPFProject.csproj b/WPFProject.csproj
index e22f115..2cdc8ca 100644
--- a/WPFProject.csproj
+++ b/WPFProject.csproj
@@ -281,5 +281,8 @@
     <WCFMetadata Include="Connected Services\" />
   </ItemGroup>
   <ItemGroup />
+  <ItemGroup>
+    <Resource Include="Resources\Icon\xinzeng_1.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file

--
Gitblit v1.9.1