精简步骤参数布局并按触发方式显示有效设置
This commit is contained in:
parent
5d7fbaf869
commit
4cbe981db6
@ -896,9 +896,23 @@ public class ConditionNode : EditorNode
|
||||
public string Method
|
||||
{
|
||||
get { return _method; }
|
||||
set { SetProperty(ref _method, value); }
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _method, value)) return;
|
||||
RaisePropertyChanged(nameof(IsTimedTrigger));
|
||||
RaisePropertyChanged(nameof(IsMoveTrigger));
|
||||
RaisePropertyChanged(nameof(UsesTriggerRegion));
|
||||
RaisePropertyChanged(nameof(UsesHandTrigger));
|
||||
RaisePropertyChanged(nameof(UsesStableGate));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTimedTrigger => Method.Equals(ConditionMethod.TimeElapsed, StringComparison.OrdinalIgnoreCase);
|
||||
public bool IsMoveTrigger => Method.Equals(ConditionMethod.HandMove, StringComparison.OrdinalIgnoreCase);
|
||||
public bool UsesTriggerRegion => Method.ToLowerInvariant() is ConditionMethod.HandInRegion or ConditionMethod.HandLeaveRegion;
|
||||
public bool UsesHandTrigger => UsesTriggerRegion || IsMoveTrigger;
|
||||
public bool UsesStableGate => UsesTriggerRegion;
|
||||
|
||||
/// <summary>目标物体类别</summary>
|
||||
public string TargetObject
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui" xmlns:ed="clr-namespace:SopHelper.VVMs.RecipeEditor" xmlns:prism="http://prismlibrary.com/" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SopHelper.VVMs.RecipeEditor.RecipeEditor" prism:ViewModelLocator.AutoWireViewModel="True" Background="{StaticResource Bg}" xmlns:conv="using:Avalonia.Data.Converters" xmlns:training="clr-namespace:SopHelper.Training" xmlns:sop="clr-namespace:SopHelper.VVMs.SopPage">
|
||||
<UserControl xmlns="https://github.com/avaloniaui" xmlns:ed="clr-namespace:SopHelper.VVMs.RecipeEditor" xmlns:prism="http://prismlibrary.com/" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SopHelper.VVMs.RecipeEditor.RecipeEditor" prism:ViewModelLocator.AutoWireViewModel="True" Background="{StaticResource Bg}" xmlns:conv="using:Avalonia.Data.Converters" xmlns:training="clr-namespace:SopHelper.Training" xmlns:sop="clr-namespace:SopHelper.VVMs.SopPage">
|
||||
<UserControl.DataTemplates>
|
||||
<DataTemplate DataType="{x:Type ed:TextItem}">
|
||||
<Grid Classes="Row">
|
||||
@ -21,6 +21,13 @@
|
||||
</DataTemplate>
|
||||
</UserControl.DataTemplates>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="ScrollViewer.StepParameters TextBlock.Field">
|
||||
<Setter Property="Width" Value="NaN" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
<Style Selector="ScrollViewer.StepParameters TextBlock.Title">
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
</Style>
|
||||
<Style Selector="ScrollViewer.StepParameters ComboBox">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
@ -153,164 +160,124 @@
|
||||
ToolTip.Tip="将当前步骤已保存的整张关键帧发送给 dlite,以步骤说明为判据进行单图测试" />
|
||||
</StackPanel>
|
||||
<ScrollViewer x:Name="StepParameters" Classes="StepParameters" Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="步骤号" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Id, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="超时秒" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Timeout, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="步骤名" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Name, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="节拍毫秒" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding StandardDurationMs, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="说明" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" x:Name="StepDescriptionBox" Text="{Binding Description, Mode=TwoWay}" AcceptsReturn="True" TextWrapping="Wrap" MinHeight="64" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<TextBlock Text="AI 完成确认" Classes="Title" Margin="0,10,0,4" TextWrapping="Wrap" />
|
||||
<StackPanel Spacing="6">
|
||||
<CheckBox IsChecked="{Binding AiContinueAfterWindow, Mode=TwoWay}"><TextBlock Text="限时复检,到期未通过则跳过并继续后续步骤" TextWrapping="Wrap" /></CheckBox>
|
||||
<StackPanel IsVisible="{Binding AiContinueAfterWindow}" Spacing="6">
|
||||
<TextBlock Text="操作事件开启窗口;优先在手部停稳或离开后检查,窗口内用新画面重试。跳过记录为未通过。" TextWrapping="Wrap" />
|
||||
<StackPanel Spacing="6">
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="检查窗口(毫秒)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiCheckWindowMs, Mode=TwoWay}" Minimum="0" Maximum="60000" Increment="500" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Margin="0,0,4,4">
|
||||
<Grid ColumnDefinitions="64,8,*">
|
||||
<StackPanel Spacing="3">
|
||||
<TextBlock Text="步骤号" Classes="Field" />
|
||||
<TextBox Text="{Binding Id, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="判定模型:dlite;每次只送1张图,500ms硬截止(固定)" TextWrapping="Wrap" />
|
||||
<TextBlock IsVisible="{Binding UsesSequenceEvidence}" Text="此步骤仍是旧多图配置,不能在线运行。请通过Agent重新生成单帧可验证的步骤。" TextWrapping="Wrap" Foreground="OrangeRed" />
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="送检方式" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" x:Name="AiImageModePicker" ItemsSource="{Binding AiImageModes}" SelectedItem="{Binding AiImageMode, Mode=TwoWay, Converter={StaticResource SelectionConverter}}">
|
||||
<StackPanel Grid.Column="2" Spacing="3">
|
||||
<TextBlock Text="步骤名" Classes="Field" />
|
||||
<TextBox Text="{Binding Name, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<TextBlock Text="完成条件 / 步骤说明" Classes="Field" />
|
||||
<TextBox x:Name="StepDescriptionBox" Text="{Binding Description, Mode=TwoWay}" AcceptsReturn="True" TextWrapping="Wrap" MinHeight="64" />
|
||||
|
||||
<TextBlock Text="触发条件" Classes="Title" Margin="0,4,0,0" />
|
||||
<Grid ColumnDefinitions="76,*">
|
||||
<TextBlock Text="触发方式" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" x:Name="StepTriggerMethodPicker" ItemsSource="{Binding DataContext.Recipe.Methods, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Method, Mode=TwoWay, Converter={StaticResource SelectionConverter}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate><TextBlock Text="{Binding Converter={x:Static ed:ConditionMethodLabels.Converter}}" TextWrapping="Wrap" /></DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<Grid x:Name="TriggerRegionRow" ColumnDefinitions="76,*" IsVisible="{Binding Detection.UsesTriggerRegion}">
|
||||
<TextBlock Text="操作区域" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Region, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid x:Name="TriggerMoveRows" RowDefinitions="Auto,Auto" ColumnDefinitions="76,*" IsVisible="{Binding Detection.IsMoveTrigger}">
|
||||
<TextBlock Text="起点区域" Classes="Field" VerticalAlignment="Center" Margin="0,0,0,6" />
|
||||
<ComboBox Grid.Column="1" Margin="0,0,0,6" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.FromRegion, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
<TextBlock Grid.Row="1" Text="终点区域" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.ToRegion, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="76,*" IsVisible="{Binding Detection.UsesHandTrigger}">
|
||||
<TextBlock Text="检测手" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.Hands, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Hand, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,8,*" IsVisible="{Binding Detection.UsesHandTrigger}">
|
||||
<StackPanel Spacing="3">
|
||||
<TextBlock Text="区域容差 / px" Classes="Field" />
|
||||
<TextBox Text="{Binding Detection.Tolerance, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="3" x:Name="TriggerStableField" IsVisible="{Binding Detection.UsesStableGate}">
|
||||
<TextBlock Text="稳定帧数" Classes="Field" />
|
||||
<TextBox Text="{Binding Detection.StableFrames, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid x:Name="TriggerDurationRow" ColumnDefinitions="76,*" IsVisible="{Binding Detection.IsTimedTrigger}">
|
||||
<TextBlock Text="持续 / ms" Classes="Field" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Detection.DurationMs, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="AI 完成确认" Classes="Title" Margin="0,4,0,0" ToolTip.Tip="dlite 单图判定,单次固定500ms截止;以步骤说明为完成条件" />
|
||||
<TextBlock IsVisible="{Binding UsesSequenceEvidence}" Text="旧多图配置不可在线运行,请重新生成单帧步骤。" TextWrapping="Wrap" Foreground="OrangeRed" />
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<CheckBox Content="限时复检" IsChecked="{Binding AiContinueAfterWindow, Mode=TwoWay}" ToolTip.Tip="触发后限时检查;到期未通过则记为未通过并继续后续步骤" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiCheckWindowMs, Mode=TwoWay}" IsVisible="{Binding AiContinueAfterWindow}" Minimum="0" Maximum="60000" Increment="500" Margin="8,0,0,0" ToolTip.Tip="复检窗口 / 毫秒" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="76,*">
|
||||
<TextBlock Text="送检方式" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" x:Name="AiImageModePicker" ItemsSource="{Binding AiImageModes}" SelectedItem="{Binding AiImageMode, Mode=TwoWay, Converter={StaticResource SelectionConverter}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate><TextBlock Text="{Binding Converter={x:Static ed:VisionImageModeLabels.Converter}}" TextWrapping="Wrap" /></DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<StackPanel IsVisible="{Binding UsesFixedImageRegion}" Spacing="6">
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="固定送检区域" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" x:Name="AiImageRegionPicker" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding AiImageRegion, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel IsVisible="{Binding UsesHandImageRegion}" Spacing="6">
|
||||
<StackPanel Spacing="6">
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="向四周扩展(像素)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" x:Name="AiHandPaddingInput" Value="{Binding AiHandPadding, Mode=TwoWay}" Minimum="0" Maximum="4096" Increment="20" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="最小宽高(像素)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiHandMinSize, Mode=TwoWay}" Minimum="32" Maximum="8192" Increment="32" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="位置保留(毫秒)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiHandMemoryMs, Mode=TwoWay}" Minimum="1" Maximum="60000" Increment="500" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="76,*" IsVisible="{Binding UsesFixedImageRegion}">
|
||||
<TextBlock Text="送检区域" Classes="Field" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" x:Name="AiImageRegionPicker" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding AiImageRegion, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<StackPanel IsVisible="{Binding UsesHandImageRegion}" Spacing="6">
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<StackPanel Spacing="3">
|
||||
<TextBlock Text="扩边 / px" Classes="Field" />
|
||||
<NumericUpDown x:Name="AiHandPaddingInput" Value="{Binding AiHandPadding, Mode=TwoWay}" Minimum="0" Maximum="4096" Increment="20" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="3">
|
||||
<TextBlock Text="最小宽高 / px" Classes="Field" />
|
||||
<NumericUpDown Value="{Binding AiHandMinSize, Mode=TwoWay}" Minimum="32" Maximum="8192" Increment="32" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="76,*">
|
||||
<TextBlock Text="保留 / ms" Classes="Field" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiHandMemoryMs, Mode=TwoWay}" Minimum="1" Maximum="60000" Increment="500" ToolTip.Tip="手离开后保留最近位置的时间" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<StackPanel Spacing="3">
|
||||
<TextBlock Text="最低置信度" Classes="Field" />
|
||||
<NumericUpDown Value="{Binding AiMinConfidence, Mode=TwoWay}" Minimum="0" Maximum="1" Increment="0.05" FormatString="0.00" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="3">
|
||||
<TextBlock Text="重试间隔 / ms" Classes="Field" />
|
||||
<NumericUpDown Value="{Binding AiRetryDelayMs, Mode=TwoWay}" Minimum="0" Maximum="600000" Increment="50" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Expander x:Name="StepAdditionalSettings" Header="结束图、超时与违规" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="0,4,0,0">
|
||||
<StackPanel Spacing="6">
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="最低完成置信度(0–1)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiMinConfidence, Mode=TwoWay}" Minimum="0" Maximum="1" Increment="0.05" FormatString="0.00" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="重试间隔(毫秒)" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1" Value="{Binding AiRetryDelayMs, Mode=TwoWay}" Minimum="50" Maximum="600000" Increment="50" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6"><TextBlock Text="单次判定期限" VerticalAlignment="Center" TextWrapping="Wrap" Margin="0,0,8,0" /><TextBlock Grid.Column="1" Text="500毫秒(固定,不随配方放宽)" TextWrapping="Wrap" /></Grid>
|
||||
<CheckBox Content="保存结束图" IsChecked="{Binding SaveCompletionImage, Mode=TwoWay}" />
|
||||
<StackPanel IsEnabled="{Binding SaveCompletionImage}" Spacing="6">
|
||||
<TextBox x:Name="CompletionImageDirectoryBox" Text="{Binding CompletionImageDirectory, Mode=TwoWay}" PlaceholderText="默认:配方目录 / completion-images" />
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<Button Content="选择目录…" Click="ChooseCompletionImageDirectory" HorizontalAlignment="Stretch" />
|
||||
<Button Grid.Column="2" Content="恢复默认" Click="ResetCompletionImageDirectory" HorizontalAlignment="Stretch" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Grid ColumnDefinitions="76,*">
|
||||
<TextBlock Text="超时 / 秒" Classes="Field" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Timeout, Mode=TwoWay}" ToolTip.Tip="0 表示不限时;需启用全局超时检测" />
|
||||
</Grid>
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" Content="加违规规则" Command="{Binding ViolationRules.AddCommand}" Classes="Mini" />
|
||||
<TextBlock Text="违规规则" Classes="Title" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
<ItemsControl ItemsSource="{Binding ViolationRules.Items}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<CheckBox Content="保存结束图" IsChecked="{Binding SaveCompletionImage, Mode=TwoWay}" Margin="0,8,0,4" />
|
||||
<StackPanel IsEnabled="{Binding SaveCompletionImage}">
|
||||
<StackPanel Spacing="6" Margin="0,6,0,6">
|
||||
<TextBox x:Name="CompletionImageDirectoryBox" Text="{Binding CompletionImageDirectory, Mode=TwoWay}" PlaceholderText="默认:当前配方目录 / completion-images" />
|
||||
<Button Content="选择目录…" Click="ChooseCompletionImageDirectory" Margin="0" />
|
||||
<Button Content="恢复默认" Click="ResetCompletionImageDirectory" Margin="0" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Text="触发 / 判定规则" FontSize="13" Margin="0,10,0,6" Classes="Title" TextWrapping="Wrap" />
|
||||
<StackPanel>
|
||||
<StackPanel Spacing="6" Margin="0,8,0,0" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="方法" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.Methods, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Method, Converter={StaticResource SelectionConverter}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={x:Static ed:ConditionMethodLabels.Converter}}" TextWrapping="Wrap" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="主区域" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Region, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="起点区域" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.FromRegion, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="终点区域" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.RegionNames, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.ToRegion, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="手" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding DataContext.Recipe.Hands, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedItem="{Binding Detection.Hand, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="容差像素" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Detection.Tolerance, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="稳定帧" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Detection.StableFrames, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6" Classes="Row">
|
||||
|
||||
<Grid ColumnDefinitions="2*,3*" Margin="0,0,0,6">
|
||||
<TextBlock Text="计时毫秒" Classes="Field" TextWrapping="Wrap" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Detection.DurationMs, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<DockPanel Margin="0,10,0,6">
|
||||
<Button DockPanel.Dock="Right" Content="加违规规则" Command="{Binding ViolationRules.AddCommand}" Classes="Mini" />
|
||||
<TextBlock FontSize="13" Text="{Binding ViolationRules.Title}" Classes="Title" TextWrapping="Wrap" />
|
||||
</DockPanel>
|
||||
<ItemsControl ItemsSource="{Binding ViolationRules.Items}" />
|
||||
</Expander>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
@ -774,6 +774,7 @@ internal static class Smoke
|
||||
var dialog=new Window{Content=editor,Width=1040,Height=760};dialog.Show();await Task.Delay(60);
|
||||
try
|
||||
{
|
||||
editor.FindControl<Expander>("StepAdditionalSettings")!.IsExpanded=true;await Task.Delay(20);
|
||||
var toggle=editor.GetVisualDescendants().OfType<CheckBox>().Single(c=>c.Content?.ToString()=="保存结束图");
|
||||
var directoryBox=editor.GetVisualDescendants().OfType<TextBox>().Single(t=>t.Name=="CompletionImageDirectoryBox");
|
||||
Check(toggle.IsChecked==true&&string.IsNullOrEmpty(directoryBox.Text),"Step editor exposes image saving enabled by default with the recipe directory selected");
|
||||
|
||||
@ -235,11 +235,18 @@ internal static class Program
|
||||
Check(keyFrame.TranslatePoint(default, window) == keyFramePosition,
|
||||
"Scrolling step parameters does not move the keyframe");
|
||||
parameters.Offset = default;
|
||||
CheckStepParameterLayout(vm, view, window);
|
||||
if (_overlayPreviewPath is not null)
|
||||
{
|
||||
using var rendered = new Avalonia.Media.Imaging.RenderTargetBitmap(new PixelSize((int)window.Bounds.Width, (int)window.Bounds.Height));
|
||||
rendered.Render(window);
|
||||
rendered.Save(Path.Combine(Path.GetDirectoryName(_overlayPreviewPath)!, "step-editor.png"));
|
||||
parameters.Offset = new Vector(0, parameters.Extent.Height);
|
||||
window.UpdateLayout(); Dispatcher.UIThread.RunJobs();
|
||||
using var details = new Avalonia.Media.Imaging.RenderTargetBitmap(new PixelSize((int)window.Bounds.Width, (int)window.Bounds.Height));
|
||||
details.Render(window);
|
||||
details.Save(Path.Combine(Path.GetDirectoryName(_overlayPreviewPath)!, "step-parameters.png"));
|
||||
parameters.Offset = default;
|
||||
}
|
||||
Check(parameters.Bounds.Width > window.Bounds.Width * .30 && parameters.Bounds.Width < window.Bounds.Width * .37
|
||||
&& parameters.Extent.Width <= parameters.Viewport.Width + 1,
|
||||
@ -399,6 +406,46 @@ internal static class Program
|
||||
Pump(playback.StopAsync());
|
||||
}
|
||||
|
||||
private static void CheckStepParameterLayout(RecipeEditorViewModel model, RecipeEditor view, Window window)
|
||||
{
|
||||
var step = model.Recipe.SelectedStep!;
|
||||
var condition = step.Detection!;
|
||||
var original = condition.Method;
|
||||
var windowMs = step.AiCheckWindowMs;
|
||||
var timing = step.StandardDurationMs = 1234;
|
||||
var notifications = new HashSet<string?>();
|
||||
System.ComponentModel.PropertyChangedEventHandler changed = (_, e) => notifications.Add(e.PropertyName);
|
||||
condition.PropertyChanged += changed;
|
||||
bool Visible(string name) => view.FindControl<Control>(name)!.IsVisible;
|
||||
void Method(string method) { condition.Method = method; Dispatcher.UIThread.RunJobs(); window.UpdateLayout(); }
|
||||
try
|
||||
{
|
||||
Method(ConditionMethod.HandInRegion);
|
||||
Check(Visible("TriggerRegionRow") && Visible("TriggerStableField") && !Visible("TriggerMoveRows") && !Visible("TriggerDurationRow"),
|
||||
"区域触发仅显示操作区域和稳定帧,不显示移动或计时参数");
|
||||
Method(ConditionMethod.HandMove);
|
||||
Check(Visible("TriggerMoveRows") && !Visible("TriggerRegionRow") && !Visible("TriggerStableField") && !Visible("TriggerDurationRow"),
|
||||
"移动触发显示起终点并隐藏不生效的稳定帧和计时参数");
|
||||
Method(ConditionMethod.TimeElapsed);
|
||||
Check(Visible("TriggerDurationRow") && !Visible("TriggerMoveRows") && !Visible("TriggerRegionRow") && !condition.UsesHandTrigger,
|
||||
"计时触发仅显示持续时间,不显示手部区域参数");
|
||||
Check(notifications.Contains(nameof(ConditionNode.UsesTriggerRegion)) && notifications.Contains(nameof(ConditionNode.IsTimedTrigger)),
|
||||
"切换触发方式通知界面刷新相关参数");
|
||||
Check(!view.FindControl<Expander>("StepAdditionalSettings")!.IsExpanded
|
||||
&& !view.FindControl<ScrollViewer>("StepParameters")!.GetVisualDescendants().OfType<TextBlock>().Any(t => t.Text == "节拍毫秒")
|
||||
&& model.Recipe.ToConfig().Sop.Steps.First(s => s.Id == step.Id).StandardDurationMs == timing,
|
||||
"低频设置折叠,移除无运行用途的节拍输入并保留原配方数据");
|
||||
step.AiContinueAfterWindow = false; Dispatcher.UIThread.RunJobs(); window.UpdateLayout();
|
||||
Check(step.AiCheckWindowMs == 0 && !step.AiContinueAfterWindow, "紧凑复检控件不会把关闭的窗口强制重新开启");
|
||||
}
|
||||
finally
|
||||
{
|
||||
condition.PropertyChanged -= changed;
|
||||
condition.Method = original; step.AiCheckWindowMs = windowMs;
|
||||
Dispatcher.UIThread.RunJobs(); window.UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Until(Func<bool> ready)
|
||||
{
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user