| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <base:WindowBase x:Class="YSAI.Tool.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:base="clr-namespace:YSAI.Window;assembly=YSAI.Window"
- xmlns:local="clr-namespace:YSAI.Tool"
- xmlns:hm="clr-namespace:YSAI.Controls.hamburgermenu;assembly=YSAI.Controls"
- xmlns:tc="clr-namespace:YSAI.Controls.tabcontrol;assembly=YSAI.Controls"
- Icon="YSAI_One.ico"
- FontFamily="{DynamicResource AllFontFamily}" WindowStartupLocation="CenterScreen" IsContentBackgroundPicture="True" ResizeMode="CanResize"
- Title="[ 远舢智能 ] 调试工具">
- <Window.DataContext>
- <local:MainWindowController />
- </Window.DataContext>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Border Grid.Column="0" Margin="0,0,0,0">
- <Border.Effect>
- <DropShadowEffect BlurRadius="10" ShadowDepth="5" Opacity="0.1" Direction="-10" />
- </Border.Effect>
- <hm:HamburgerMenu ToWidth="100" Background="{DynamicResource Follow.Style.Background}" MenuIconColor="{DynamicResource Follow.Style.ImageColor}" HorizontalAlignment="Left" x:Name="hmc">
- <hm:HamburgerMenu.Content>
- <hm:HamburgerMenuItem Icon="{DynamicResource AboutUs}" Text="关于" ToolTip="关于我们" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding AboutUsTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Can}" Text="CAN 工具" ToolTip="CanTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding CanTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource MqttClient}" Text="MQTT 客户端工具" ToolTip="MqttClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttClientTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource MqttService}" Text="MQTT 服务端工具" ToolTip="MqttServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttServiceTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource MqttWebSocketService}" Text="MQTT WS 服务端工具" ToolTip="MqttWebSocketServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttWebSocketServiceTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Can}" Text="OPCDA HTTP 工具" ToolTip="OpcDaHttpClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcDaHttpClientTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource OpcUaClient}" Text="OPCUA 客户端工具" ToolTip="OpcUaClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcUaClientTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource OpcUaService}" Text="OPCUA 服务端工具" ToolTip="OpcUaServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcUaServiceTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource SerialPort}" Text="串口工具" ToolTip="SerialPortTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SerialPortTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Client}" Text="TCP 客户端工具" ToolTip="SocketTcpClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketTcpClientTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Service}" Text="TCP 服务端工具" ToolTip="SocketTcpServerTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketTcpServerTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Udp}" Text="UDP 工具" ToolTip="SocketUdpTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketUdpTool}" />
- <hm:HamburgerMenuItem Icon="{DynamicResource Svg}" Text="Svg 工具" ToolTip="SvgTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SvgTool}" />
- </hm:HamburgerMenu.Content>
- </hm:HamburgerMenu>
- </Border>
- <Grid Grid.Column="1">
- <TabControl ItemsSource="{Binding TabControlItemsSource}" TabStripPlacement="Top" SelectedItem="{Binding TabControlSelectedItem}">
- <TabControl.Resources>
- <!-- 笔刷用于定义TabControl和TabItem的外观-->
- <!-- TabItems和TabControl的边框刷 -->
- <SolidColorBrush x:Key="TabBorderBrush" Color="LightGray"/>
- <!-- 未选中时的标签文本颜色-->
- <SolidColorBrush x:Key="TabGrayTextBrush" Color="#FF444444"/>
- <!-- 关闭按钮刷-->
- <SolidColorBrush x:Key="TabCloseButtonBrush" Color="#FFADADAD"/>
- <!-- TabItem刷 -->
- <SolidColorBrush x:Key="TabItemNormalBackground" Color="WhiteSmoke"/>
- <SolidColorBrush x:Key="TabItemHoverBackground" Color="LightGray"/>
- <SolidColorBrush x:Key="TabItemSelectedBackground" Color="LightGray"/>
-
- <!--关闭按钮的样式-->
- <Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}">
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="border" CornerRadius="2" Background="{TemplateBinding Background}" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Width="16" Height="16" SnapsToDevicePixels="True">
- <Grid Width="8" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center">
- <Path x:Name="path1" Stroke="{StaticResource TabCloseButtonBrush}" Data="M0,0 L8,8" StrokeThickness="2" />
- <Path x:Name="path2" Stroke="{StaticResource TabCloseButtonBrush}" Data="M8,0 L0,8" StrokeThickness="2" />
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="BorderBrush" Value="{StaticResource TabCloseButtonBrush}"/>
- <Setter Property="Background" Value="WhiteSmoke"/>
- <Setter Property="Stroke" TargetName="path1" Value="DarkRed"/>
- <Setter Property="Stroke" TargetName="path2" Value="DarkRed"/>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter Property="Background">
- <Setter.Value>
- <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
- <GradientStop Color="#FFADADAD" Offset="0"/>
- <GradientStop Color="White" Offset="0.5"/>
- <GradientStop Color="White" Offset="1"/>
- </LinearGradientBrush>
- </Setter.Value>
- </Setter>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!--选项的样式-->
- <Style TargetType="{x:Type TabItem}">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="HorizontalAlignment" Value="Stretch" />
- <Setter Property="VerticalAlignment" Value="Stretch" />
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- <Setter Property="VerticalContentAlignment" Value="Stretch" />
- <Setter Property="SnapsToDevicePixels" Value="False"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TabItem}">
- <Border x:Name="Border" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="5" VerticalAlignment="Center" HorizontalAlignment="Center">
- <Grid HorizontalAlignment="Stretch">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="Auto"/>
- </Grid.ColumnDefinitions>
- <Image Source="{DynamicResource Communication}" Height="20"/>
- <TextBlock x:Name="TextBlock" Margin="5,0,0,0" Grid.Column="1" Text="{Binding Title}" Foreground="{DynamicResource Font.Head.Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{DynamicResource AllFontSize}"/>
- <Button Command="{Binding CloseTab}" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,5,0" Style="{StaticResource CloseButtonStyle}" Visibility="Visible"/>
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <!--鼠标在上方-->
- <Trigger Property="IsMouseOver" Value="true">
- <Setter Property="Opacity" TargetName="Border" Value="0.8" />
- </Trigger>
- <!--被选中-->
- <Trigger Property="IsSelected" Value="true">
- <Setter Property="FontWeight" TargetName="TextBlock" Value="Bold"/>
- <Setter Property="TextDecorations" TargetName="TextBlock" Value="Underline"/>
- </Trigger>
- <!--被选中-->
- <Trigger Property="IsSelected" Value="False">
- <Setter Property="Background" TargetName="Border" Value="Transparent" />
- <Setter Property="FontWeight" TargetName="TextBlock" Value="Normal"/>
- <Setter Property="TextDecorations" TargetName="TextBlock" Value="None"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!--tab控件样式-->
- <Style TargetType="{x:Type TabControl}">
- <Setter Property="HorizontalContentAlignment" Value="Center" />
- <Setter Property="VerticalContentAlignment" Value="Center" />
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- </Style>
- </TabControl.Resources>
- <TabControl.ContentTemplate>
- <DataTemplate>
- <Border Background="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}"
- BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
- BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
- KeyboardNavigation.DirectionalNavigation="Contained"
- KeyboardNavigation.TabIndex="5"
- KeyboardNavigation.TabNavigation="Local">
- <ContentControl Content="{Binding UserControl}" />
- </Border>
- </DataTemplate>
- </TabControl.ContentTemplate>
- </TabControl>
- </Grid>
- </Grid>
- </base:WindowBase>
|