修复步骤页切换标签后触发方式显示为空
This commit is contained in:
parent
12fcf7a2fa
commit
0b377d2afa
@ -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" x:Name="RecipeEditorRoot" 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">
|
||||
@ -177,7 +177,7 @@
|
||||
<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 Grid.Column="1" x:Name="StepTriggerMethodPicker" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.Methods}" 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>
|
||||
@ -185,17 +185,17 @@
|
||||
</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}}" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.RegionNames}" 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}}" />
|
||||
<ComboBox Grid.Column="1" Margin="0,0,0,6" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.RegionNames}" 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}}" />
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.RegionNames}" 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}}" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.Hands}" SelectedItem="{Binding Detection.Hand, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,8,*" IsVisible="{Binding Detection.UsesHandTrigger}">
|
||||
<StackPanel Spacing="3">
|
||||
@ -228,7 +228,7 @@
|
||||
</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}}" />
|
||||
<ComboBox Grid.Column="1" x:Name="AiImageRegionPicker" ItemsSource="{Binding #RecipeEditorRoot.DataContext.Recipe.RegionNames}" SelectedItem="{Binding AiImageRegion, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" />
|
||||
</Grid>
|
||||
<StackPanel IsVisible="{Binding UsesHandImageRegion}" Spacing="6">
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
|
||||
@ -172,6 +172,8 @@ internal static class Smoke
|
||||
}
|
||||
if(Environment.GetCommandLineArgs().Contains("--recipe-close-only"))
|
||||
{ await CheckRecipeClose(app,lifetime);_exit=0;return; }
|
||||
if(Environment.GetCommandLineArgs().Contains("--step-trigger-tabs-only"))
|
||||
{ await CheckStepTriggerTabs();_exit=0;return; }
|
||||
if(Environment.GetCommandLineArgs().Contains("--runtime-settings-only"))
|
||||
{
|
||||
var model=app.Container.Resolve<SopPageViewModel>();
|
||||
@ -1423,6 +1425,49 @@ internal static class Smoke
|
||||
Check(owner.IsVisible&&buttons.Length==2,"关闭保存提示仅有保存并关闭和不保存两个按钮");
|
||||
buttons.Single(b=>b.Name==buttonName).RaiseEvent(new Avalonia.Interactivity.RoutedEventArgs(Button.ClickEvent));
|
||||
}
|
||||
private static async Task CheckStepTriggerTabs()
|
||||
{
|
||||
var model=new RecipeEditorViewModel();
|
||||
model.Recipe.AddRegion("work");model.Recipe.AddRegion("finish");
|
||||
var first=model.Recipe.AddStep();first.Detection.Method="hand_in_region";
|
||||
first.Detection.Region="work";first.Detection.FromRegion="work";first.Detection.ToRegion="finish";
|
||||
first.Detection.Hand="left";first.AiImageMode="fixed_region";first.AiImageRegion="work";
|
||||
var second=model.Recipe.AddStep();second.Detection.Method="time_elapsed";
|
||||
model.Recipe.SelectedStep=first;
|
||||
var editor=new RecipeEditor{DataContext=model};
|
||||
var dialog=new Window{Content=editor,Width=1040,Height=900};dialog.Show();await Task.Delay(60);
|
||||
try
|
||||
{
|
||||
var tabs=editor.GetVisualDescendants().OfType<TabControl>().First();
|
||||
var picker=editor.FindControl<ComboBox>("StepTriggerMethodPicker")!;
|
||||
var selections=editor.FindControl<ScrollViewer>("StepParameters")!.GetVisualDescendants()
|
||||
.OfType<ComboBox>().Select(c=>(Picker:c,Selected:c.SelectedItem)).ToArray();
|
||||
Check(selections.Length==7&&selections.All(s=>s.Selected is not null),"Step selectors initially display all configured values");
|
||||
void CheckSelection(string expected)
|
||||
{
|
||||
Check(picker.SelectedItem?.ToString()==expected,"Trigger selection survives tab changes: "+expected);
|
||||
Check(picker.GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text==
|
||||
ConditionMethodLabels.Converter.Convert(expected,typeof(string),null,System.Globalization.CultureInfo.InvariantCulture)?.ToString()),
|
||||
"Trigger label remains displayed after tab changes: "+expected);
|
||||
Check(model.Recipe.SelectedStep!.Detection.Method==expected,"Tab changes preserve the stored trigger method");
|
||||
}
|
||||
CheckSelection(first.Detection.Method);
|
||||
for(var index=1;index<tabs.Items.Count;index++)
|
||||
{
|
||||
tabs.SelectedIndex=index;await Task.Delay(30);
|
||||
tabs.SelectedIndex=0;await Task.Delay(30);
|
||||
CheckSelection(first.Detection.Method);
|
||||
Check(selections.All(s=>Equals(s.Picker.SelectedItem,s.Selected)),"Region, hand and image selectors retain their selections after tab changes");
|
||||
}
|
||||
model.Recipe.SelectedStep=second;await Task.Delay(30);CheckSelection("time_elapsed");
|
||||
picker.SelectedItem="hand_move";await Task.Delay(30);CheckSelection("hand_move");
|
||||
tabs.SelectedIndex=1;await Task.Delay(30);tabs.SelectedIndex=0;await Task.Delay(30);
|
||||
CheckSelection("hand_move");
|
||||
model.Recipe.SelectedStep=first;await Task.Delay(30);CheckSelection("hand_in_region");
|
||||
}
|
||||
finally { await model.ShutdownAsync();dialog.Close(); }
|
||||
}
|
||||
|
||||
private static async Task CheckRecipeClose(App app,IClassicDesktopStyleApplicationLifetime lifetime)
|
||||
{
|
||||
var root=Environment.GetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT")!;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user