From 006c98e5650b530e5220f279c1e803fefe69d40d Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 25 十一月 2025 15:47:33 +0800
Subject: [PATCH] 优化一些东西;
---
WPFProject/Controls/MainTabControl.xaml | 183 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 148 insertions(+), 35 deletions(-)
diff --git a/WPFProject/Controls/MainTabControl.xaml b/WPFProject/Controls/MainTabControl.xaml
index 2949177..f28f6ee 100644
--- a/WPFProject/Controls/MainTabControl.xaml
+++ b/WPFProject/Controls/MainTabControl.xaml
@@ -5,6 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFProject.Controls"
mc:Ignorable="d"
+ Loaded="UserControl_Loaded"
+ Foreground="#51555f"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
@@ -13,7 +15,8 @@
</ResourceDictionary.MergedDictionaries>
<Style TargetType="ListBox" x:Key="ListBoxItemStyle1">
- <Setter Property="Background" Value="{StaticResource PrimaryColor}"/>
+ <Setter Property="Background" Value="Transparent"/>
+ <Setter Property="Padding" Value="-1"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
@@ -23,31 +26,28 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
- <Border x:Name="border" Background="{StaticResource PrimaryColor}"
- Padding="10" Margin="0" BorderThickness="0,0,1,1"
- BorderBrush="Gray">
- <!-- 鍐呭鍛堢幇鍣� -->
- <StackPanel>
- <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
- ContentStringFormat="{TemplateBinding ContentStringFormat}"
- ContentTemplate="{TemplateBinding ContentTemplate}" />
- </StackPanel>
+ <Border x:Name="border" Padding="10,5" BorderBrush="{StaticResource PrimaryColor}"
+ Cursor="Hand"
+ BorderThickness="1,0,0,0"
+ >
+ <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
+ContentStringFormat="{TemplateBinding ContentStringFormat}"
+ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="border" Property="Background"
- Value="{StaticResource WorkspaceBackground}"/>
- <Setter Property="Foreground" Value="{StaticResource PrimaryColor}"/>
- <Setter TargetName="border" Property="BorderThickness" Value="0,0,0,0"/>
+ Value="#7093d3"/>
+ <Setter Property="Foreground" Value="#ffff95"/>
</Trigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=(ItemsControl.AlternationIndex)}" Value="0">
- <Setter TargetName="border" Property="BorderThickness" Value="1,0,1,0" />
+ <Setter TargetName="border" Property="BorderThickness" Value="0" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="border" Property="Background" Value="{StaticResource SecondPrimaryColor}" />
+ <Setter TargetName="border" Property="Background" Value="#7093d3" />
<Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
</Trigger>
</ControlTemplate.Triggers>
@@ -60,7 +60,7 @@
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
- <StackPanel HorizontalAlignment="Left" Orientation="Horizontal"/>
+ <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
@@ -68,15 +68,78 @@
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
- <Image Width="20" Height="20" Margin="5" Source="{Binding Icon}"/>
+ <!--<Image Width="20" Height="20" Margin="5" Source="{Binding Icon}"/>-->
+ <Label Width="20" Height="20" FontFamily="{StaticResource iconfont}"
+ Padding="0"
+ Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
+ VerticalAlignment="Center"
+ VerticalContentAlignment="Center"
+ FontSize="20" Content="{Binding IconFont}"/>
<Label x:Name="txt" BorderThickness="0"
Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
- FontWeight="Bold"
- FontSize="16"
+ FontWeight="Bold"
VerticalContentAlignment="Center"
HorizontalAlignment="Left"
Content="{Binding Name}" ToolTip="{Binding Name}"/>
</StackPanel>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="ListBox" x:Key="ListBoxItemStyle2" BasedOn="{StaticResource ListBoxItemStyle1}">
+ <Setter Property="ItemContainerStyle">
+ <Setter.Value>
+ <Style TargetType="ListBoxItem">
+ <Setter Property="Margin" Value="0"/>
+ <Setter Property="Padding" Value="0"/>
+ <Setter Property="Foreground" Value="{StaticResource PrimaryColorContract}"/>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="ListBoxItem">
+ <Border x:Name="border" Padding="0,10" Margin="0" Cursor="Hand">
+ <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
+ContentStringFormat="{TemplateBinding ContentStringFormat}"
+ContentTemplate="{TemplateBinding ContentTemplate}" />
+ </Border>
+
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Foreground" Value="#ffff95"/>
+ </Trigger>
+
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter TargetName="border" Property="Background" Value="#7093d3" />
+ <Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="ItemTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
+ <Label x:Name="txt"
+ Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
+ FontWeight="Bold"
+ VerticalContentAlignment="Center"
+ HorizontalContentAlignment="Center"
+ Padding="10,0"
+ VerticalAlignment="Center"
+ BorderThickness="1,0,0,0" BorderBrush="Wheat"
+ Content="{Binding Name}" ToolTip="{Binding Name}"/>
+ </StackPanel>
+
+ <DataTemplate.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem},AncestorLevel=1},
+ Path=(ItemsControl.AlternationIndex)}" Value="0">
+ <Setter TargetName="txt" Property="BorderBrush" Value="Transparent"/>
+ </DataTrigger>
+ </DataTemplate.Triggers>
</DataTemplate>
</Setter.Value>
</Setter>
@@ -91,28 +154,78 @@
<RowDefinition/>
</Grid.RowDefinitions>
- <ListBox Grid.Row="0" x:Name="Menu" Margin="0" Padding="-1"
- Style="{StaticResource ListBoxItemStyle1}"
- BorderBrush="Gray"
- BorderThickness="0,1,0,1"
- Visibility="{Binding MenuVisibility}"
- SelectionChanged="Menu_SelectionChanged"
- SelectedItem="{Binding SelectedMenu}"
- AlternationCount="{Binding MenuItemsCount}" ItemsSource="{Binding MenuItems}">
+ <Border Grid.Row="0" BorderThickness="0,1,0,0" BorderBrush="#93b7ea"
+ Visibility="{Binding MenuVisibility}">
+ <DockPanel Background="Transparent">
+ <Border DockPanel.Dock="Left" BorderThickness="1,1,0,1" Background="Transparent" BorderBrush="{StaticResource PrimaryColor}" Width="50"></Border>
+ <ListBox DockPanel.Dock="Left" Grid.Row="0" x:Name="Menu"
+ Style="{StaticResource ListBoxItemStyle1}" FontSize="16"
+ BorderBrush="{StaticResource PrimaryColor}"
+ BorderThickness="1"
+ SelectionChanged="Menu_SelectionChanged"
+ SelectedItem="{Binding SelectedMenu}"
+ AlternationCount="{Binding MenuItems.Count}" ItemsSource="{Binding MenuItems}">
- </ListBox>
+ </ListBox>
+ <Border DockPanel.Dock="Left" BorderThickness="0,1,1,1" BorderBrush="{StaticResource PrimaryColor}"></Border>
+ </DockPanel>
+ </Border>
- <ListBox Grid.Row="1" x:Name="SubMenu" Margin="0" Padding="-1"
- Style="{StaticResource ListBoxItemStyle1}"
+
+ <Border Grid.Row="1" BorderThickness="0,1" BorderBrush="#93b7ea"
+ Visibility="{Binding MenuVisibility}">
+ <DockPanel Background="Transparent">
+ <Border Margin="1,1,0,1" DockPanel.Dock="Left" Background="Transparent" Width="50"></Border>
+ <ListBox Grid.Row="1" x:Name="SubMenu" Margin="0" FontSize="14"
+ Style="{StaticResource ListBoxItemStyle2}"
BorderBrush="Gray"
Visibility="{Binding MenuVisibility}"
- SelectedItem="{Binding SelectedSubMenu}" AlternationCount="{Binding SubMenuItemsCount}"
+ SelectedItem="{Binding SelectedSubMenu}" AlternationCount="{Binding SubMenuItems.Count}"
SelectionChanged="SubMenu_SelectionChanged"
-BorderThickness="0" ItemsSource="{Binding SubMenuItems}">
- </ListBox>
+BorderThickness="0" ItemsSource="{Binding SubMenuItems}" >
+ </ListBox>
+ </DockPanel>
+ </Border>
- <Border x:Name="page" Grid.Row="2" BorderThickness="0" Margin="0" Padding="0">
-
+ <Border x:Name="page" Grid.Row="2" BorderThickness="0" Margin="0" Background="White" Padding="0">
+
+ </Border>
+
+ <Border Height="80" Grid.Row="2" Background="Red" Visibility="Collapsed" VerticalAlignment="Top" x:Name="alarmBorder">
+ <Border.Style>
+ <Style TargetType="Border">
+ <Style.Triggers>
+ <Trigger Property="Visibility" Value="Visible">
+ <Trigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <ColorAnimation Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
+ From="#ff2100"
+ To="#fe7975"
+ Duration="0:0:0.7"
+ AutoReverse="True"
+ RepeatBehavior="Forever"/>
+ </Storyboard>
+ </BeginStoryboard>
+ </Trigger.EnterActions>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </Border.Style>
+
+ <DockPanel>
+ <Button DockPanel.Dock="Right"
+ FontSize="25"
+ FontWeight="Bold"
+ Margin="0,10,10,0"
+ VerticalAlignment="Top"
+ Click="Button_Click_1"
+ FontFamily="{StaticResource iconfont}" Background="Transparent" Content=""/>
+
+ <Label Margin="10,0,0,0" FontSize="25" FontWeight="Bold"
+ VerticalAlignment="Center" Content="{Binding AlarmInfo}"/>
+
+ </DockPanel>
</Border>
</Grid>
</UserControl>
--
Gitblit v1.9.1