MainWindow.xaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <base:WindowBase x:Class="YSAI.Tool.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:base="clr-namespace:YSAI.Window;assembly=YSAI.Window"
  5. xmlns:local="clr-namespace:YSAI.Tool"
  6. xmlns:hm="clr-namespace:YSAI.Controls.hamburgermenu;assembly=YSAI.Controls"
  7. xmlns:tc="clr-namespace:YSAI.Controls.tabcontrol;assembly=YSAI.Controls"
  8. Icon="YSAI_One.ico"
  9. FontFamily="{DynamicResource AllFontFamily}" WindowStartupLocation="CenterScreen" IsContentBackgroundPicture="True" ResizeMode="CanResize"
  10. Title="[ 远舢智能 ] 调试工具">
  11. <Window.DataContext>
  12. <local:MainWindowController />
  13. </Window.DataContext>
  14. <Grid>
  15. <Grid.ColumnDefinitions>
  16. <ColumnDefinition Width="auto" />
  17. <ColumnDefinition Width="*" />
  18. </Grid.ColumnDefinitions>
  19. <Border Grid.Column="0" Margin="0,0,0,0">
  20. <Border.Effect>
  21. <DropShadowEffect BlurRadius="10" ShadowDepth="5" Opacity="0.1" Direction="-10" />
  22. </Border.Effect>
  23. <hm:HamburgerMenu ToWidth="100" Background="{DynamicResource Follow.Style.Background}" MenuIconColor="{DynamicResource Follow.Style.ImageColor}" HorizontalAlignment="Left" x:Name="hmc">
  24. <hm:HamburgerMenu.Content>
  25. <hm:HamburgerMenuItem Icon="{DynamicResource AboutUs}" Text="关于" ToolTip="关于我们" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding AboutUsTool}" />
  26. <hm:HamburgerMenuItem Icon="{DynamicResource Can}" Text="CAN 工具" ToolTip="CanTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding CanTool}" />
  27. <hm:HamburgerMenuItem Icon="{DynamicResource MqttClient}" Text="MQTT 客户端工具" ToolTip="MqttClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttClientTool}" />
  28. <hm:HamburgerMenuItem Icon="{DynamicResource MqttService}" Text="MQTT 服务端工具" ToolTip="MqttServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttServiceTool}" />
  29. <hm:HamburgerMenuItem Icon="{DynamicResource MqttWebSocketService}" Text="MQTT WS 服务端工具" ToolTip="MqttWebSocketServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding MqttWebSocketServiceTool}" />
  30. <hm:HamburgerMenuItem Icon="{DynamicResource Can}" Text="OPCDA HTTP 工具" ToolTip="OpcDaHttpClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcDaHttpClientTool}" />
  31. <hm:HamburgerMenuItem Icon="{DynamicResource OpcUaClient}" Text="OPCUA 客户端工具" ToolTip="OpcUaClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcUaClientTool}" />
  32. <hm:HamburgerMenuItem Icon="{DynamicResource OpcUaService}" Text="OPCUA 服务端工具" ToolTip="OpcUaServiceTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding OpcUaServiceTool}" />
  33. <hm:HamburgerMenuItem Icon="{DynamicResource SerialPort}" Text="串口工具" ToolTip="SerialPortTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SerialPortTool}" />
  34. <hm:HamburgerMenuItem Icon="{DynamicResource Client}" Text="TCP 客户端工具" ToolTip="SocketTcpClientTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketTcpClientTool}" />
  35. <hm:HamburgerMenuItem Icon="{DynamicResource Service}" Text="TCP 服务端工具" ToolTip="SocketTcpServerTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketTcpServerTool}" />
  36. <hm:HamburgerMenuItem Icon="{DynamicResource Udp}" Text="UDP 工具" ToolTip="SocketUdpTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SocketUdpTool}" />
  37. <hm:HamburgerMenuItem Icon="{DynamicResource Svg}" Text="Svg 工具" ToolTip="SvgTool" SelectionIndicatorColor="{DynamicResource Follow.Style.ImageColor}" Foreground="{DynamicResource Follow.Style.Foreground}" SelectionCommand="{Binding SvgTool}" />
  38. </hm:HamburgerMenu.Content>
  39. </hm:HamburgerMenu>
  40. </Border>
  41. <Grid Grid.Column="1">
  42. <TabControl ItemsSource="{Binding TabControlItemsSource}" TabStripPlacement="Top" SelectedItem="{Binding TabControlSelectedItem}">
  43. <TabControl.Resources>
  44. <!-- 笔刷用于定义TabControl和TabItem的外观-->
  45. <!-- TabItems和TabControl的边框刷 -->
  46. <SolidColorBrush x:Key="TabBorderBrush" Color="LightGray"/>
  47. <!-- 未选中时的标签文本颜色-->
  48. <SolidColorBrush x:Key="TabGrayTextBrush" Color="#FF444444"/>
  49. <!-- 关闭按钮刷-->
  50. <SolidColorBrush x:Key="TabCloseButtonBrush" Color="#FFADADAD"/>
  51. <!-- TabItem刷 -->
  52. <SolidColorBrush x:Key="TabItemNormalBackground" Color="WhiteSmoke"/>
  53. <SolidColorBrush x:Key="TabItemHoverBackground" Color="LightGray"/>
  54. <SolidColorBrush x:Key="TabItemSelectedBackground" Color="LightGray"/>
  55. <!--关闭按钮的样式-->
  56. <Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}">
  57. <Setter Property="BorderBrush" Value="Transparent"/>
  58. <Setter Property="Background" Value="Transparent"/>
  59. <Setter Property="Template">
  60. <Setter.Value>
  61. <ControlTemplate TargetType="{x:Type Button}">
  62. <Border x:Name="border" CornerRadius="2" Background="{TemplateBinding Background}" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Width="16" Height="16" SnapsToDevicePixels="True">
  63. <Grid Width="8" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center">
  64. <Path x:Name="path1" Stroke="{StaticResource TabCloseButtonBrush}" Data="M0,0 L8,8" StrokeThickness="2" />
  65. <Path x:Name="path2" Stroke="{StaticResource TabCloseButtonBrush}" Data="M8,0 L0,8" StrokeThickness="2" />
  66. </Grid>
  67. </Border>
  68. <ControlTemplate.Triggers>
  69. <Trigger Property="IsMouseOver" Value="True">
  70. <Setter Property="BorderBrush" Value="{StaticResource TabCloseButtonBrush}"/>
  71. <Setter Property="Background" Value="WhiteSmoke"/>
  72. <Setter Property="Stroke" TargetName="path1" Value="DarkRed"/>
  73. <Setter Property="Stroke" TargetName="path2" Value="DarkRed"/>
  74. </Trigger>
  75. <Trigger Property="IsPressed" Value="True">
  76. <Setter Property="Background">
  77. <Setter.Value>
  78. <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
  79. <GradientStop Color="#FFADADAD" Offset="0"/>
  80. <GradientStop Color="White" Offset="0.5"/>
  81. <GradientStop Color="White" Offset="1"/>
  82. </LinearGradientBrush>
  83. </Setter.Value>
  84. </Setter>
  85. </Trigger>
  86. </ControlTemplate.Triggers>
  87. </ControlTemplate>
  88. </Setter.Value>
  89. </Setter>
  90. </Style>
  91. <!--选项的样式-->
  92. <Style TargetType="{x:Type TabItem}">
  93. <Setter Property="Background" Value="Transparent"/>
  94. <Setter Property="BorderBrush" Value="Transparent"/>
  95. <Setter Property="HorizontalAlignment" Value="Stretch" />
  96. <Setter Property="VerticalAlignment" Value="Stretch" />
  97. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  98. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  99. <Setter Property="SnapsToDevicePixels" Value="False"/>
  100. <Setter Property="Template">
  101. <Setter.Value>
  102. <ControlTemplate TargetType="{x:Type TabItem}">
  103. <Border x:Name="Border" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="5" VerticalAlignment="Center" HorizontalAlignment="Center">
  104. <Grid HorizontalAlignment="Stretch">
  105. <Grid.ColumnDefinitions>
  106. <ColumnDefinition Width="Auto"/>
  107. <ColumnDefinition Width="*"/>
  108. <ColumnDefinition Width="Auto"/>
  109. </Grid.ColumnDefinitions>
  110. <Image Source="{DynamicResource Communication}" Height="20"/>
  111. <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}"/>
  112. <Button Command="{Binding CloseTab}" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,5,0" Style="{StaticResource CloseButtonStyle}" Visibility="Visible"/>
  113. </Grid>
  114. </Border>
  115. <ControlTemplate.Triggers>
  116. <!--鼠标在上方-->
  117. <Trigger Property="IsMouseOver" Value="true">
  118. <Setter Property="Opacity" TargetName="Border" Value="0.8" />
  119. </Trigger>
  120. <!--被选中-->
  121. <Trigger Property="IsSelected" Value="true">
  122. <Setter Property="FontWeight" TargetName="TextBlock" Value="Bold"/>
  123. <Setter Property="TextDecorations" TargetName="TextBlock" Value="Underline"/>
  124. </Trigger>
  125. <!--被选中-->
  126. <Trigger Property="IsSelected" Value="False">
  127. <Setter Property="Background" TargetName="Border" Value="Transparent" />
  128. <Setter Property="FontWeight" TargetName="TextBlock" Value="Normal"/>
  129. <Setter Property="TextDecorations" TargetName="TextBlock" Value="None"/>
  130. </Trigger>
  131. </ControlTemplate.Triggers>
  132. </ControlTemplate>
  133. </Setter.Value>
  134. </Setter>
  135. </Style>
  136. <!--tab控件样式-->
  137. <Style TargetType="{x:Type TabControl}">
  138. <Setter Property="HorizontalContentAlignment" Value="Center" />
  139. <Setter Property="VerticalContentAlignment" Value="Center" />
  140. <Setter Property="SnapsToDevicePixels" Value="True"/>
  141. <Setter Property="Background" Value="Transparent"/>
  142. <Setter Property="BorderBrush" Value="Transparent"/>
  143. </Style>
  144. </TabControl.Resources>
  145. <TabControl.ContentTemplate>
  146. <DataTemplate>
  147. <Border Background="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}"
  148. BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
  149. BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
  150. KeyboardNavigation.DirectionalNavigation="Contained"
  151. KeyboardNavigation.TabIndex="5"
  152. KeyboardNavigation.TabNavigation="Local">
  153. <ContentControl Content="{Binding UserControl}" />
  154. </Border>
  155. </DataTemplate>
  156. </TabControl.ContentTemplate>
  157. </TabControl>
  158. </Grid>
  159. </Grid>
  160. </base:WindowBase>