| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867 |
- <UserControl x:Class="TeamAAS.FlowEditor.FlowEditorView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:loc="clr-namespace:TeamAAS.Localization;assembly=TeamAAS.Global"
- xmlns:hc="https://handyorg.github.io/handycontrol"
- xmlns:fe="clr-namespace:TeamAAS.FlowEditor.Controls"
- xmlns:conv="clr-namespace:TeamAAS.FlowEditor.Converters"
- xmlns:ip="clr-namespace:MahApps.Metro.IconPacks;assembly=MahApps.Metro.IconPacks.Material"
- xmlns:g="clr-namespace:TeamAAS;assembly=TeamAAS.Global">
- <UserControl.Resources>
- <!-- bool 取反:只读模式禁用编辑按钮 -->
- <conv:InverseBoolConverter x:Key="InverseBoolConverter"/>
- <!-- 图标 Kind 名 → PackIconMaterialKind -->
- <g:IconKindConverter x:Key="IconKind"/>
- <!-- 画布网格背景(透明底 + 浅灰网格线,叠加在 SecondaryBorderBrush 上) -->
- <DrawingBrush x:Key="GridBrush" TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
- <DrawingBrush.Drawing>
- <DrawingGroup>
- <GeometryDrawing Geometry="M0,0 L20,0 M0,0 L0,20">
- <GeometryDrawing.Pen>
- <Pen Brush="{DynamicResource SecondaryBorderBrush}" Thickness="0.5"/>
- </GeometryDrawing.Pen>
- </GeometryDrawing>
- </DrawingGroup>
- </DrawingBrush.Drawing>
- </DrawingBrush>
- <!-- MoveThumb 透明模板 -->
- <Style TargetType="{x:Type fe:MoveThumb}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type fe:MoveThumb}">
- <Rectangle Fill="Transparent"/>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- 画布垂直滚动条:扁平细滑块,颜色跟随主题(悬停变强调色) -->
- <Style x:Key="CanvasVScrollBar" TargetType="ScrollBar">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ScrollBar">
- <Grid Background="Transparent">
- <Track x:Name="PART_Track" IsDirectionReversed="True">
- <Track.DecreaseRepeatButton>
- <RepeatButton Command="ScrollBar.PageUpCommand" Opacity="0" Focusable="False"/>
- </Track.DecreaseRepeatButton>
- <Track.IncreaseRepeatButton>
- <RepeatButton Command="ScrollBar.PageDownCommand" Opacity="0" Focusable="False"/>
- </Track.IncreaseRepeatButton>
- <Track.Thumb>
- <Thumb>
- <Thumb.Template>
- <ControlTemplate TargetType="Thumb">
- <Border x:Name="ThumbBorder" Margin="4,1" CornerRadius="3" MinHeight="28"
- Background="{DynamicResource BorderBrush}"/>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Thumb.Template>
- </Thumb>
- </Track.Thumb>
- </Track>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- 画布水平滚动条:同上(横向) -->
- <Style x:Key="CanvasHScrollBar" TargetType="ScrollBar">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ScrollBar">
- <Grid Background="Transparent">
- <Track x:Name="PART_Track">
- <Track.DecreaseRepeatButton>
- <RepeatButton Command="ScrollBar.PageLeftCommand" Opacity="0" Focusable="False"/>
- </Track.DecreaseRepeatButton>
- <Track.IncreaseRepeatButton>
- <RepeatButton Command="ScrollBar.PageRightCommand" Opacity="0" Focusable="False"/>
- </Track.IncreaseRepeatButton>
- <Track.Thumb>
- <Thumb>
- <Thumb.Template>
- <ControlTemplate TargetType="Thumb">
- <Border x:Name="ThumbBorder" Margin="1,4" CornerRadius="3" MinWidth="28"
- Background="{DynamicResource BorderBrush}"/>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Thumb.Template>
- </Thumb>
- </Track.Thumb>
- </Track>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- 执行历史列表项样式 -->
- <Style x:Key="HistoryListItemStyle" TargetType="ListBoxItem">
- <Setter Property="Padding" Value="6,2"/>
- <Setter Property="Margin" Value="0,1"/>
- <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ListBoxItem">
- <Border x:Name="Bd" Background="Transparent" CornerRadius="3" Padding="{TemplateBinding Padding}">
- <ContentPresenter/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsSelected" Value="True">
- <Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
- <Setter Property="TextElement.Foreground" Value="White"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- ConnectorControl 连接点样式 -->
- <Style TargetType="{x:Type fe:ConnectorControl}">
- <Setter Property="Width" Value="14"/>
- <Setter Property="Height" Value="14"/>
- <Setter Property="Cursor" Value="Cross"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type fe:ConnectorControl}">
- <Grid Width="14" Height="14">
- <Ellipse Fill="Transparent" Margin="-8"/>
- <Ellipse Width="10" Height="10"
- Fill="{DynamicResource PrimaryBrush}"
- Stroke="#FFFFFF" StrokeThickness="1.5"/>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- NodeControl 节点样式 -->
- <Style TargetType="{x:Type fe:NodeControl}">
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="HorizontalAlignment" Value="Left"/>
- <Setter Property="VerticalAlignment" Value="Top"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type fe:NodeControl}">
- <Grid >
- <!-- ========== 矩形节点(Normal/ToolBlock) ========== -->
- <Border x:Name="RectNode" CornerRadius="4"
- BorderBrush="{DynamicResource PrimaryBrush}"
- BorderThickness="2"
- Background="{DynamicResource RegionBrush}"
- MinHeight="40"
- ClipToBounds="True">
- <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
- <!-- 左侧色条 + 图标 -->
- <Border x:Name="RectLeftBar" Background="{DynamicResource PrimaryBrush}"
- CornerRadius="3,0,0,3" Width="32">
- <ip:PackIconMaterial Width="16" Height="16"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"/>
- </Border>
- <!-- 中间:名称 + 耗时 -->
- <StackPanel VerticalAlignment="Center" Margin="8,0,8,0" MinWidth="100" >
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="15"
- FontFamily="Microsoft YaHei"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- MinWidth="35"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
- Margin="8,0,0,0"
- VerticalAlignment="Center"/>
- </StackPanel>
- </StackPanel>
- <!-- 右侧色条 + 状态圆 -->
- <Border x:Name="RectRightBar" Background="{DynamicResource PrimaryBrush}"
- CornerRadius="0,3,3,0" Width="20">
- <Ellipse Width="10" Height="10"
- Fill="{Binding StatusColor}"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"/>
- </Border>
- </StackPanel>
- </Border>
- <!-- ========== 循环节点(ForLoop) ========== -->
- <Border x:Name="LoopNode" Visibility="Collapsed"
- MinWidth="200" MinHeight="35"
- CornerRadius="4"
- BorderBrush="{DynamicResource DarkInfoBrush}"
- BorderThickness="0"
- Background="{DynamicResource RegionBrush}"
- ClipToBounds="True">
- <StackPanel Background="{DynamicResource RegionBrush}">
- <!-- 头部色条 -->
- <Border Background="{DynamicResource DarkInfoBrush}"
- CornerRadius="3,3,0,0" Padding="8,4">
- <TextBlock Text="{loc:Translate '循环'}" Foreground="White"
- FontSize="11" FontWeight="Bold"
- HorizontalAlignment="Center"
- FontFamily="Microsoft YaHei"/>
- </Border>
- <!-- 内容 -->
- <StackPanel Orientation="Horizontal" Margin="8,6,6,6">
- <ip:PackIconMaterial Width="14" Height="14"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
- Foreground="{DynamicResource DarkInfoBrush}"
- VerticalAlignment="Center"/>
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="13"
- FontFamily="Microsoft YaHei"
- Margin="6,0,0,0"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
- Margin="8,0,0,0"
- VerticalAlignment="Center"/>
- </StackPanel>
- </StackPanel>
- </Border>
- <!-- ========== 组合节点(Group)- 堆叠效果 ========== -->
- <Grid x:Name="GroupNode" Visibility="Collapsed" MinWidth="150" MinHeight="40" >
- <!-- 底层堆叠2(最远) -->
- <Border CornerRadius="4" BorderThickness="1.5"
- BorderBrush="{DynamicResource PrimaryBrush}" Background="{DynamicResource PrimaryBrush}"
- Margin="6,6,-6,-6" Opacity="0.3"/>
- <!-- 底层堆叠1 -->
- <Border CornerRadius="4" BorderThickness="1.5"
- BorderBrush="{DynamicResource PrimaryBrush}" Background="{DynamicResource PrimaryBrush}"
- Margin="3,3,-3,-3" Opacity="0.5"/>
- <!-- 主区块 -->
- <Border x:Name="GroupMainBorder" CornerRadius="4" BorderThickness="2"
- BorderBrush="{DynamicResource PrimaryBrush}"
- Background="{DynamicResource RegionBrush}"
- ClipToBounds="True">
- <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
- <Border Background="{DynamicResource PrimaryBrush}" CornerRadius="3,0,0,3" Width="32">
- <ip:PackIconMaterial Width="16" Height="16"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <StackPanel VerticalAlignment="Center" Margin="8,0,16,0" MinWidth="100" >
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="13" FontFamily="Microsoft YaHei"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- MinWidth="20"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
- Margin="8,0,0,0" VerticalAlignment="Center"/>
- </StackPanel>
- <TextBlock Text="{loc:Translate '组合模块'}" FontSize="10"
- Foreground="{DynamicResource SecondaryTextBrush}"
- Margin="0,2,0,0"/>
- </StackPanel>
- <Border Background="{DynamicResource PrimaryBrush}" CornerRadius="0,3,3,0" Width="20">
- <Ellipse Width="10" Height="10" Fill="{Binding StatusColor}"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- </StackPanel>
- </Border>
- </Grid>
- <!-- ========== 结束节点(End)- 圆角胶囊形 ========== -->
- <Grid x:Name="EndNode" Visibility="Collapsed">
- <Border x:Name="EndMainBorder" CornerRadius="26" BorderThickness="2"
- BorderBrush="#D32F2F"
- Background="{DynamicResource RegionBrush}"
- MinWidth="140" MinHeight="50">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
- <ip:PackIconMaterial Width="14" Height="14"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="#D32F2F"
- VerticalAlignment="Center"/>
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="13" FontFamily="Microsoft YaHei"
- Margin="6,0,0,0" VerticalAlignment="Center"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
- Margin="8,0,0,0" VerticalAlignment="Center"/>
- </StackPanel>
- </Border>
- </Grid>
- <!-- ========== 菱形节点(Decision) ========== -->
- <Grid x:Name="DiamondNode" Visibility="Collapsed"
- Width="180" Height="50">
- <Path x:Name="DiamondPath"
- Data="M0.12,0 L0.88,0 L1,0.5 L0.88,1 L0.12,1 L0,0.5 Z"
- Stretch="Fill"
- Fill="{DynamicResource RegionBrush}"
- Stroke="{DynamicResource DarkWarningBrush}"
- StrokeThickness="1.5"/>
- <StackPanel HorizontalAlignment="Center"
- VerticalAlignment="Center"
- Margin="30,4">
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="12"
- FontFamily="Microsoft YaHei"
- HorizontalAlignment="Center"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="10"
- HorizontalAlignment="Center"
- Margin="0,2,0,0"/>
- </StackPanel>
- </Grid>
- <!-- ========== 异常分支节点(ExceptionBranch)- 深红矩形 + 警告色条 ========== -->
- <Border x:Name="ExceptionBranchNode" Visibility="Collapsed"
- CornerRadius="4"
- BorderBrush="#B71C1C"
- BorderThickness="2"
- Background="{DynamicResource RegionBrush}"
- MinHeight="40"
- ClipToBounds="True">
- <StackPanel Orientation="Horizontal" Background="{DynamicResource RegionBrush}">
- <Border Background="#B71C1C" CornerRadius="3,0,0,3" Width="32">
- <ip:PackIconMaterial Width="16" Height="16"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}" Foreground="White"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <StackPanel VerticalAlignment="Center" Margin="8,0,8,0" MinWidth="100">
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding NodeName}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- FontSize="15" FontFamily="Microsoft YaHei"
- TextTrimming="CharacterEllipsis"/>
- <TextBlock Text="{Binding CostTimeText}"
- MinWidth="20"
- Foreground="{DynamicResource SecondaryTextBrush}" FontSize="11"
- Margin="8,0,0,0" VerticalAlignment="Center"/>
- </StackPanel>
- <TextBlock Text="{loc:Translate '异常分支'}" FontSize="10"
- Foreground="#B71C1C"
- Margin="0,2,0,0"/>
- </StackPanel>
- <Border Background="#B71C1C" CornerRadius="0,3,3,0" Width="20">
- <Ellipse Width="10" Height="10" Fill="{Binding StatusColor}"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- </StackPanel>
- </Border>
- <!-- 拖拽手柄 -->
- <fe:MoveThumb Cursor="Hand" Panel.ZIndex="1"/>
- <!-- 连接点容器(常驻可见,悬停高亮) -->
- <Grid x:Name="ConnectorContainer"
- Opacity="0" Panel.ZIndex="2">
- <!-- 左 -->
- <fe:ConnectorControl PortIndex="0" Side="Left"
- VerticalAlignment="Center"
- HorizontalAlignment="Left"
- Margin="-7,0,0,0"/>
- <!-- 右 -->
- <fe:ConnectorControl PortIndex="1" Side="Right"
- VerticalAlignment="Center"
- HorizontalAlignment="Right"
- Margin="0,0,-7,0"/>
- <!-- 上 -->
- <fe:ConnectorControl PortIndex="2" Side="Top"
- VerticalAlignment="Top"
- HorizontalAlignment="Center"
- Margin="0,-7,0,0"/>
- <!-- 下 -->
- <fe:ConnectorControl PortIndex="3" Side="Bottom"
- VerticalAlignment="Bottom"
- HorizontalAlignment="Center"
- Margin="0,0,0,-7"/>
- </Grid>
- </Grid>
- <ControlTemplate.Triggers>
- <!-- 悬停:高亮连接点 -->
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="ConnectorContainer" Property="Opacity" Value="1"/>
- <Setter TargetName="RectNode" Property="BorderThickness" Value="2"/>
- <Setter TargetName="LoopNode" Property="BorderThickness" Value="2"/>
- <Setter TargetName="DiamondPath" Property="StrokeThickness" Value="2.5"/>
- </Trigger>
- <!-- 选中:加粗边框 + 显示连接点 -->
- <DataTrigger Binding="{Binding IsSelected}" Value="True">
- <Setter TargetName="RectNode" Property="BorderThickness" Value="2.5"/>
- <Setter TargetName="LoopNode" Property="BorderThickness" Value="2.5"/>
- <Setter TargetName="DiamondPath" Property="StrokeThickness" Value="3"/>
- <Setter TargetName="ConnectorContainer" Property="Opacity" Value="1"/>
- </DataTrigger>
- <!-- Decision → 菱形 -->
- <DataTrigger Binding="{Binding Category}" Value="Decision">
- <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="DiamondNode" Property="Visibility" Value="Visible"/>
- <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
- </DataTrigger>
- <!-- ForLoop → 循环头 -->
- <DataTrigger Binding="{Binding Category}" Value="ForLoop">
- <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="LoopNode" Property="Visibility" Value="Visible"/>
- <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
- </DataTrigger>
- <!-- Group → 组合模块(堆叠) -->
- <DataTrigger Binding="{Binding Category}" Value="Group">
- <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="GroupNode" Property="Visibility" Value="Visible"/>
- <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
- </DataTrigger>
- <!-- End → 结束节点(胶囊形) -->
- <DataTrigger Binding="{Binding Category}" Value="End">
- <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="EndNode" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- <DataTrigger Binding="{Binding Category}" Value="ExceptionBranch">
- <Setter TargetName="RectNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="LoopNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="DiamondNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="GroupNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="EndNode" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="ExceptionBranchNode" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- 工具箱项样式 -->
- <Style x:Key="ToolboxItem" TargetType="Border">
- <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
- <Setter Property="CornerRadius" Value="4"/>
- <Setter Property="Padding" Value="8,6"/>
- <Setter Property="Margin" Value="0,0,0,2"/>
- <Setter Property="Cursor" Value="Hand"/>
- <Style.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
- </Trigger>
- </Style.Triggers>
- </Style>
- </UserControl.Resources>
- <Grid Background="{DynamicResource SecondaryBorderBrush}">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="6"/>
- <ColumnDefinition Width="320" MinWidth="320"/>
- </Grid.ColumnDefinitions>
- <!-- 顶部工具栏 -->
- <Border Grid.Row="0" Grid.ColumnSpan="4" Height="46"
- Background="{DynamicResource RegionBrush}"
- BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,0,1">
- <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="8,0">
- <TextBlock Text="{loc:Translate '流程编辑'}" FontSize="14" FontWeight="Bold"
- Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center" Margin="0,0,16,0"/>
- <Button Content="+" Width="40" Height="32" FontSize="14" Click="ZoomIn_Click" ToolTip="{loc:Translate '放大'}" Tag="{loc:Translate '放大画布视图'}"/>
- <Button Content="−" Width="40" Height="32" FontSize="14" Click="ZoomOut_Click" ToolTip="{loc:Translate '缩小'}" Margin="2,0" Tag="{loc:Translate '缩小画布视图'}"/>
- <TextBlock x:Name="TxtZoom" Text="100%" FontSize="12"
- Foreground="{DynamicResource SecondaryTextBrush}" VerticalAlignment="Center" Margin="8,0"/>
- <Button Content="{loc:Translate '适应内容'}" Width="auto" Height="32" FontSize="14" Click="FitView_Click" ToolTip="{loc:Translate '缩放至所有节点可见'}" Tag="{loc:Translate '自动缩放至所有节点可见'}"/>
- <Separator Margin="8,4"/>
- <Button Content="{loc:Translate '导入'}" Width="auto" Height="32" FontSize="14" Command="{Binding ImportFlowCommand}"
- IsEnabled="{Binding IsReadOnly, Converter={StaticResource InverseBoolConverter}}"
- ToolTip="{loc:Translate '从文件导入流程'}" Tag="{loc:Translate '从 .aas 文件导入流程节点与连线'}"/>
- <Button Content="{loc:Translate '导出'}" Width="auto" Height="32" FontSize="14" Command="{Binding ExportFlowCommand}" ToolTip="{loc:Translate '导出当前流程到文件'}" Margin="2,0" Tag="{loc:Translate '导出当前流程到 .aas 文件'}"/>
- <Separator Margin="8,4"/>
- <Button x:Name="BtnRun" Content="{loc:Translate '▶ 运行'}" Width="auto" Height="32" FontSize="14" Click="RunFlow_Click" ToolTip="{loc:Translate '运行流程'}" Tag="{loc:Translate '从头开始运行当前流程,节点状态实时显示在画布上'}"/>
- <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 '停止当前正在运行的流程'}"/>
- </StackPanel>
- </Border>
- <!-- 左: 工具箱(独立面板,可折叠) -->
- <Border x:Name="ToolboxPanel" Grid.Row="1" Grid.Column="0" Width="56" MaxWidth="220"
- ClipToBounds="True"
- Background="{DynamicResource RegionBrush}"
- BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,1,0">
- <Grid>
- <!-- EXPANDED: 完整工具箱 -->
- <DockPanel x:Name="ToolboxExpanded" Opacity="0" Visibility="Hidden">
- <!-- 顶部:折叠按钮 + 标题 -->
- <DockPanel DockPanel.Dock="Top" Margin="8,8,8,6">
- <Button x:Name="BtnToolboxToggleExpanded" DockPanel.Dock="Right" Content="◀" FontSize="11"
- Click="BtnToolboxToggle_Click" ToolTip="{loc:Translate '折叠工具箱'}"
- Background="Transparent" BorderThickness="1"
- Foreground="{DynamicResource SecondaryTextBrush}"
- BorderBrush="{DynamicResource BorderBrush}"
- Cursor="Hand"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- <TextBlock Text="{loc:Translate '节点工具箱'}" FontSize="13" FontWeight="Bold"
- Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
- </DockPanel>
- <Separator Background="{DynamicResource BorderBrush}"/>
- <ScrollViewer VerticalScrollBarVisibility="Auto">
- <ItemsControl ItemsSource="{Binding ToolboxGroups}" Margin="4,4">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Expander Header="{Binding GroupName}" IsExpanded="True"
- FontSize="11" FontWeight="Bold"
- Foreground="{DynamicResource SecondaryTextBrush}"
- Margin="2,2" Padding="4,2">
- <ItemsControl ItemsSource="{Binding Items}">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Border Style="{StaticResource ToolboxItem}"
- MouseLeftButtonDown="ToolboxItem_MouseLeftButtonDown"
- MouseMove="ToolboxItem_MouseMove">
- <StackPanel Orientation="Horizontal">
- <ip:PackIconMaterial Width="14" Height="14"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- VerticalAlignment="Center"/>
- <StackPanel Margin="8,0,0,0">
- <TextBlock Text="{Binding DisplayName}"
- FontSize="12"
- Foreground="{DynamicResource PrimaryTextBrush}"/>
- <TextBlock Text="{Binding Description}"
- FontSize="10"
- Foreground="{DynamicResource SecondaryTextBrush}"
- TextTrimming="CharacterEllipsis"/>
- </StackPanel>
- </StackPanel>
- </Border>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </Expander>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </DockPanel>
- <!-- COLLAPSED: 仅类型图标,Hover 弹 Popup -->
- <DockPanel x:Name="ToolboxCollapsed" Opacity="1.0" Visibility="Visible">
- <!-- 顶部:展开按钮 -->
- <Border DockPanel.Dock="Top" Margin="0,4,0,4">
- <Button x:Name="BtnToolboxToggleCollapsed" Content="▶" Width="40" Height="32" FontSize="14"
- Click="BtnToolboxToggle_Click" ToolTip="{loc:Translate '展开工具箱'}"
- Background="Transparent" BorderThickness="0"
- Foreground="{DynamicResource SecondaryTextBrush}" Cursor="Hand"
- HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <Separator Background="{DynamicResource BorderBrush}"/>
- <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
- <ItemsControl x:Name="CollapsedGroups" ItemsSource="{Binding ToolboxGroups}" Margin="4,4">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Border Width="44" Height="44" Margin="2"
- Style="{StaticResource ToolboxItem}"
- MouseEnter="GroupTag_MouseEnter"
- MouseLeave="GroupTag_MouseLeave">
- <ip:PackIconMaterial Width="20" Height="20"
- Kind="{Binding GroupIcon, Converter={StaticResource IconKind}}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- HorizontalAlignment="Center" VerticalAlignment="Center"
- ToolTip="{Binding GroupName}"/>
- </Border>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </DockPanel>
- </Grid>
- </Border>
- <!-- Popup: 折叠模式下 Hover 弹出类型下的工具列表 -->
- <Popup x:Name="ToolboxGroupPopup" AllowsTransparency="True"
- PopupAnimation="Slide" Placement="Right"
- PlacementTarget="{Binding ElementName=ToolboxPanel}">
- <Border Width="200" Background="{DynamicResource RegionBrush}"
- BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
- Margin="4,0,0,0">
- <DockPanel MouseEnter="ToolboxGroupPopup_MouseEnter"
- MouseLeave="ToolboxGroupPopup_MouseLeave">
- <TextBlock DockPanel.Dock="Top" x:Name="PopupGroupName" FontSize="13" FontWeight="Bold"
- Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,8,0,4"/>
- <Separator Background="{DynamicResource BorderBrush}"/>
- <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="320">
- <ItemsControl x:Name="PopupItems" Margin="4,4">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Border Style="{StaticResource ToolboxItem}"
- MouseLeftButtonDown="ToolboxItem_MouseLeftButtonDown"
- MouseMove="ToolboxItem_MouseMove">
- <StackPanel Orientation="Horizontal">
- <ip:PackIconMaterial Width="14" Height="14"
- Kind="{Binding IconGeometry, Converter={StaticResource IconKind}}"
- Foreground="{DynamicResource PrimaryTextBrush}"
- VerticalAlignment="Center"/>
- <StackPanel Margin="8,0,0,0">
- <TextBlock Text="{Binding DisplayName}" FontSize="12"
- Foreground="{DynamicResource PrimaryTextBrush}"/>
- <TextBlock Text="{Binding Description}" FontSize="10"
- Foreground="{DynamicResource SecondaryTextBrush}"
- TextTrimming="CharacterEllipsis"/>
- </StackPanel>
- </StackPanel>
- </Border>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </DockPanel>
- </Border>
- </Popup>
- <!-- 中: 画布 + 滚动条 + 鸟瞰图 -->
- <Grid Grid.Row="1" Grid.Column="1" Background="{DynamicResource SecondaryRegionBrush}" ClipToBounds="True">
- <fe:FlowCanvas x:Name="EditorCanvas"
- Background="{StaticResource GridBrush}"
- ClipToBounds="True"
- IsRunning="{Binding IsRunning}">
- <!-- 工具箱拖拽预览节点:画布子元素,用 Canvas.Left/Top(画布内容坐标)定位,
- 与落点/节点同一坐标系,随画布缩放平移;不经过 adorner/窗口坐标换算,
- 高 DPI(PerMonitorV2)下不会错位 -->
- <Border x:Name="DragPreviewNode"
- Visibility="Collapsed"
- IsHitTestVisible="False"
- Panel.ZIndex="100000"
- Background="{DynamicResource PrimaryBrush}"
- CornerRadius="6"
- Padding="10,6,12,6"
- Width="160" Height="42">
- <StackPanel Orientation="Horizontal">
- <ip:PackIconMaterial x:Name="DragPreviewIcon" Width="14" Height="14"
- Foreground="White" VerticalAlignment="Center" Margin="0,0,8,0"/>
- <TextBlock x:Name="DragPreviewText" Foreground="White" FontSize="13"
- FontWeight="Medium" VerticalAlignment="Center"/>
- </StackPanel>
- </Border>
- </fe:FlowCanvas>
- <ScrollBar x:Name="VScrollBar" Orientation="Vertical"
- Style="{StaticResource CanvasVScrollBar}"
- HorizontalAlignment="Right" Width="16"
- SmallChange="20" LargeChange="200"
- Scroll="VScrollBar_Scroll"/>
- <ScrollBar x:Name="HScrollBar" Orientation="Horizontal"
- Style="{StaticResource CanvasHScrollBar}"
- VerticalAlignment="Bottom" Height="16"
- SmallChange="20" LargeChange="200"
- Scroll="HScrollBar_Scroll"/>
- <fe:MinimapControl x:Name="Minimap"
- Width="200" Height="140"
- HorizontalAlignment="Right"
- VerticalAlignment="Bottom"
- Margin="0,0,20,20"
- Canvas="{Binding ElementName=EditorCanvas}"/>
- <!-- 加载动画(导入流程时显示转圈) -->
- <Border x:Name="LoadingOverlay"
- Visibility="Collapsed"
- Background="#66000000"
- IsHitTestVisible="False"
- Panel.ZIndex="1000">
- <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
- <ProgressBar IsIndeterminate="True" Width="120" Height="8"/>
- <TextBlock Text="{loc:Translate '加载中...'}" HorizontalAlignment="Center" Margin="0,10,0,0"
- Foreground="{DynamicResource PrimaryTextBrush}"/>
- </StackPanel>
- </Border>
- </Grid>
- <!-- 垂直分割线(可拖拽调节左右) -->
- <GridSplitter Grid.Row="1" Grid.Column="2"
- Width="6" HorizontalAlignment="Stretch" ResizeDirection="Columns"
- Background="{DynamicResource BorderBrush}"
- ResizeBehavior="PreviousAndNext"/>
- <!-- 右: 属性面板 -->
- <Grid Grid.Row="1" Grid.Column="3" Background="{DynamicResource BorderBrush}">
- <Grid.RowDefinitions>
- <!-- 顶部可选插槽:默认折叠,主流程/组合模块不受影响;HALCON 子流程编辑器在此注入显示窗体(位于“节点信息”上面) -->
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <ContentControl x:Name="RightTopSlot" Grid.Row="0" Visibility="Collapsed"/>
- <Grid Grid.Row="1">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="4"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="4"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <!-- 上: 节点信息(默认内容;平台子流程编辑器可经 ReplaceNodeInfoPanel 整区替换为视觉显示框) -->
- <ContentControl x:Name="NodeInfoSlot" Grid.Row="0"
- HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
- <Border Background="{DynamicResource RegionBrush}">
- <DockPanel>
- <TextBlock DockPanel.Dock="Top" Text="{loc:Translate '节点信息'}" FontSize="13"
- FontWeight="Bold" Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,8,0,4"/>
- <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="120">
- <StackPanel Margin="10,2">
- <TextBlock Text="{loc:Translate '名称'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,4,0,1"/>
- <TextBlock Text="{Binding SelectedNode.NodeName}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}" TextTrimming="CharacterEllipsis"/>
- <Grid Margin="0,6,0,0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="*"/>
- </Grid.ColumnDefinitions>
- <StackPanel Grid.Column="0">
- <TextBlock Text="{loc:Translate '类型'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,1"/>
- <TextBlock Text="{Binding SelectedNode.Category}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
- </StackPanel>
- <StackPanel Grid.Column="1">
- <TextBlock Text="{loc:Translate '状态'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,1"/>
- <StackPanel Orientation="Horizontal">
- <Ellipse Width="8" Height="8" Fill="{Binding SelectedNode.StatusColor}" Margin="0,0,4,0"/>
- <TextBlock Text="{Binding SelectedNode.StatusText}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
- </StackPanel>
- </StackPanel>
- </Grid>
- <TextBlock Text="{loc:Translate '耗时'}" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,6,0,1"/>
- <TextBlock Text="{Binding SelectedNode.CostTimeText}" FontSize="12" Foreground="{DynamicResource PrimaryTextBrush}"/>
- </StackPanel>
- </ScrollViewer>
- </DockPanel>
- </Border>
- </ContentControl>
- <!-- 分割线1 -->
- <GridSplitter Grid.Row="1"
- Height="4" HorizontalAlignment="Stretch" ResizeDirection="Rows"
- Background="{DynamicResource BorderBrush}"
- ResizeBehavior="PreviousAndNext"/>
- <!-- 中: 执行历史 -->
- <Border Grid.Row="2" MaxHeight="160"
- Background="{DynamicResource RegionBrush}">
- <DockPanel>
- <TextBlock DockPanel.Dock="Top" Text="{loc:Translate '执行历史'}" FontSize="13"
- FontWeight="Bold" Foreground="{DynamicResource PrimaryTextBrush}" Margin="10,6,0,2"/>
- <ListBox ItemsSource="{Binding SelectedNode.ExecutionHistory}"
- SelectedItem="{Binding SelectedNode.SelectedHistoryEntry}"
- BorderThickness="0"
- Background="{DynamicResource RegionBrush}"
- Margin="6,0,6,6"
- FontSize="11"
- ItemContainerStyle="{StaticResource HistoryListItemStyle}"
- MaxHeight="120">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal" Margin="4,2">
- <TextBlock Text="🕐" Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,6,0"/>
- <TextBlock Text="{Binding TimestampText}" Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
- </StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- </DockPanel>
- </Border>
- <!-- 分割线2 -->
- <GridSplitter Grid.Row="3"
- Height="4" HorizontalAlignment="Stretch" ResizeDirection="Rows"
- Background="{DynamicResource BorderBrush}"
- ResizeBehavior="PreviousAndNext"/>
- <!-- 下: 执行结果表格 -->
- <Border Grid.Row="4"
- Background="{DynamicResource RegionBrush}">
- <DockPanel>
- <DockPanel DockPanel.Dock="Top" Margin="10,6,10,4">
- <TextBlock Text="{loc:Translate '执行结果'}" FontSize="13" FontWeight="Bold"
- Foreground="{DynamicResource PrimaryTextBrush}" VerticalAlignment="Center"/>
- <TextBlock Text="{loc:Translate '选中单元格按 Ctrl+C 复制'}" FontSize="10"
- Foreground="{DynamicResource SecondaryTextBrush}"
- VerticalAlignment="Center" Margin="12,0,0,0"/>
- </DockPanel>
- <DataGrid Style="{StaticResource DataGrid.Small}" ItemsSource="{Binding SelectedNode.SelectedHistoryEntry.Results}"
- AutoGenerateColumns="False"
- HeadersVisibility="Column"
- IsReadOnly="True"
- GridLinesVisibility="Horizontal"
- CanUserAddRows="False"
- CanUserDeleteRows="False"
- CanUserResizeColumns="True"
- CanUserSortColumns ="False"
- SelectionMode="Single"
- SelectionUnit="Cell"
- ClipboardCopyMode="ExcludeHeader"
- BorderThickness="0"
- Background="{DynamicResource RegionBrush}"
- RowBackground="{DynamicResource RegionBrush}"
- AlternatingRowBackground="{DynamicResource SecondaryRegionBrush}"
- ColumnHeaderHeight="26"
- RowHeight="26"
- FontSize="12"
- Margin="6,0,6,4">
- <DataGrid.Columns>
- <DataGridTextColumn Header="{loc:Translate '键'}" Binding="{Binding Key}" Width="*"/>
- <DataGridTemplateColumn Header="{loc:Translate '值'}" Width="3*">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Grid>
- <TextBlock x:Name="SimpleValue" Text="{Binding DisplayValue}" VerticalAlignment="Center"/>
- <ItemsControl x:Name="ComplexValue" ItemsSource="{Binding SubItems}" Visibility="Collapsed">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal" Margin="2,1">
- <TextBlock Text="{Binding Key}" FontWeight="SemiBold" FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}"/>
- <TextBlock Text=": " FontSize="11" Foreground="{DynamicResource SecondaryTextBrush}"/>
- <TextBlock Text="{Binding DisplayValue}" FontSize="11" Foreground="{DynamicResource PrimaryTextBrush}"/>
- </StackPanel>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </Grid>
- <DataTemplate.Triggers>
- <DataTrigger Binding="{Binding IsComplex}" Value="True">
- <Setter TargetName="SimpleValue" Property="Visibility" Value="Collapsed"/>
- <Setter TargetName="ComplexValue" Property="Visibility" Value="Visible"/>
- </DataTrigger>
- </DataTemplate.Triggers>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTextColumn Header="{loc:Translate '类型'}" Binding="{Binding TypeName}" Width="*"/>
- </DataGrid.Columns>
- </DataGrid>
- </DockPanel>
- </Border>
- </Grid>
- </Grid>
- </Grid>
- </UserControl>
|