ProductView.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <UserControl x:Class="TeamAAS.Views.ProductView"
  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" xmlns:loc="clr-namespace:TeamAAS.Localization"
  5. xmlns:fe="clr-namespace:TeamAAS.FlowEditor;assembly=TeamAAS.FlowEngine"
  6. xmlns:conv="clr-namespace:TeamAAS.Converters">
  7. <UserControl.Resources>
  8. <BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>
  9. <conv:BoolToArrowConverter x:Key="BoolToArrowConverter"/>
  10. <conv:BoolToWidthConverter x:Key="BoolToWidthConverter"/>
  11. <conv:InvertBoolToVisibilityConverter x:Key="InvertBoolToVisConverter"/>
  12. <conv:RunDotConverter x:Key="RunDotConverter"/>
  13. <!-- Expanded: Product list item style -->
  14. <Style x:Key="ProductListItem" TargetType="ListBoxItem">
  15. <Setter Property="Padding" Value="12,8"/>
  16. <Setter Property="Margin" Value="4,2"/>
  17. <Setter Property="FontSize" Value="14"/>
  18. <Setter Property="Cursor" Value="Hand"/>
  19. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  20. <Setter Property="Template">
  21. <Setter.Value>
  22. <ControlTemplate TargetType="ListBoxItem">
  23. <Border x:Name="itemBd" Background="Transparent" CornerRadius="6" Padding="{TemplateBinding Padding}">
  24. <ContentPresenter/>
  25. </Border>
  26. <ControlTemplate.Triggers>
  27. <Trigger Property="IsMouseOver" Value="True">
  28. <Setter TargetName="itemBd" Property="Background" Value="{DynamicResource BorderBrush}"/>
  29. </Trigger>
  30. <Trigger Property="IsSelected" Value="True">
  31. <Setter TargetName="itemBd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  32. <Setter Property="Foreground" Value="White"/>
  33. </Trigger>
  34. </ControlTemplate.Triggers>
  35. </ControlTemplate>
  36. </Setter.Value>
  37. </Setter>
  38. </Style>
  39. <!-- Collapsed: compact icon-only style -->
  40. <Style x:Key="ProductListItemCompact" TargetType="ListBoxItem">
  41. <Setter Property="Width" Value="40"/>
  42. <Setter Property="Height" Value="40"/>
  43. <Setter Property="Margin" Value="2,3"/>
  44. <Setter Property="Cursor" Value="Hand"/>
  45. <Setter Property="Template">
  46. <Setter.Value>
  47. <ControlTemplate TargetType="ListBoxItem">
  48. <Border x:Name="itemBd" Background="Transparent" CornerRadius="6"
  49. Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
  50. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  51. </Border>
  52. <ControlTemplate.Triggers>
  53. <Trigger Property="IsMouseOver" Value="True">
  54. <Setter TargetName="itemBd" Property="Background" Value="{DynamicResource BorderBrush}"/>
  55. </Trigger>
  56. <Trigger Property="IsSelected" Value="True">
  57. <Setter TargetName="itemBd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  58. </Trigger>
  59. </ControlTemplate.Triggers>
  60. </ControlTemplate>
  61. </Setter.Value>
  62. </Setter>
  63. </Style>
  64. <!-- Expanded sidebar action button style -->
  65. <Style x:Key="ActionBtn" TargetType="Button">
  66. <Setter Property="Height" Value="38"/>
  67. <Setter Property="FontSize" Value="13"/>
  68. <Setter Property="Cursor" Value="Hand"/>
  69. <Setter Property="Margin" Value="2,3"/>
  70. </Style>
  71. <!-- Collapsed sidebar action button style -->
  72. <Style x:Key="ActionBtnIcon" TargetType="Button">
  73. <Setter Property="Width" Value="36"/>
  74. <Setter Property="Height" Value="36"/>
  75. <Setter Property="FontSize" Value="14"/>
  76. <Setter Property="Cursor" Value="Hand"/>
  77. <Setter Property="Margin" Value="2,3"/>
  78. <Setter Property="Template">
  79. <Setter.Value>
  80. <ControlTemplate TargetType="Button">
  81. <Border x:Name="bd" Background="{DynamicResource SecondaryRegionBrush}"
  82. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
  83. CornerRadius="6">
  84. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  85. </Border>
  86. <ControlTemplate.Triggers>
  87. <Trigger Property="IsMouseOver" Value="True">
  88. <Setter TargetName="bd" Property="Background" Value="{DynamicResource BorderBrush}"/>
  89. </Trigger>
  90. <Trigger Property="IsEnabled" Value="False">
  91. <Setter Property="Opacity" Value="0.4"/>
  92. </Trigger>
  93. </ControlTemplate.Triggers>
  94. </ControlTemplate>
  95. </Setter.Value>
  96. </Setter>
  97. </Style>
  98. <!-- Toggle button style -->
  99. <Style x:Key="ToggleBtn" TargetType="Button">
  100. <Setter Property="Width" Value="32"/>
  101. <Setter Property="Height" Value="32"/>
  102. <Setter Property="Cursor" Value="Hand"/>
  103. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  104. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  105. <Setter Property="BorderThickness" Value="1"/>
  106. <Setter Property="FontSize" Value="14"/>
  107. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  108. <Setter Property="Template">
  109. <Setter.Value>
  110. <ControlTemplate TargetType="Button">
  111. <Border x:Name="bd" Background="{TemplateBinding Background}"
  112. BorderBrush="{TemplateBinding BorderBrush}"
  113. BorderThickness="{TemplateBinding BorderThickness}"
  114. CornerRadius="6">
  115. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  116. </Border>
  117. <ControlTemplate.Triggers>
  118. <Trigger Property="IsMouseOver" Value="True">
  119. <Setter TargetName="bd" Property="Background" Value="{DynamicResource BorderBrush}"/>
  120. </Trigger>
  121. </ControlTemplate.Triggers>
  122. </ControlTemplate>
  123. </Setter.Value>
  124. </Setter>
  125. </Style>
  126. </UserControl.Resources>
  127. <Grid>
  128. <!-- Main content -->
  129. <Grid>
  130. <Grid.ColumnDefinitions>
  131. <ColumnDefinition Width="Auto"/>
  132. <ColumnDefinition Width="*"/>
  133. </Grid.ColumnDefinitions>
  134. <!-- Sidebar -->
  135. <Border x:Name="SidebarPanel" Grid.Column="0" Width="280"
  136. ClipToBounds="True"
  137. Background="{DynamicResource RegionBrush}"
  138. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,1,0">
  139. <Grid>
  140. <!-- EXPANDED sidebar(宽视图,文字+图标) -->
  141. <Grid x:Name="SidebarExpanded" Opacity="1.0">
  142. <DockPanel>
  143. <!-- 顶部标题 + 折叠按钮 -->
  144. <Grid DockPanel.Dock="Top" Margin="12,8,8,8">
  145. <Grid.ColumnDefinitions>
  146. <ColumnDefinition Width="*"/>
  147. <ColumnDefinition Width="Auto"/>
  148. </Grid.ColumnDefinitions>
  149. <TextBlock Grid.Column="0" Text="{loc:Translate '产品管理'}" FontSize="20" FontWeight="Bold"
  150. Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
  151. <Button Grid.Column="1" Style="{StaticResource ToggleBtn}"
  152. Command="{Binding ToggleSidebarCommand}"
  153. Content="◀" ToolTip="{loc:Translate '折叠产品面板'}"/>
  154. </Grid>
  155. <DockPanel Margin="14,0,14,12">
  156. <UniformGrid DockPanel.Dock="Top" Columns="2" Margin="0,0,0,10">
  157. <Button Width="auto" MinWidth="90" Height="35" Margin="5" Content="{loc:Translate '➕ 新建'}" Command="{Binding NewProductCommand}"/>
  158. <Button Width="auto" MinWidth="90" Height="35" Margin="5" Content="{loc:Translate '✏ 重命名'}" Command="{Binding RenameProductCommand}"
  159. IsEnabled="{Binding IsProductSelected}"/>
  160. <Button Width="auto" MinWidth="90" Height="35" Margin="5" Content="{loc:Translate '🗑 删除'}" Command="{Binding DeleteProductCommand}"
  161. IsEnabled="{Binding IsProductSelected}"/>
  162. <Button Width="auto" MinWidth="90" Height="35" Margin="5" Content="{loc:Translate '💾 保存全部'}" Command="{Binding SaveProductCommand}"
  163. IsEnabled="{Binding IsProductSelected}"/>
  164. </UniformGrid>
  165. <Border DockPanel.Dock="Top" Height="1" Background="{DynamicResource BorderBrush}" Margin="0,2,0,10"/>
  166. <ListBox ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProduct}"
  167. Background="{DynamicResource SecondaryRegionBrush}"
  168. BorderBrush="{DynamicResource BorderBrush}"
  169. BorderThickness="1"
  170. ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  171. <ListBox.ItemTemplate>
  172. <DataTemplate>
  173. <Grid Background="Transparent">
  174. <Grid.ContextMenu>
  175. <ContextMenu>
  176. <MenuItem Header="{loc:Translate '🖼 属性'}" Click="ProductProperties_Click"/>
  177. <MenuItem Header="{loc:Translate '📊 全局变量'}" Click="ProductGlobalVars_Click"/>
  178. </ContextMenu>
  179. </Grid.ContextMenu>
  180. <StackPanel Orientation="Horizontal">
  181. <TextBlock Text="📦" Margin="0,0,10,0" VerticalAlignment="Center" FontSize="16"/>
  182. <TextBlock Text="{Binding}" VerticalAlignment="Center" FontSize="14"/>
  183. </StackPanel>
  184. </Grid>
  185. </DataTemplate>
  186. </ListBox.ItemTemplate>
  187. <ListBox.ItemContainerStyle>
  188. <Style TargetType="ListBoxItem" BasedOn="{StaticResource ProductListItem}"/>
  189. </ListBox.ItemContainerStyle>
  190. </ListBox>
  191. </DockPanel>
  192. </DockPanel>
  193. </Grid>
  194. <!-- COLLAPSED sidebar(窄条,仅图标) -->
  195. <Grid x:Name="SidebarCollapsed" Opacity="0" Visibility="Hidden">
  196. <DockPanel>
  197. <!-- 展开按钮 -->
  198. <Border DockPanel.Dock="Top" Margin="0,4,0,4">
  199. <Button Style="{StaticResource ToggleBtn}"
  200. Command="{Binding ToggleSidebarCommand}"
  201. Content="▶" ToolTip="{loc:Translate '展开产品面板'}"
  202. HorizontalAlignment="Center"/>
  203. </Border>
  204. <Separator DockPanel.Dock="Top" Background="{DynamicResource BorderBrush}"/>
  205. <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="2">
  206. <StackPanel>
  207. <hc:UniformSpacingPanel ChildWrapping="Wrap" Orientation="Vertical" HorizontalAlignment="Center" Spacing="5">
  208. <Button Height="36" Width="40"
  209. Command="{Binding NewProductCommand}"
  210. Content="➕" ToolTip="{loc:Translate '新建产品'}"/>
  211. <Button Height="36" Width="40"
  212. Command="{Binding RenameProductCommand}"
  213. Content="✏" ToolTip="{loc:Translate '重命名'}"
  214. IsEnabled="{Binding IsProductSelected}"/>
  215. <Button Height="36" Width="40"
  216. Command="{Binding DeleteProductCommand}"
  217. Content="🗑" ToolTip="{loc:Translate '删除产品'}"
  218. IsEnabled="{Binding IsProductSelected}"/>
  219. <Button Height="36" Width="40"
  220. Command="{Binding SaveProductCommand}"
  221. Content="💾" ToolTip="{loc:Translate '保存所有流程'}"
  222. IsEnabled="{Binding IsProductSelected}"/>
  223. </hc:UniformSpacingPanel>
  224. <Separator Margin="0,6,0,6" Background="{DynamicResource BorderBrush}"/>
  225. <ListBox ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProduct}"
  226. Background="Transparent"
  227. BorderThickness="0"
  228. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  229. ItemContainerStyle="{StaticResource ProductListItemCompact}">
  230. <ListBox.ItemTemplate>
  231. <DataTemplate>
  232. <TextBlock Text="📦" FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center"
  233. ToolTip="{Binding}"/>
  234. </DataTemplate>
  235. </ListBox.ItemTemplate>
  236. </ListBox>
  237. </StackPanel>
  238. </ScrollViewer>
  239. </DockPanel>
  240. </Grid>
  241. </Grid>
  242. </Border>
  243. <!-- Right: Flow Editor -->
  244. <Grid Grid.Column="1">
  245. <!-- Flow Editor Shell(运行产品运行中 → 画布只读监控,可选中节点查看结果) -->
  246. <Grid>
  247. <ContentControl Content="{Binding ShellVm}">
  248. <ContentControl.ContentTemplate>
  249. <DataTemplate DataType="{x:Type fe:FlowEditorShellViewModel}">
  250. <fe:FlowEditorShellView/>
  251. </DataTemplate>
  252. </ContentControl.ContentTemplate>
  253. </ContentControl>
  254. </Grid>
  255. </Grid>
  256. </Grid>
  257. <!-- Loading Overlay -->
  258. <Border Background="#66000000"
  259. Visibility="{Binding IsProductLoading, Converter={StaticResource BoolToVisConverter}}"
  260. Panel.ZIndex="1000">
  261. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
  262. <ProgressBar IsIndeterminate="True" Width="140" Height="10"/>
  263. <TextBlock Text="{loc:Translate '加载产品中...'}" FontSize="14" Foreground="{DynamicResource SecondaryTextBrush}"
  264. HorizontalAlignment="Center" Margin="0,12,0,0"/>
  265. </StackPanel>
  266. </Border>
  267. </Grid>
  268. </UserControl>