MainWindow.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <hc:Window x:Class="TeamAAS.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:hc="https://handyorg.github.io/handycontrol"
  5. xmlns:prism="http://prismlibrary.com/"
  6. xmlns:conv="clr-namespace:TeamAAS.Converters"
  7. xmlns:loc="clr-namespace:TeamAAS.Localization"
  8. xmlns:ip="clr-namespace:MahApps.Metro.IconPacks;assembly=MahApps.Metro.IconPacks.Material"
  9. xmlns:g="clr-namespace:TeamAAS;assembly=TeamAAS.Global"
  10. Height="800" Width="1280"
  11. MinHeight="600" MinWidth="960"
  12. WindowState="Maximized"
  13. ShowTitle="False"
  14. ResizeMode="CanResizeWithGrip"
  15. RenderOptions.BitmapScalingMode="HighQuality"
  16. RenderOptions.ClearTypeHint="Enabled"
  17. NonClientAreaBackground="{DynamicResource PrimaryBrush}"
  18. WindowStartupLocation="CenterScreen"
  19. Background="{DynamicResource RegionBrush}">
  20. <hc:Window.NonClientAreaContent>
  21. <Grid hc:WindowAttach.IsDragElement="True">
  22. <Grid.ColumnDefinitions>
  23. <ColumnDefinition/>
  24. <ColumnDefinition Width="Auto"/>
  25. </Grid.ColumnDefinitions>
  26. <TextBlock Grid.Column="0" Text="{DynamicResource CenterTitleText}" FontWeight="Bold"
  27. Foreground="{DynamicResource PrimaryTextBrush}"
  28. VerticalAlignment="Center" Margin="16,0,0,0"/>
  29. <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
  30. <Button x:Name="RegistryMonitorButton"
  31. ToolTip="调试:监控 ResultRegistry(Main / Debug)"
  32. Visibility="Collapsed"
  33. hc:WindowAttach.IsDragElement="False"
  34. Click="RegistryMonitor_Click"
  35. Cursor="Hand"
  36. Background="Transparent" BorderThickness="0"
  37. Foreground="{DynamicResource PrimaryTextBrush}">
  38. <ip:PackIconMaterial x:Name="RegistryMonitorIcon"
  39. Foreground="{DynamicResource PrimaryTextBrush}"
  40. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  41. </Button>
  42. <ToggleButton x:Name="SettingsToggle"
  43. ToolTip="{loc:Translate '主题设置'}"
  44. hc:WindowAttach.IsDragElement="False"
  45. Click="SettingsToggle_Click"
  46. Cursor="Hand"
  47. Background="Transparent" BorderThickness="0"
  48. Foreground="{DynamicResource PrimaryTextBrush}">
  49. <ip:PackIconMaterial Kind="Cog"
  50. Foreground="{DynamicResource PrimaryTextBrush}"
  51. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  52. </ToggleButton>
  53. <Popup x:Name="ThemePopup"
  54. StaysOpen="False"
  55. PlacementTarget="{Binding ElementName=SettingsToggle}"
  56. Placement="Bottom" HorizontalOffset="-120" VerticalOffset="6"
  57. PopupAnimation="Slide" AllowsTransparency="True"
  58. Closed="ThemePopup_Closed">
  59. <Border Background="{DynamicResource SecondaryRegionBrush}"
  60. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
  61. CornerRadius="6" Padding="14">
  62. <StackPanel Width="240">
  63. <TextBlock Text="{loc:Translate '主题'}" FontSize="12" FontWeight="Bold"
  64. Foreground="{DynamicResource PrimaryTextBrush}" Margin="0,0,0,8"/>
  65. <Button Command="{Binding ToggleThemeCommand}"
  66. Padding="14,6" Margin="0,0,0,12" Cursor="Hand"
  67. Background="{DynamicResource SecondaryRegionBrush}"
  68. Foreground="{DynamicResource PrimaryTextBrush}"
  69. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
  70. <StackPanel Orientation="Horizontal">
  71. <TextBlock Text="{Binding ThemeIcon}" Margin="0,0,6,0"/>
  72. <TextBlock Text="{Binding ThemeDisplayName}"/>
  73. </StackPanel>
  74. </Button>
  75. <Separator Background="{DynamicResource BorderBrush}" Margin="0,0,0,10"/>
  76. <TextBlock Text="{loc:Translate '主题色'}" FontSize="12" FontWeight="Bold"
  77. Foreground="{DynamicResource PrimaryTextBrush}" Margin="0,0,0,8"/>
  78. <ItemsControl ItemsSource="{Binding AccentColors}">
  79. <ItemsControl.ItemsPanel>
  80. <ItemsPanelTemplate>
  81. <WrapPanel/>
  82. </ItemsPanelTemplate>
  83. </ItemsControl.ItemsPanel>
  84. <ItemsControl.ItemTemplate>
  85. <DataTemplate>
  86. <Button Command="{Binding DataContext.SetAccentCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
  87. CommandParameter="{Binding Hex}"
  88. ToolTip="{Binding Name}"
  89. Background="Transparent" BorderThickness="0" Cursor="Hand"
  90. Padding="3" Margin="1">
  91. <Ellipse Width="20" Height="20" Fill="{Binding Brush}"
  92. Stroke="{DynamicResource BorderBrush}" StrokeThickness="1"/>
  93. </Button>
  94. </DataTemplate>
  95. </ItemsControl.ItemTemplate>
  96. </ItemsControl>
  97. <Separator Background="{DynamicResource BorderBrush}" Margin="0,10"/>
  98. <TextBlock Text="{loc:Translate '自定义颜色'}" FontSize="12"
  99. Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,6"/>
  100. <hc:ColorPicker SelectedBrush="{Binding AccentBrush, Mode=TwoWay}" Width="212"/>
  101. </StackPanel>
  102. </Border>
  103. </Popup>
  104. </StackPanel>
  105. </Grid>
  106. </hc:Window.NonClientAreaContent>
  107. <hc:Window.Resources>
  108. <conv:IsEqualConverter x:Key="IsEqualConverter"/>
  109. <g:IconKindConverter x:Key="IconKind"/>
  110. <!-- Navigation Button Style -->
  111. <Style x:Key="NavButton" TargetType="RadioButton">
  112. <Setter Property="MinWidth" Value="{DynamicResource NavButtonWidth}"/>
  113. <Setter Property="Height" Value="{DynamicResource NavButtonHeight}"/>
  114. <Setter Property="Margin" Value="2,0"/>
  115. <Setter Property="Cursor" Value="Hand"/>
  116. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  117. <Setter Property="FontSize" Value="{DynamicResource NavButtonFontSize}"/>
  118. <Setter Property="Template">
  119. <Setter.Value>
  120. <ControlTemplate TargetType="RadioButton">
  121. <Border x:Name="bd" Background="Transparent" CornerRadius="8" Padding="8,4">
  122. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
  123. <ip:PackIconMaterial x:Name="icon" Width="{DynamicResource NavIconSize}" Height="{DynamicResource NavIconSize}"
  124. Kind="{TemplateBinding Tag, Converter={StaticResource IconKind}}"
  125. Foreground="{DynamicResource SecondaryTextBrush}"
  126. HorizontalAlignment="Center" Margin="0,0,0,4"/>
  127. <ContentPresenter HorizontalAlignment="Center"/>
  128. </StackPanel>
  129. </Border>
  130. <ControlTemplate.Triggers>
  131. <Trigger Property="IsMouseOver" Value="True">
  132. <Setter TargetName="bd" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  133. </Trigger>
  134. <Trigger Property="IsChecked" Value="True">
  135. <Setter TargetName="bd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  136. <Setter Property="Foreground" Value="White"/>
  137. <Setter TargetName="icon" Property="Foreground" Value="White"/>
  138. </Trigger>
  139. </ControlTemplate.Triggers>
  140. </ControlTemplate>
  141. </Setter.Value>
  142. </Setter>
  143. </Style>
  144. </hc:Window.Resources>
  145. <DockPanel>
  146. <!-- Top Navigation Bar -->
  147. <Border DockPanel.Dock="Top" Height="{DynamicResource TopBarHeight}"
  148. Background="{DynamicResource RegionBrush}"
  149. BorderBrush="{DynamicResource BorderBrush}"
  150. BorderThickness="0,0,0,1"
  151. hc:WindowAttach.IsDragElement="True">
  152. <Grid Margin="10,0">
  153. <!-- Left Navigation -->
  154. <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
  155. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '首页'}" Tag="Home"
  156. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="HomeView"
  157. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=HomeView, Mode=TwoWay}"/>
  158. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '产品'}" Tag="CubeOutline"
  159. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="ProductView"
  160. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=ProductView, Mode=TwoWay}"/>
  161. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '设置'}" Tag="Cog"
  162. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="SettingView"
  163. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=SettingView, Mode=TwoWay}"/>
  164. </StackPanel>
  165. <!-- Center Title -->
  166. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
  167. <TextBlock Text="{DynamicResource CenterTitleText}"
  168. FontSize="{DynamicResource CenterTitleFontSize}" FontWeight="Bold"
  169. Foreground="{DynamicResource PrimaryBrush}"/>
  170. </StackPanel>
  171. <!-- Right Navigation + Theme Toggle -->
  172. <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
  173. <Rectangle Width="1" Height="36" Fill="{DynamicResource BorderBrush}" Margin="6,0"/>
  174. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '标定'}" Tag="Ruler"
  175. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="CalibrationView"
  176. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=CalibrationView, Mode=TwoWay}"/>
  177. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '统计'}" Tag="ChartBar"
  178. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="StatisticsView"
  179. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=StatisticsView, Mode=TwoWay}"/>
  180. <RadioButton Style="{StaticResource NavButton}" Content="{loc:Translate '用户'}" Tag="Account"
  181. GroupName="Nav" Command="{Binding NavigateCommand}" CommandParameter="UserView"
  182. IsChecked="{Binding CurrentView, Converter={StaticResource IsEqualConverter}, ConverterParameter=UserView, Mode=TwoWay}"/>
  183. <Rectangle Width="1" Height="36" Fill="{DynamicResource BorderBrush}" Margin="6,0"/>
  184. </StackPanel>
  185. </Grid>
  186. </Border>
  187. <!-- Bottom Status Bar -->
  188. <Border DockPanel.Dock="Bottom" Height="{DynamicResource StatusBarHeight}"
  189. Background="{DynamicResource SecondaryRegionBrush}"
  190. BorderBrush="{DynamicResource BorderBrush}"
  191. BorderThickness="0,1,0,0">
  192. <Grid>
  193. <Grid.ColumnDefinitions>
  194. <ColumnDefinition Width="*"/>
  195. <ColumnDefinition Width="Auto"/>
  196. </Grid.ColumnDefinitions>
  197. <!-- 左侧:设备状态(可换行,最多两行) -->
  198. <ItemsControl Grid.Column="0" ItemsSource="{Binding DeviceStatusItems}"
  199. Margin="16,0" VerticalAlignment="Center">
  200. <ItemsControl.ItemsPanel>
  201. <ItemsPanelTemplate>
  202. <WrapPanel Orientation="Horizontal"/>
  203. </ItemsPanelTemplate>
  204. </ItemsControl.ItemsPanel>
  205. <ItemsControl.ItemTemplate>
  206. <DataTemplate>
  207. <StackPanel Orientation="Horizontal" Margin="0,0,16,0" VerticalAlignment="Center">
  208. <Ellipse Width="8" Height="8" Margin="0,0,6,0">
  209. <Ellipse.Style>
  210. <Style TargetType="Ellipse">
  211. <Setter Property="Fill" Value="#F44336"/>
  212. <Style.Triggers>
  213. <DataTrigger Binding="{Binding IsConnected}" Value="True">
  214. <Setter Property="Fill" Value="#4CAF50"/>
  215. </DataTrigger>
  216. </Style.Triggers>
  217. </Style>
  218. </Ellipse.Style>
  219. </Ellipse>
  220. <TextBlock FontSize="{DynamicResource StatusBarFontSize}" Foreground="{DynamicResource SecondaryTextBrush}" VerticalAlignment="Center">
  221. <Run Text="{Binding Category}"/><Run Text=": "/><Run Text="{Binding Name}"/>
  222. </TextBlock>
  223. </StackPanel>
  224. </DataTemplate>
  225. </ItemsControl.ItemTemplate>
  226. </ItemsControl>
  227. <!-- 右侧:内存 + 时间 -->
  228. <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="16,0">
  229. <TextBlock Text="{Binding MemoryUsage}" FontSize="{DynamicResource StatusBarFontSize}" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,16,0"/>
  230. <TextBlock Text="{Binding CurrentTime}" FontSize="{DynamicResource StatusBarFontSize}" Foreground="{DynamicResource SecondaryTextBrush}"/>
  231. </StackPanel>
  232. </Grid>
  233. </Border>
  234. <!-- Content Area -->
  235. <ContentControl prism:RegionManager.RegionName="ContentRegion"
  236. Background="{DynamicResource RegionBrush}"/>
  237. </DockPanel>
  238. </hc:Window>