FlowEditorView.xaml 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. <UserControl x:Class="TeamAAS.FlowEditor.FlowEditorView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:loc="clr-namespace:TeamAAS.Localization;assembly=TeamAAS.Global"
  5. xmlns:hc="https://handyorg.github.io/handycontrol"
  6. xmlns:fe="clr-namespace:TeamAAS.FlowEditor.Controls"
  7. xmlns:conv="clr-namespace:TeamAAS.FlowEditor.Converters"
  8. xmlns:ip="clr-namespace:MahApps.Metro.IconPacks;assembly=MahApps.Metro.IconPacks.Material"
  9. xmlns:g="clr-namespace:TeamAAS;assembly=TeamAAS.Global">
  10. <UserControl.Resources>
  11. <!-- bool 取反:只读模式禁用编辑按钮 -->
  12. <conv:InverseBoolConverter x:Key="InverseBoolConverter"/>
  13. <!-- 图标 Kind 名 → PackIconMaterialKind -->
  14. <g:IconKindConverter x:Key="IconKind"/>
  15. <!-- 画布网格背景(透明底 + 浅灰网格线,叠加在 SecondaryBorderBrush 上) -->
  16. <DrawingBrush x:Key="GridBrush" TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
  17. <DrawingBrush.Drawing>
  18. <DrawingGroup>
  19. <GeometryDrawing Geometry="M0,0 L20,0 M0,0 L0,20">
  20. <GeometryDrawing.Pen>
  21. <Pen Brush="{DynamicResource SecondaryBorderBrush}" Thickness="0.5"/>
  22. </GeometryDrawing.Pen>
  23. </GeometryDrawing>
  24. </DrawingGroup>
  25. </DrawingBrush.Drawing>
  26. </DrawingBrush>
  27. <!-- MoveThumb 透明模板 -->
  28. <Style TargetType="{x:Type fe:MoveThumb}">
  29. <Setter Property="Template">
  30. <Setter.Value>
  31. <ControlTemplate TargetType="{x:Type fe:MoveThumb}">
  32. <Rectangle Fill="Transparent"/>
  33. </ControlTemplate>
  34. </Setter.Value>
  35. </Setter>
  36. </Style>
  37. <!-- 画布垂直滚动条:扁平细滑块,颜色跟随主题(悬停变强调色) -->
  38. <Style x:Key="CanvasVScrollBar" TargetType="ScrollBar">
  39. <Setter Property="Background" Value="Transparent"/>
  40. <Setter Property="Template">
  41. <Setter.Value>
  42. <ControlTemplate TargetType="ScrollBar">
  43. <Grid Background="Transparent">
  44. <Track x:Name="PART_Track" IsDirectionReversed="True">
  45. <Track.DecreaseRepeatButton>
  46. <RepeatButton Command="ScrollBar.PageUpCommand" Opacity="0" Focusable="False"/>
  47. </Track.DecreaseRepeatButton>
  48. <Track.IncreaseRepeatButton>
  49. <RepeatButton Command="ScrollBar.PageDownCommand" Opacity="0" Focusable="False"/>
  50. </Track.IncreaseRepeatButton>
  51. <Track.Thumb>
  52. <Thumb>
  53. <Thumb.Template>
  54. <ControlTemplate TargetType="Thumb">
  55. <Border x:Name="ThumbBorder" Margin="4,1" CornerRadius="3" MinHeight="28"
  56. Background="{DynamicResource BorderBrush}"/>
  57. <ControlTemplate.Triggers>
  58. <Trigger Property="IsMouseOver" Value="True">
  59. <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  60. </Trigger>
  61. </ControlTemplate.Triggers>
  62. </ControlTemplate>
  63. </Thumb.Template>
  64. </Thumb>
  65. </Track.Thumb>
  66. </Track>
  67. </Grid>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. <!-- 画布水平滚动条:同上(横向) -->
  73. <Style x:Key="CanvasHScrollBar" TargetType="ScrollBar">
  74. <Setter Property="Background" Value="Transparent"/>
  75. <Setter Property="Template">
  76. <Setter.Value>
  77. <ControlTemplate TargetType="ScrollBar">
  78. <Grid Background="Transparent">
  79. <Track x:Name="PART_Track">
  80. <Track.DecreaseRepeatButton>
  81. <RepeatButton Command="ScrollBar.PageLeftCommand" Opacity="0" Focusable="False"/>
  82. </Track.DecreaseRepeatButton>
  83. <Track.IncreaseRepeatButton>
  84. <RepeatButton Command="ScrollBar.PageRightCommand" Opacity="0" Focusable="False"/>
  85. </Track.IncreaseRepeatButton>
  86. <Track.Thumb>
  87. <Thumb>
  88. <Thumb.Template>
  89. <ControlTemplate TargetType="Thumb">
  90. <Border x:Name="ThumbBorder" Margin="1,4" CornerRadius="3" MinWidth="28"
  91. Background="{DynamicResource BorderBrush}"/>
  92. <ControlTemplate.Triggers>
  93. <Trigger Property="IsMouseOver" Value="True">
  94. <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  95. </Trigger>
  96. </ControlTemplate.Triggers>
  97. </ControlTemplate>
  98. </Thumb.Template>
  99. </Thumb>
  100. </Track.Thumb>
  101. </Track>
  102. </Grid>
  103. </ControlTemplate>
  104. </Setter.Value>
  105. </Setter>
  106. </Style>
  107. <!-- 执行历史列表项样式 -->
  108. <Style x:Key="HistoryListItemStyle" TargetType="ListBoxItem">
  109. <Setter Property="Padding" Value="6,2"/>
  110. <Setter Property="Margin" Value="0,1"/>
  111. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  112. <Setter Property="Template">
  113. <Setter.Value>
  114. <ControlTemplate TargetType="ListBoxItem">
  115. <Border x:Name="Bd" Background="Transparent" CornerRadius="3" Padding="{TemplateBinding Padding}">
  116. <ContentPresenter/>
  117. </Border>
  118. <ControlTemplate.Triggers>
  119. <Trigger Property="IsSelected" Value="True">
  120. <Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  121. <Setter Property="TextElement.Foreground" Value="White"/>
  122. </Trigger>
  123. <Trigger Property="IsMouseOver" Value="True">
  124. <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  125. </Trigger>
  126. </ControlTemplate.Triggers>
  127. </ControlTemplate>
  128. </Setter.Value>
  129. </Setter>
  130. </Style>
  131. <!-- ConnectorControl 连接点样式 -->
  132. <Style TargetType="{x:Type fe:ConnectorControl}">
  133. <Setter Property="Width" Value="14"/>
  134. <Setter Property="Height" Value="14"/>
  135. <Setter Property="Cursor" Value="Cross"/>
  136. <Setter Property="Template">
  137. <Setter.Value>
  138. <ControlTemplate TargetType="{x:Type fe:ConnectorControl}">
  139. <Grid Width="14" Height="14">
  140. <Ellipse Fill="Transparent" Margin="-8"/>
  141. <Ellipse Width="10" Height="10"
  142. Fill="{DynamicResource PrimaryBrush}"
  143. Stroke="#FFFFFF" StrokeThickness="1.5"/>
  144. </Grid>
  145. </ControlTemplate>
  146. </Setter.Value>
  147. </Setter>
  148. </Style>
  149. <!-- NodeControl 节点样式 -->
  150. <Style TargetType="{x:Type fe:NodeControl}">
  151. <Setter Property="SnapsToDevicePixels" Value="True"/>
  152. <Setter Property="HorizontalAlignment" Value="Left"/>
  153. <Setter Property="VerticalAlignment" Value="Top"/>
  154. <Setter Property="Template">
  155. <Setter.Value>
  156. <ControlTemplate TargetType="{x:Type fe:NodeControl}">
  157. <Grid >
  158. <!-- ========== 矩形节点(Normal/ToolBlock) ========== -->
  159. <Border x:Name="RectNode" CornerRadius="4"
  160. BorderBrush="{DynamicResource PrimaryBrush}"
  161. BorderThickness="2"
  162. Background="{DynamicResource RegionBrush}"
  163. MinHeight="40"
  164. ClipToBounds="True">
  165. <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
  166. <!-- 左侧色条 + 图标 -->
  167. <Border x:Name="RectLeftBar" Background="{DynamicResource PrimaryBrush}"
  168. CornerRadius="3,0,0,3" Width="32">
  169. <ip:PackIconMaterial Width="16" Height="16"
  170. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
  171. HorizontalAlignment="Center"
  172. VerticalAlignment="Center"/>
  173. </Border>
  174. <!-- 中间:名称 + 耗时 -->
  175. <StackPanel VerticalAlignment="Center" Margin="8,0,8,0" MinWidth="100" >
  176. <StackPanel Orientation="Horizontal">
  177. <TextBlock Text="{Binding NodeName}"
  178. Foreground="{DynamicResource PrimaryTextBrush}"
  179. FontSize="15"
  180. FontFamily="Microsoft YaHei"
  181. TextTrimming="CharacterEllipsis"/>
  182. <TextBlock Text="{Binding CostTimeText}"
  183. MinWidth="35"
  184. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
  185. Margin="8,0,0,0"
  186. VerticalAlignment="Center"/>
  187. </StackPanel>
  188. </StackPanel>
  189. <!-- 右侧色条 + 状态圆 -->
  190. <Border x:Name="RectRightBar" Background="{DynamicResource PrimaryBrush}"
  191. CornerRadius="0,3,3,0" Width="20">
  192. <Ellipse Width="10" Height="10"
  193. Fill="{Binding StatusColor}"
  194. HorizontalAlignment="Center"
  195. VerticalAlignment="Center"/>
  196. </Border>
  197. </StackPanel>
  198. </Border>
  199. <!-- ========== 循环节点(ForLoop) ========== -->
  200. <Border x:Name="LoopNode" Visibility="Collapsed"
  201. MinWidth="200" MinHeight="35"
  202. CornerRadius="4"
  203. BorderBrush="{DynamicResource DarkInfoBrush}"
  204. BorderThickness="0"
  205. Background="{DynamicResource RegionBrush}"
  206. ClipToBounds="True">
  207. <StackPanel Background="{DynamicResource RegionBrush}">
  208. <!-- 头部色条 -->
  209. <Border Background="{DynamicResource DarkInfoBrush}"
  210. CornerRadius="3,3,0,0" Padding="8,4">
  211. <TextBlock Text="{loc:Translate '循环'}" Foreground="White"
  212. FontSize="11" FontWeight="Bold"
  213. HorizontalAlignment="Center"
  214. FontFamily="Microsoft YaHei"/>
  215. </Border>
  216. <!-- 内容 -->
  217. <StackPanel Orientation="Horizontal" Margin="8,6,6,6">
  218. <ip:PackIconMaterial Width="14" Height="14"
  219. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
  220. Foreground="{DynamicResource DarkInfoBrush}"
  221. VerticalAlignment="Center"/>
  222. <TextBlock Text="{Binding NodeName}"
  223. Foreground="{DynamicResource PrimaryTextBrush}"
  224. FontSize="13"
  225. FontFamily="Microsoft YaHei"
  226. Margin="6,0,0,0"
  227. TextTrimming="CharacterEllipsis"/>
  228. <TextBlock Text="{Binding CostTimeText}"
  229. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
  230. Margin="8,0,0,0"
  231. VerticalAlignment="Center"/>
  232. </StackPanel>
  233. </StackPanel>
  234. </Border>
  235. <!-- ========== 组合节点(Group)- 堆叠效果 ========== -->
  236. <Grid x:Name="GroupNode" Visibility="Collapsed" MinWidth="150" MinHeight="40" >
  237. <!-- 底层堆叠2(最远) -->
  238. <Border CornerRadius="4" BorderThickness="1.5"
  239. BorderBrush="{DynamicResource PrimaryBrush}" Background="{DynamicResource PrimaryBrush}"
  240. Margin="6,6,-6,-6" Opacity="0.3"/>
  241. <!-- 底层堆叠1 -->
  242. <Border CornerRadius="4" BorderThickness="1.5"
  243. BorderBrush="{DynamicResource PrimaryBrush}" Background="{DynamicResource PrimaryBrush}"
  244. Margin="3,3,-3,-3" Opacity="0.5"/>
  245. <!-- 主区块 -->
  246. <Border x:Name="GroupMainBorder" CornerRadius="4" BorderThickness="2"
  247. BorderBrush="{DynamicResource PrimaryBrush}"
  248. Background="{DynamicResource RegionBrush}"
  249. ClipToBounds="True">
  250. <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
  251. <Border Background="{DynamicResource PrimaryBrush}" CornerRadius="3,0,0,3" Width="32">
  252. <ip:PackIconMaterial Width="16" Height="16"
  253. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
  254. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  255. </Border>
  256. <StackPanel VerticalAlignment="Center" Margin="8,0,16,0" MinWidth="100" >
  257. <StackPanel Orientation="Horizontal">
  258. <TextBlock Text="{Binding NodeName}"
  259. Foreground="{DynamicResource PrimaryTextBrush}"
  260. FontSize="13" FontFamily="Microsoft YaHei"
  261. TextTrimming="CharacterEllipsis"/>
  262. <TextBlock Text="{Binding CostTimeText}"
  263. MinWidth="20"
  264. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
  265. Margin="8,0,0,0" VerticalAlignment="Center"/>
  266. </StackPanel>
  267. <TextBlock Text="{loc:Translate '组合模块'}" FontSize="10"
  268. Foreground="{DynamicResource SecondaryTextBrush}"
  269. Margin="0,2,0,0"/>
  270. </StackPanel>
  271. <Border Background="{DynamicResource PrimaryBrush}" CornerRadius="0,3,3,0" Width="20">
  272. <Ellipse Width="10" Height="10" Fill="{Binding StatusColor}"
  273. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  274. </Border>
  275. </StackPanel>
  276. </Border>
  277. </Grid>
  278. <!-- ========== 结束节点(End)- 圆角胶囊形 ========== -->
  279. <Grid x:Name="EndNode" Visibility="Collapsed">
  280. <Border x:Name="EndMainBorder" CornerRadius="26" BorderThickness="2"
  281. BorderBrush="#D32F2F"
  282. Background="{DynamicResource RegionBrush}"
  283. MinWidth="140" MinHeight="50">
  284. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
  285. <ip:PackIconMaterial Width="14" Height="14"
  286. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="#D32F2F"
  287. VerticalAlignment="Center"/>
  288. <TextBlock Text="{Binding NodeName}"
  289. Foreground="{DynamicResource PrimaryTextBrush}"
  290. FontSize="13" FontFamily="Microsoft YaHei"
  291. Margin="6,0,0,0" VerticalAlignment="Center"
  292. TextTrimming="CharacterEllipsis"/>
  293. <TextBlock Text="{Binding CostTimeText}"
  294. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
  295. Margin="8,0,0,0" VerticalAlignment="Center"/>
  296. </StackPanel>
  297. </Border>
  298. </Grid>
  299. <!-- ========== 菱形节点(Decision) ========== -->
  300. <Grid x:Name="DiamondNode" Visibility="Collapsed"
  301. Width="180" Height="50">
  302. <Path x:Name="DiamondPath"
  303. Data="M0.12,0 L0.88,0 L1,0.5 L0.88,1 L0.12,1 L0,0.5 Z"
  304. Stretch="Fill"
  305. Fill="{DynamicResource RegionBrush}"
  306. Stroke="{DynamicResource DarkWarningBrush}"
  307. StrokeThickness="1.5"/>
  308. <StackPanel HorizontalAlignment="Center"
  309. VerticalAlignment="Center"
  310. Margin="30,4">
  311. <TextBlock Text="{Binding NodeName}"
  312. Foreground="{DynamicResource PrimaryTextBrush}"
  313. FontSize="12"
  314. FontFamily="Microsoft YaHei"
  315. HorizontalAlignment="Center"
  316. TextTrimming="CharacterEllipsis"/>
  317. <TextBlock Text="{Binding CostTimeText}"
  318. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="10"
  319. HorizontalAlignment="Center"
  320. Margin="0,2,0,0"/>
  321. </StackPanel>
  322. </Grid>
  323. <!-- ========== 异常分支节点(ExceptionBranch)- 深红矩形 + 警告色条 ========== -->
  324. <Border x:Name="ExceptionBranchNode" Visibility="Collapsed"
  325. CornerRadius="4"
  326. BorderBrush="#B71C1C"
  327. BorderThickness="2"
  328. Background="{DynamicResource RegionBrush}"
  329. MinHeight="40"
  330. ClipToBounds="True">
  331. <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
  332. <Border Background="#B71C1C" CornerRadius="3,0,0,3" Width="32">
  333. <ip:PackIconMaterial Width="16" Height="16"
  334. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
  335. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  336. </Border>
  337. <StackPanel VerticalAlignment="Center" Margin="8,0,8,0" MinWidth="100">
  338. <StackPanel Orientation="Horizontal">
  339. <TextBlock Text="{Binding NodeName}"
  340. Foreground="{DynamicResource PrimaryTextBrush}"
  341. FontSize="15" FontFamily="Microsoft YaHei"
  342. TextTrimming="CharacterEllipsis"/>
  343. <TextBlock Text="{Binding CostTimeText}"
  344. MinWidth="20"
  345. Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
  346. Margin="8,0,0,0" VerticalAlignment="Center"/>
  347. </StackPanel>
  348. <TextBlock Text="{loc:Translate '异常分支'}" FontSize="10"
  349. Foreground="#B71C1C"
  350. Margin="0,2,0,0"/>
  351. </StackPanel>
  352. <Border Background="#B71C1C" CornerRadius="0,3,3,0" Width="20">
  353. <Ellipse Width="10" Height="10" Fill="{Binding StatusColor}"
  354. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  355. </Border>
  356. </StackPanel>
  357. </Border>
  358. <!-- 拖拽手柄 -->
  359. <fe:MoveThumb Cursor="Hand" Panel.ZIndex="1"/>
  360. <!-- 连接点容器(常驻可见,悬停高亮) -->
  361. <Grid x:Name="ConnectorContainer"
  362. Opacity="0" Panel.ZIndex="2">
  363. <!-- 左 -->
  364. <fe:ConnectorControl PortIndex="0" Side="Left"
  365. VerticalAlignment="Center"
  366. HorizontalAlignment="Left"
  367. Margin="-7,0,0,0"/>
  368. <!-- 右 -->
  369. <fe:ConnectorControl PortIndex="1" Side="Right"
  370. VerticalAlignment="Center"
  371. HorizontalAlignment="Right"
  372. Margin="0,0,-7,0"/>
  373. <!-- 上 -->
  374. <fe:ConnectorControl PortIndex="2" Side="Top"
  375. VerticalAlignment="Top"
  376. HorizontalAlignment="Center"
  377. Margin="0,-7,0,0"/>
  378. <!-- 下 -->
  379. <fe:ConnectorControl PortIndex="3" Side="Bottom"
  380. VerticalAlignment="Bottom"
  381. HorizontalAlignment="Center"
  382. Margin="0,0,0,-7"/>
  383. </Grid>
  384. </Grid>
  385. <ControlTemplate.Triggers>
  386. <!-- 悬停:高亮连接点 -->
  387. <Trigger Property="IsMouseOver" Value="True">
  388. <Setter TargetName="ConnectorContainer" Property="Opacity" Value="1"/>
  389. <Setter TargetName="RectNode" Property="BorderThickness" Value="2"/>
  390. <Setter TargetName="LoopNode" Property="BorderThickness" Value="2"/>
  391. <Setter TargetName="DiamondPath" Property="StrokeThickness" Value="2.5"/>
  392. </Trigger>
  393. <!-- 选中:加粗边框 + 显示连接点 -->
  394. <DataTrigger Binding="{Binding IsSelected}" Value="True">
  395. <Setter TargetName="RectNode" Property="BorderThickness" Value="2.5"/>
  396. <Setter TargetName="LoopNode" Property="BorderThickness" Value="2.5"/>
  397. <Setter TargetName="DiamondPath" Property="StrokeThickness" Value="3"/>
  398. <Setter TargetName="ConnectorContainer" Property="Opacity" Value="1"/>
  399. </DataTrigger>
  400. <!-- Decision → 菱形 -->
  401. <DataTrigger Binding="{Binding Category}" Value="Decision">
  402. <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
  403. <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
  404. <Setter TargetName="DiamondNode" Property="Visibility" Value="Visible"/>
  405. <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
  406. <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
  407. </DataTrigger>
  408. <!-- ForLoop → 循环头 -->
  409. <DataTrigger Binding="{Binding Category}" Value="ForLoop">
  410. <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
  411. <Setter TargetName="LoopNode" Property="Visibility" Value="Visible"/>
  412. <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
  413. <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
  414. <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
  415. </DataTrigger>
  416. <!-- Group → 组合模块(堆叠) -->
  417. <DataTrigger Binding="{Binding Category}" Value="Group">
  418. <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
  419. <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
  420. <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
  421. <Setter TargetName="GroupNode" Property="Visibility" Value="Visible"/>
  422. <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
  423. </DataTrigger>
  424. <!-- End → 结束节点(胶囊形) -->
  425. <DataTrigger Binding="{Binding Category}" Value="End">
  426. <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
  427. <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
  428. <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
  429. <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
  430. <Setter TargetName="EndNode" Property="Visibility" Value="Visible"/>
  431. </DataTrigger>
  432. <DataTrigger Binding="{Binding Category}" Value="ExceptionBranch">
  433. <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
  434. <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
  435. <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
  436. <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
  437. <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
  438. <Setter TargetName="ExceptionBranchNode" Property="Visibility" Value="Visible"/>
  439. </DataTrigger>
  440. </ControlTemplate.Triggers>
  441. </ControlTemplate>
  442. </Setter.Value>
  443. </Setter>
  444. </Style>
  445. <!-- 工具箱项样式 -->
  446. <Style x:Key="ToolboxItem" TargetType="Border">
  447. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  448. <Setter Property="CornerRadius" Value="4"/>
  449. <Setter Property="Padding" Value="8,6"/>
  450. <Setter Property="Margin" Value="0,0,0,2"/>
  451. <Setter Property="Cursor" Value="Hand"/>
  452. <Style.Triggers>
  453. <Trigger Property="IsMouseOver" Value="True">
  454. <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  455. </Trigger>
  456. </Style.Triggers>
  457. </Style>
  458. </UserControl.Resources>
  459. <Grid Background="{DynamicResource SecondaryBorderBrush}">
  460. <Grid.RowDefinitions>
  461. <RowDefinition Height="Auto"/>
  462. <RowDefinition Height="*"/>
  463. </Grid.RowDefinitions>
  464. <Grid.ColumnDefinitions>
  465. <ColumnDefinition Width="Auto"/>
  466. <ColumnDefinition Width="*"/>
  467. <ColumnDefinition Width="6"/>
  468. <ColumnDefinition Width="320" MinWidth="320"/>
  469. </Grid.ColumnDefinitions>
  470. <!-- 顶部工具栏 -->
  471. <Border Grid.Row="0" Grid.ColumnSpan="4" Height="46"
  472. Background="{DynamicResource RegionBrush}"
  473. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,0,1">
  474. <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="8,0">
  475. <TextBlock Text="{loc:Translate '流程编辑'}" FontSize="14" FontWeight="Bold"
  476. Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center" Margin="0,0,16,0"/>
  477. <Button Content="+" Width="40" Height="32" FontSize="14" Click="ZoomIn_Click" ToolTip="{loc:Translate '放大'}" Tag="{loc:Translate '放大画布视图'}"/>
  478. <Button Content="−" Width="40" Height="32" FontSize="14" Click="ZoomOut_Click" ToolTip="{loc:Translate '缩小'}" Margin="2,0" Tag="{loc:Translate '缩小画布视图'}"/>
  479. <TextBlock x:Name="TxtZoom" Text="100%" FontSize="12"
  480. Foreground="{DynamicResource SecondaryTextBrush}" VerticalAlignment="Center" Margin="8,0"/>
  481. <Button Content="{loc:Translate '适应内容'}" Width="auto" Height="32" FontSize="14" Click="FitView_Click" ToolTip="{loc:Translate '缩放至所有节点可见'}" Tag="{loc:Translate '自动缩放至所有节点可见'}"/>
  482. <Separator Margin="8,4"/>
  483. <Button Content="{loc:Translate '导入'}" Width="auto" Height="32" FontSize="14" Command="{Binding ImportFlowCommand}"
  484. IsEnabled="{Binding IsReadOnly, Converter={StaticResource InverseBoolConverter}}"
  485. ToolTip="{loc:Translate '从文件导入流程'}" Tag="{loc:Translate '从 .aas 文件导入流程节点与连线'}"/>
  486. <Button Content="{loc:Translate '导出'}" Width="auto" Height="32" FontSize="14" Command="{Binding ExportFlowCommand}" ToolTip="{loc:Translate '导出当前流程到文件'}" Margin="2,0" Tag="{loc:Translate '导出当前流程到 .aas 文件'}"/>
  487. <Separator Margin="8,4"/>
  488. <Button x:Name="BtnRun" Content="{loc:Translate '▶ 运行'}" Width="auto" Height="32" FontSize="14" Click="RunFlow_Click" ToolTip="{loc:Translate '运行流程'}" Tag="{loc:Translate '从头开始运行当前流程,节点状态实时显示在画布上'}"/>
  489. <Button x:Name="BtnStop" Content="{loc:Translate '■ 停止'}" Width="auto" Height="32" FontSize="14" Click="StopFlow_Click" ToolTip="{loc:Translate '停止运行'}" Margin="2,0,0,0" IsEnabled="False" Tag="{loc:Translate '停止当前正在运行的流程'}"/>
  490. </StackPanel>
  491. </Border>
  492. <!-- 左: 工具箱(独立面板,可折叠) -->
  493. <Border x:Name="ToolboxPanel" Grid.Row="1" Grid.Column="0" Width="56" MaxWidth="220"
  494. ClipToBounds="True"
  495. Background="{DynamicResource RegionBrush}"
  496. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,1,0">
  497. <Grid>
  498. <!-- EXPANDED: 完整工具箱 -->
  499. <DockPanel x:Name="ToolboxExpanded" Opacity="0" Visibility="Hidden">
  500. <!-- 顶部:折叠按钮 + 标题 -->
  501. <DockPanel DockPanel.Dock="Top" Margin="8,8,8,6">
  502. <Button x:Name="BtnToolboxToggleExpanded" DockPanel.Dock="Right" Content="◀" FontSize="11"
  503. Click="BtnToolboxToggle_Click" ToolTip="{loc:Translate '折叠工具箱'}"
  504. Background="Transparent" BorderThickness="1"
  505. Foreground="{DynamicResource SecondaryTextBrush}"
  506. BorderBrush="{DynamicResource BorderBrush}"
  507. Cursor="Hand"
  508. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  509. <TextBlock Text="{loc:Translate '节点工具箱'}" FontSize="13" FontWeight="Bold"
  510. Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
  511. </DockPanel>
  512. <Separator Background="{DynamicResource BorderBrush}"/>
  513. <ScrollViewer VerticalScrollBarVisibility="Auto">
  514. <ItemsControl ItemsSource="{Binding ToolboxGroups}" Margin="4,4">
  515. <ItemsControl.ItemTemplate>
  516. <DataTemplate>
  517. <Expander Header="{Binding GroupName}" IsExpanded="True"
  518. FontSize="11" FontWeight="Bold"
  519. Foreground="{DynamicResource SecondaryTextBrush}"
  520. Margin="2,2" Padding="4,2">
  521. <ItemsControl ItemsSource="{Binding Items}">
  522. <ItemsControl.ItemTemplate>
  523. <DataTemplate>
  524. <Border Style="{StaticResource ToolboxItem}"
  525. MouseLeftButtonDown="ToolboxItem_MouseLeftButtonDown"
  526. MouseMove="ToolboxItem_MouseMove">
  527. <StackPanel Orientation="Horizontal">
  528. <ip:PackIconMaterial Width="14" Height="14"
  529. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
  530. Foreground="{DynamicResource PrimaryTextBrush}"
  531. VerticalAlignment="Center"/>
  532. <StackPanel Margin="8,0,0,0">
  533. <TextBlock Text="{Binding DisplayName}"
  534. FontSize="12"
  535. Foreground="{DynamicResource PrimaryTextBrush}"/>
  536. <TextBlock Text="{Binding Description}"
  537. FontSize="10"
  538. Foreground="{DynamicResource SecondaryTextBrush}"
  539. TextTrimming="CharacterEllipsis"/>
  540. </StackPanel>
  541. </StackPanel>
  542. </Border>
  543. </DataTemplate>
  544. </ItemsControl.ItemTemplate>
  545. </ItemsControl>
  546. </Expander>
  547. </DataTemplate>
  548. </ItemsControl.ItemTemplate>
  549. </ItemsControl>
  550. </ScrollViewer>
  551. </DockPanel>
  552. <!-- COLLAPSED: 仅类型图标,Hover 弹 Popup -->
  553. <DockPanel x:Name="ToolboxCollapsed" Opacity="1.0" Visibility="Visible">
  554. <!-- 顶部:展开按钮 -->
  555. <Border DockPanel.Dock="Top" Margin="0,4,0,4">
  556. <Button x:Name="BtnToolboxToggleCollapsed" Content="▶" Width="40" Height="32" FontSize="14"
  557. Click="BtnToolboxToggle_Click" ToolTip="{loc:Translate '展开工具箱'}"
  558. Background="Transparent" BorderThickness="0"
  559. Foreground="{DynamicResource SecondaryTextBrush}" Cursor="Hand"
  560. HorizontalAlignment="Center" VerticalAlignment="Center"/>
  561. </Border>
  562. <Separator Background="{DynamicResource BorderBrush}"/>
  563. <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
  564. <ItemsControl x:Name="CollapsedGroups" ItemsSource="{Binding ToolboxGroups}" Margin="4,4">
  565. <ItemsControl.ItemTemplate>
  566. <DataTemplate>
  567. <Border Width="44" Height="44" Margin="2"
  568. Style="{StaticResource ToolboxItem}"
  569. MouseEnter="GroupTag_MouseEnter"
  570. MouseLeave="GroupTag_MouseLeave">
  571. <ip:PackIconMaterial Width="20" Height="20"
  572. Kind="{Binding GroupIcon, Converter={StaticResource IconKind}}"
  573. Foreground="{DynamicResource PrimaryTextBrush}"
  574. HorizontalAlignment="Center" VerticalAlignment="Center"
  575. ToolTip="{Binding GroupName}"/>
  576. </Border>
  577. </DataTemplate>
  578. </ItemsControl.ItemTemplate>
  579. </ItemsControl>
  580. </ScrollViewer>
  581. </DockPanel>
  582. </Grid>
  583. </Border>
  584. <!-- Popup: 折叠模式下 Hover 弹出类型下的工具列表 -->
  585. <Popup x:Name="ToolboxGroupPopup" AllowsTransparency="True"
  586. PopupAnimation="Slide" Placement="Right"
  587. PlacementTarget="{Binding ElementName=ToolboxPanel}">
  588. <Border Width="200" Background="{DynamicResource RegionBrush}"
  589. BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
  590. Margin="4,0,0,0">
  591. <DockPanel MouseEnter="ToolboxGroupPopup_MouseEnter"
  592. MouseLeave="ToolboxGroupPopup_MouseLeave">
  593. <TextBlock DockPanel.Dock="Top" x:Name="PopupGroupName" FontSize="13" FontWeight="Bold"
  594. Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,8,0,4"/>
  595. <Separator Background="{DynamicResource BorderBrush}"/>
  596. <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="320">
  597. <ItemsControl x:Name="PopupItems" Margin="4,4">
  598. <ItemsControl.ItemTemplate>
  599. <DataTemplate>
  600. <Border Style="{StaticResource ToolboxItem}"
  601. MouseLeftButtonDown="ToolboxItem_MouseLeftButtonDown"
  602. MouseMove="ToolboxItem_MouseMove">
  603. <StackPanel Orientation="Horizontal">
  604. <ip:PackIconMaterial Width="14" Height="14"
  605. Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
  606. Foreground="{DynamicResource PrimaryTextBrush}"
  607. VerticalAlignment="Center"/>
  608. <StackPanel Margin="8,0,0,0">
  609. <TextBlock Text="{Binding DisplayName}" FontSize="12"
  610. Foreground="{DynamicResource PrimaryTextBrush}"/>
  611. <TextBlock Text="{Binding Description}" FontSize="10"
  612. Foreground="{DynamicResource SecondaryTextBrush}"
  613. TextTrimming="CharacterEllipsis"/>
  614. </StackPanel>
  615. </StackPanel>
  616. </Border>
  617. </DataTemplate>
  618. </ItemsControl.ItemTemplate>
  619. </ItemsControl>
  620. </ScrollViewer>
  621. </DockPanel>
  622. </Border>
  623. </Popup>
  624. <!-- 中: 画布 + 滚动条 + 鸟瞰图 -->
  625. <Grid Grid.Row="1" Grid.Column="1" Background="{DynamicResource SecondaryRegionBrush}" ClipToBounds="True">
  626. <fe:FlowCanvas x:Name="EditorCanvas"
  627. Background="{StaticResource GridBrush}"
  628. ClipToBounds="True"
  629. IsRunning="{Binding IsRunning}">
  630. <!-- 工具箱拖拽预览节点:画布子元素,用 Canvas.Left/Top(画布内容坐标)定位,
  631. 与落点/节点同一坐标系,随画布缩放平移;不经过 adorner/窗口坐标换算,
  632. 高 DPI(PerMonitorV2)下不会错位 -->
  633. <Border x:Name="DragPreviewNode"
  634. Visibility="Collapsed"
  635. IsHitTestVisible="False"
  636. Panel.ZIndex="100000"
  637. Background="{DynamicResource PrimaryBrush}"
  638. CornerRadius="6"
  639. Padding="10,6,12,6"
  640. Width="160" Height="42">
  641. <StackPanel Orientation="Horizontal">
  642. <ip:PackIconMaterial x:Name="DragPreviewIcon" Width="14" Height="14"
  643. Foreground="White" VerticalAlignment="Center" Margin="0,0,8,0"/>
  644. <TextBlock x:Name="DragPreviewText" Foreground="White" FontSize="13"
  645. FontWeight="Medium" VerticalAlignment="Center"/>
  646. </StackPanel>
  647. </Border>
  648. </fe:FlowCanvas>
  649. <ScrollBar x:Name="VScrollBar" Orientation="Vertical"
  650. Style="{StaticResource CanvasVScrollBar}"
  651. HorizontalAlignment="Right" Width="16"
  652. SmallChange="20" LargeChange="200"
  653. Scroll="VScrollBar_Scroll"/>
  654. <ScrollBar x:Name="HScrollBar" Orientation="Horizontal"
  655. Style="{StaticResource CanvasHScrollBar}"
  656. VerticalAlignment="Bottom" Height="16"
  657. SmallChange="20" LargeChange="200"
  658. Scroll="HScrollBar_Scroll"/>
  659. <fe:MinimapControl x:Name="Minimap"
  660. Width="200" Height="140"
  661. HorizontalAlignment="Right"
  662. VerticalAlignment="Bottom"
  663. Margin="0,0,20,20"
  664. Canvas="{Binding ElementName=EditorCanvas}"/>
  665. <!-- 加载动画(导入流程时显示转圈) -->
  666. <Border x:Name="LoadingOverlay"
  667. Visibility="Collapsed"
  668. Background="#66000000"
  669. IsHitTestVisible="False"
  670. Panel.ZIndex="1000">
  671. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
  672. <ProgressBar IsIndeterminate="True" Width="120" Height="8"/>
  673. <TextBlock Text="{loc:Translate '加载中...'}" HorizontalAlignment="Center" Margin="0,10,0,0"
  674. Foreground="{DynamicResource PrimaryTextBrush}"/>
  675. </StackPanel>
  676. </Border>
  677. </Grid>
  678. <!-- 垂直分割线(可拖拽调节左右) -->
  679. <GridSplitter Grid.Row="1" Grid.Column="2"
  680. Width="6" HorizontalAlignment="Stretch" ResizeDirection="Columns"
  681. Background="{DynamicResource BorderBrush}"
  682. ResizeBehavior="PreviousAndNext"/>
  683. <!-- 右: 属性面板 -->
  684. <Grid Grid.Row="1" Grid.Column="3" Background="{DynamicResource BorderBrush}">
  685. <Grid.RowDefinitions>
  686. <!-- 顶部可选插槽:默认折叠,主流程/组合模块不受影响;HALCON 子流程编辑器在此注入显示窗体(位于“节点信息”上面) -->
  687. <RowDefinition Height="Auto"/>
  688. <RowDefinition Height="*"/>
  689. </Grid.RowDefinitions>
  690. <ContentControl x:Name="RightTopSlot" Grid.Row="0" Visibility="Collapsed"/>
  691. <Grid Grid.Row="1">
  692. <Grid.RowDefinitions>
  693. <RowDefinition Height="Auto"/>
  694. <RowDefinition Height="4"/>
  695. <RowDefinition Height="Auto"/>
  696. <RowDefinition Height="4"/>
  697. <RowDefinition Height="*"/>
  698. </Grid.RowDefinitions>
  699. <!-- 上: 节点信息(默认内容;平台子流程编辑器可经 ReplaceNodeInfoPanel 整区替换为视觉显示框) -->
  700. <ContentControl x:Name="NodeInfoSlot" Grid.Row="0"
  701. HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
  702. <Border Background="{DynamicResource RegionBrush}">
  703. <DockPanel>
  704. <TextBlock DockPanel.Dock="Top" Text="{loc:Translate '节点信息'}" FontSize="13"
  705. FontWeight="Bold" Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,8,0,4"/>
  706. <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="120">
  707. <StackPanel Margin="10,2">
  708. <TextBlock Text="{loc:Translate '名称'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,4,0,1"/>
  709. <TextBlock Text="{Binding SelectedNode.NodeName}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}" TextTrimming="CharacterEllipsis"/>
  710. <Grid Margin="0,6,0,0">
  711. <Grid.ColumnDefinitions>
  712. <ColumnDefinition Width="*"/>
  713. <ColumnDefinition Width="*"/>
  714. </Grid.ColumnDefinitions>
  715. <StackPanel Grid.Column="0">
  716. <TextBlock Text="{loc:Translate '类型'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,1"/>
  717. <TextBlock Text="{Binding SelectedNode.Category}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
  718. </StackPanel>
  719. <StackPanel Grid.Column="1">
  720. <TextBlock Text="{loc:Translate '状态'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,1"/>
  721. <StackPanel Orientation="Horizontal">
  722. <Ellipse Width="8" Height="8" Fill="{Binding SelectedNode.StatusColor}" Margin="0,0,4,0"/>
  723. <TextBlock Text="{Binding SelectedNode.StatusText}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
  724. </StackPanel>
  725. </StackPanel>
  726. </Grid>
  727. <TextBlock Text="{loc:Translate '耗时'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,6,0,1"/>
  728. <TextBlock Text="{Binding SelectedNode.CostTimeText}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
  729. </StackPanel>
  730. </ScrollViewer>
  731. </DockPanel>
  732. </Border>
  733. </ContentControl>
  734. <!-- 分割线1 -->
  735. <GridSplitter Grid.Row="1"
  736. Height="4" HorizontalAlignment="Stretch" ResizeDirection="Rows"
  737. Background="{DynamicResource BorderBrush}"
  738. ResizeBehavior="PreviousAndNext"/>
  739. <!-- 中: 执行历史 -->
  740. <Border Grid.Row="2" MaxHeight="160"
  741. Background="{DynamicResource RegionBrush}">
  742. <DockPanel>
  743. <TextBlock DockPanel.Dock="Top" Text="{loc:Translate '执行历史'}" FontSize="13"
  744. FontWeight="Bold" Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,6,0,2"/>
  745. <ListBox ItemsSource="{Binding SelectedNode.ExecutionHistory}"
  746. SelectedItem="{Binding SelectedNode.SelectedHistoryEntry}"
  747. BorderThickness="0"
  748. Background="{DynamicResource RegionBrush}"
  749. Margin="6,0,6,6"
  750. FontSize="11"
  751. ItemContainerStyle="{StaticResource HistoryListItemStyle}"
  752. MaxHeight="120">
  753. <ListBox.ItemTemplate>
  754. <DataTemplate>
  755. <StackPanel Orientation="Horizontal" Margin="4,2">
  756. <TextBlock Text="🕐" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,6,0"/>
  757. <TextBlock Text="{Binding TimestampText}" Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
  758. </StackPanel>
  759. </DataTemplate>
  760. </ListBox.ItemTemplate>
  761. </ListBox>
  762. </DockPanel>
  763. </Border>
  764. <!-- 分割线2 -->
  765. <GridSplitter Grid.Row="3"
  766. Height="4" HorizontalAlignment="Stretch" ResizeDirection="Rows"
  767. Background="{DynamicResource BorderBrush}"
  768. ResizeBehavior="PreviousAndNext"/>
  769. <!-- 下: 执行结果表格 -->
  770. <Border Grid.Row="4"
  771. Background="{DynamicResource RegionBrush}">
  772. <DockPanel>
  773. <DockPanel DockPanel.Dock="Top" Margin="10,6,10,4">
  774. <TextBlock Text="{loc:Translate '执行结果'}" FontSize="13" FontWeight="Bold"
  775. Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
  776. <TextBlock Text="{loc:Translate '选中单元格按 Ctrl+C 复制'}" FontSize="10"
  777. Foreground="{DynamicResource SecondaryTextBrush}"
  778. VerticalAlignment="Center" Margin="12,0,0,0"/>
  779. </DockPanel>
  780. <DataGrid Style="{StaticResource DataGrid.Small}" ItemsSource="{Binding SelectedNode.SelectedHistoryEntry.Results}"
  781. AutoGenerateColumns="False"
  782. HeadersVisibility="Column"
  783. IsReadOnly="True"
  784. GridLinesVisibility="Horizontal"
  785. CanUserAddRows="False"
  786. CanUserDeleteRows="False"
  787. CanUserResizeColumns="True"
  788. CanUserSortColumns ="False"
  789. SelectionMode="Single"
  790. SelectionUnit="Cell"
  791. ClipboardCopyMode="ExcludeHeader"
  792. BorderThickness="0"
  793. Background="{DynamicResource RegionBrush}"
  794. RowBackground="{DynamicResource RegionBrush}"
  795. AlternatingRowBackground="{DynamicResource SecondaryRegionBrush}"
  796. ColumnHeaderHeight="26"
  797. RowHeight="26"
  798. FontSize="12"
  799. Margin="6,0,6,4">
  800. <DataGrid.Columns>
  801. <DataGridTextColumn Header="{loc:Translate '键'}" Binding="{Binding Key}" Width="*"/>
  802. <DataGridTemplateColumn Header="{loc:Translate '值'}" Width="3*">
  803. <DataGridTemplateColumn.CellTemplate>
  804. <DataTemplate>
  805. <Grid>
  806. <TextBlock x:Name="SimpleValue" Text="{Binding DisplayValue}" VerticalAlignment="Center"/>
  807. <ItemsControl x:Name="ComplexValue" ItemsSource="{Binding SubItems}" Visibility="Collapsed">
  808. <ItemsControl.ItemTemplate>
  809. <DataTemplate>
  810. <StackPanel Orientation="Horizontal" Margin="2,1">
  811. <TextBlock Text="{Binding Key}" FontWeight="SemiBold" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}"/>
  812. <TextBlock Text=": " FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}"/>
  813. <TextBlock Text="{Binding DisplayValue}" FontSize="11" Foreground="{DynamicResource PrimaryTextBrush}"/>
  814. </StackPanel>
  815. </DataTemplate>
  816. </ItemsControl.ItemTemplate>
  817. </ItemsControl>
  818. </Grid>
  819. <DataTemplate.Triggers>
  820. <DataTrigger Binding="{Binding IsComplex}" Value="True">
  821. <Setter TargetName="SimpleValue" Property="Visibility" Value="Collapsed"/>
  822. <Setter TargetName="ComplexValue" Property="Visibility" Value="Visible"/>
  823. </DataTrigger>
  824. </DataTemplate.Triggers>
  825. </DataTemplate>
  826. </DataGridTemplateColumn.CellTemplate>
  827. </DataGridTemplateColumn>
  828. <DataGridTextColumn Header="{loc:Translate '类型'}" Binding="{Binding TypeName}" Width="*"/>
  829. </DataGrid.Columns>
  830. </DataGrid>
  831. </DockPanel>
  832. </Border>
  833. </Grid>
  834. </Grid>
  835. </Grid>
  836. </UserControl>