子程序优化
This commit is contained in:
@@ -154,6 +154,24 @@ namespace ADP.ViewModels
|
||||
public ICommand MonitorValueSettingCommand { get; set; }
|
||||
public ICommand GetFileStringCommand { get; set; }
|
||||
public ICommand SilenceBuzzerCommand { get; set; }
|
||||
public ICommand GoBackCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 子程序导航
|
||||
|
||||
public bool CanGoBack =>
|
||||
(CurrentContext?.MainNav.CanGoBack ?? false) ||
|
||||
(CurrentContext?.ErrorNav.CanGoBack ?? false);
|
||||
|
||||
private void OnGoBack()
|
||||
{
|
||||
var ctx = CurrentContext;
|
||||
if (ctx == null) return;
|
||||
// 工具栏按钮同时重置两个 Tab 的导航
|
||||
ctx.MainNav.Reset(ctx.Program, "主程序");
|
||||
ctx.ErrorNav.Reset(ctx.Program, "错误程序");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ShellViewModel(IContainerProvider containerProvider)
|
||||
@@ -188,6 +206,7 @@ namespace ADP.ViewModels
|
||||
MonitorValueSettingCommand = new DelegateCommand(MonitorValueSetting);
|
||||
GetFileStringCommand = new DelegateCommand(GetFileString);
|
||||
SilenceBuzzerCommand = new AsyncDelegateCommand(SilenceBuzzer);
|
||||
GoBackCommand = new DelegateCommand(OnGoBack);
|
||||
|
||||
_globalInfo.ContextDic.Add("default", new ScopedContext());
|
||||
|
||||
@@ -457,6 +476,9 @@ namespace ADP.ViewModels
|
||||
|
||||
LoggerHelper.InfoWithNotify(runningScope, $"{_globalInfo.UserName} 执行工位 [{runningScope}] 复位命令");
|
||||
|
||||
// 重置导航栈,回到根程序界面
|
||||
targetContext.ResetNavigation();
|
||||
|
||||
_executionTasks.TryGetValue(runningScope, out var currentTask);
|
||||
_errorExecutionTasks.TryGetValue(runningScope, out var errorTask);
|
||||
|
||||
@@ -573,6 +595,7 @@ namespace ADP.ViewModels
|
||||
targetContext.Program.Parameters.Clear();
|
||||
targetContext.Program.StepCollection.Clear();
|
||||
targetContext.Program.ErrorStepCollection.Clear();
|
||||
targetContext.ResetNavigation();
|
||||
foreach (var item in CurrentConfig.ParameterList)
|
||||
{
|
||||
var param = CurrentConfig.SharedParameterList.FirstOrDefault(x => x.ParameterName == item.Name);
|
||||
|
||||
@@ -226,6 +226,16 @@ Command="{Binding GetFileStringCommand}">
|
||||
Foreground="Black" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator/>
|
||||
<!-- 返回上一级程序 -->
|
||||
<MenuItem Header="返回上一级程序"
|
||||
Foreground="Black"
|
||||
Command="{Binding GoBackCommand}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="ArrowLeftBold"
|
||||
Foreground="Black" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="切换九宫格"
|
||||
FontSize="13"
|
||||
|
||||
@@ -568,6 +568,8 @@ namespace TestingModule.ViewModels
|
||||
{
|
||||
// 查找最近的未匹配循环开始
|
||||
StepVM? lastUnmatchedLoopStart = null;
|
||||
if (_ScopedContext.SelectedStepList == "主程序")
|
||||
{
|
||||
for (int i = Program.StepCollection.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (Program.StepCollection[i].StepType == "循环开始")
|
||||
@@ -581,6 +583,23 @@ namespace TestingModule.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = Program.ErrorStepCollection.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (Program.ErrorStepCollection[i].StepType == "循环开始")
|
||||
{
|
||||
bool isMatched = Program.ErrorStepCollection.Any(s => s.StepType == "循环结束" && s.LoopStartStepId == Program.StepCollection[i].ID);
|
||||
|
||||
if (!isMatched)
|
||||
{
|
||||
lastUnmatchedLoopStart = Program.ErrorStepCollection[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var newStep = new StepVM
|
||||
{
|
||||
|
||||
@@ -94,6 +94,29 @@ namespace TestingModule.ViewModels
|
||||
public ICommand DeleteStepCommand { get;set; }
|
||||
public ICommand TabSelectionChangedCommand { get;set; }
|
||||
public ICommand SelectionChangedCommand { get;set; }
|
||||
public ICommand OpenSubProgramCommand { get; set; }
|
||||
public ICommand GoBackCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 子程序导航(主程序 / 错误程序各自独立)
|
||||
|
||||
// --- 主程序 Tab 导航属性 ---
|
||||
public ProgramVM MainCurrentProgram => _ScopedContext.MainNav.CurrentProgram;
|
||||
public string MainBreadcrumbPath => _ScopedContext.MainNav.BreadcrumbPath;
|
||||
public bool MainCanGoBack => _ScopedContext.MainNav.CanGoBack;
|
||||
public ObservableCollection<StepVM> MainDisplaySteps => _ScopedContext.MainNav.DisplaySteps;
|
||||
|
||||
// --- 错误程序 Tab 导航属性 ---
|
||||
public ProgramVM ErrorCurrentProgram => _ScopedContext.ErrorNav.CurrentProgram;
|
||||
public string ErrorBreadcrumbPath => _ScopedContext.ErrorNav.BreadcrumbPath;
|
||||
public bool ErrorCanGoBack => _ScopedContext.ErrorNav.CanGoBack;
|
||||
public ObservableCollection<StepVM> ErrorDisplaySteps => _ScopedContext.ErrorNav.DisplaySteps;
|
||||
|
||||
/// <summary>
|
||||
/// 当前激活的导航状态(根据选中的 Tab 索引决定)
|
||||
/// </summary>
|
||||
private ProgramNavigationState ActiveNav => SelectedTabIndex == 1 ? _ScopedContext.ErrorNav : _ScopedContext.MainNav;
|
||||
|
||||
#endregion
|
||||
|
||||
public StepsManagerViewModel(IContainerProvider containerProvider, ScopedContext scopedContext, SystemConfig systemConfig, GlobalInfo globalInfo) : base(containerProvider)
|
||||
@@ -108,9 +131,48 @@ namespace TestingModule.ViewModels
|
||||
DeleteStepCommand = new DelegateCommand(DeleteStep);
|
||||
TabSelectionChangedCommand = new DelegateCommand<string>(TabSelectionChanged);
|
||||
SelectionChangedCommand = new DelegateCommand<object>(SelectionChanged);
|
||||
OpenSubProgramCommand = new DelegateCommand(OpenSubProgram);
|
||||
GoBackCommand = new DelegateCommand(GoBack);
|
||||
SubscribeStepCollections();
|
||||
Program.PropertyChanged += Program_PropertyChanged;
|
||||
Admin = _globalInfo.IsAdmin;
|
||||
|
||||
// 初始化两套导航状态
|
||||
_ScopedContext.MainNav.Initialize(Program, "主程序");
|
||||
_ScopedContext.ErrorNav.Initialize(Program, "错误程序");
|
||||
|
||||
// 订阅主程序导航状态变化 → 转发给 UI
|
||||
_ScopedContext.MainNav.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(ProgramNavigationState.CurrentProgram))
|
||||
{
|
||||
RaisePropertyChanged(nameof(MainCurrentProgram));
|
||||
RaisePropertyChanged(nameof(MainDisplaySteps));
|
||||
}
|
||||
else if (e.PropertyName == nameof(ProgramNavigationState.BreadcrumbPath))
|
||||
RaisePropertyChanged(nameof(MainBreadcrumbPath));
|
||||
else if (e.PropertyName == nameof(ProgramNavigationState.CanGoBack))
|
||||
RaisePropertyChanged(nameof(MainCanGoBack));
|
||||
};
|
||||
|
||||
// 订阅错误程序导航状态变化 → 转发给 UI
|
||||
_ScopedContext.ErrorNav.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(ProgramNavigationState.CurrentProgram))
|
||||
{
|
||||
RaisePropertyChanged(nameof(ErrorCurrentProgram));
|
||||
RaisePropertyChanged(nameof(ErrorDisplaySteps));
|
||||
}
|
||||
else if (e.PropertyName == nameof(ProgramNavigationState.BreadcrumbPath))
|
||||
RaisePropertyChanged(nameof(ErrorBreadcrumbPath));
|
||||
else if (e.PropertyName == nameof(ProgramNavigationState.CanGoBack))
|
||||
RaisePropertyChanged(nameof(ErrorCanGoBack));
|
||||
};
|
||||
|
||||
// 订阅子程序导航事件(运行时由 StepRunning 发布)
|
||||
_eventAggregator.GetEvent<SubProgramNavigateEvent>()
|
||||
.Subscribe(OnSubProgramNavigate, ThreadOption.UIThread, false,
|
||||
payload => payload.Scope == _systemConfig.Title);
|
||||
}
|
||||
|
||||
private void SelectionChanged(object parameter)
|
||||
@@ -208,6 +270,72 @@ namespace TestingModule.ViewModels
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 子程序导航方法
|
||||
|
||||
/// <summary>
|
||||
/// 编辑模式:右键打开子程序(操作当前激活的 Tab 的导航状态)
|
||||
/// </summary>
|
||||
private void OpenSubProgram()
|
||||
{
|
||||
if (SelectedStep == null || SelectedStep.StepType != "子程序" || SelectedStep.SubProgram == null)
|
||||
return;
|
||||
|
||||
var nav = ActiveNav;
|
||||
nav.NavigationStack.Push(nav.CurrentProgram);
|
||||
nav.UpdateCanGoBack();
|
||||
var stepName = SelectedStep.Name ?? "子程序";
|
||||
nav.BreadcrumbPath = $"{nav.BreadcrumbPath} > {stepName}";
|
||||
nav.CurrentProgram = SelectedStep.SubProgram;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回上一级程序(操作当前激活的 Tab 的导航状态)
|
||||
/// </summary>
|
||||
private void GoBack()
|
||||
{
|
||||
var nav = ActiveNav;
|
||||
if (nav.NavigationStack.Count == 0)
|
||||
return;
|
||||
|
||||
var parentProgram = nav.NavigationStack.Pop();
|
||||
nav.UpdateCanGoBack();
|
||||
nav.CurrentProgram = parentProgram;
|
||||
|
||||
var parts = nav.BreadcrumbPath.Split(" > ");
|
||||
nav.BreadcrumbPath = parts.Length > 1
|
||||
? string.Join(" > ", parts.Take(parts.Length - 1))
|
||||
: nav == _ScopedContext.MainNav ? "主程序" : "错误程序";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行时:处理 StepRunning 发布的子程序导航事件
|
||||
/// </summary>
|
||||
private void OnSubProgramNavigate(SubProgramNavigatePayload payload)
|
||||
{
|
||||
var nav = payload.IsErrorProgram ? _ScopedContext.ErrorNav : _ScopedContext.MainNav;
|
||||
if (payload.Action == NavigateAction.Enter && payload.SubProgram != null)
|
||||
{
|
||||
nav.NavigationStack.Push(nav.CurrentProgram);
|
||||
nav.UpdateCanGoBack();
|
||||
nav.CurrentProgram = payload.SubProgram;
|
||||
var stepName = payload.StepName ?? "子程序";
|
||||
nav.BreadcrumbPath = $"{nav.BreadcrumbPath} > {stepName}";
|
||||
}
|
||||
else if (payload.Action == NavigateAction.Exit)
|
||||
{
|
||||
if (nav.NavigationStack.Count == 0) return;
|
||||
var parentProgram = nav.NavigationStack.Pop();
|
||||
nav.UpdateCanGoBack();
|
||||
nav.CurrentProgram = parentProgram;
|
||||
var parts = nav.BreadcrumbPath.Split(" > ");
|
||||
nav.BreadcrumbPath = parts.Length > 1
|
||||
? string.Join(" > ", parts.Take(parts.Length - 1))
|
||||
: nav == _ScopedContext.MainNav ? "主程序" : "错误程序";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,9 +8,13 @@
|
||||
xmlns:behaviors="clr-namespace:UIShare.Behaviors;assembly=UIShare"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<GroupBox Header="{Binding Title}">
|
||||
<TabControl SelectedIndex="{Binding SelectedTabIndex, Mode=TwoWay}">
|
||||
@@ -19,6 +23,17 @@
|
||||
CommandParameter="{Binding SelectedTabHeader}" />
|
||||
</i:Interaction.Behaviors>
|
||||
<TabItem Header="主程序">
|
||||
<DockPanel>
|
||||
<!-- 主程序面包屑导航栏 -->
|
||||
<Border DockPanel.Dock="Top" Background="#F0F0F0" Padding="6,3" Visibility="{Binding MainCanGoBack, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" Content="↩ 返回上一级"
|
||||
Command="{Binding GoBackCommand}"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
FontSize="12" Padding="8,2" Margin="8,0,0,0"/>
|
||||
<TextBlock Text="{Binding MainBreadcrumbPath}" VerticalAlignment="Center" FontSize="12" Foreground="#555"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<DataGrid dd:DragDrop.IsDragSource="{Binding Admin}"
|
||||
dd:DragDrop.IsDropTarget="{Binding Admin}"
|
||||
dd:DragDrop.UseDefaultDragAdorner="{Binding Admin}"
|
||||
@@ -29,7 +44,7 @@
|
||||
Background="Transparent"
|
||||
CanUserAddRows="False"
|
||||
CanUserSortColumns="False"
|
||||
ItemsSource="{Binding Program.StepCollection}"
|
||||
ItemsSource="{Binding MainDisplaySteps}"
|
||||
SelectedItem="{Binding SelectedStep, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow">
|
||||
@@ -120,14 +135,29 @@
|
||||
<MenuItem Header="删除"
|
||||
Foreground="Red"
|
||||
Command="{Binding DeleteStepCommand}" />
|
||||
<Separator/>
|
||||
<MenuItem Header="打开子程序"
|
||||
Command="{Binding OpenSubProgramCommand}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
|
||||
|
||||
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="错误程序">
|
||||
<DockPanel>
|
||||
<!-- 错误程序面包屑导航栏 -->
|
||||
<Border DockPanel.Dock="Top" Background="#F0F0F0" Padding="6,3" Visibility="{Binding ErrorCanGoBack, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" Content="↩ 返回上一级"
|
||||
Command="{Binding GoBackCommand}"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
FontSize="12" Padding="8,2" Margin="8,0,0,0"/>
|
||||
<TextBlock Text="{Binding ErrorBreadcrumbPath}" VerticalAlignment="Center" FontSize="12" Foreground="#555"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<DataGrid dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
@@ -135,7 +165,7 @@
|
||||
Background="Transparent"
|
||||
CanUserAddRows="False"
|
||||
CanUserSortColumns="False"
|
||||
ItemsSource="{Binding Program.ErrorStepCollection}"
|
||||
ItemsSource="{Binding ErrorDisplaySteps}"
|
||||
SelectedItem="{Binding SelectedStep, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow">
|
||||
@@ -226,6 +256,9 @@
|
||||
<MenuItem Header="删除"
|
||||
Foreground="Red"
|
||||
Command="{Binding DeleteStepCommand}" />
|
||||
<Separator/>
|
||||
<MenuItem Header="打开子程序"
|
||||
Command="{Binding OpenSubProgramCommand}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
|
||||
@@ -239,6 +272,7 @@
|
||||
</i:Interaction.Triggers>-->
|
||||
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</GroupBox>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using UIShare.UIViewModel;
|
||||
|
||||
namespace UIShare.GlobalVariable
|
||||
{
|
||||
/// <summary>
|
||||
/// 单个 Tab(主程序 / 错误程序)的子程序导航状态。
|
||||
/// 主程序和错误程序各自持有一个独立实例,互不干扰。
|
||||
/// </summary>
|
||||
public class ProgramNavigationState : BindableBase
|
||||
{
|
||||
/// <summary>是否为错误程序 Tab</summary>
|
||||
public bool IsErrorTab { get; set; }
|
||||
|
||||
public Stack<ProgramVM> NavigationStack { get; } = new();
|
||||
|
||||
private ProgramVM _currentProgram;
|
||||
public ProgramVM CurrentProgram
|
||||
{
|
||||
get => _currentProgram;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _currentProgram, value))
|
||||
RaisePropertyChanged(nameof(DisplaySteps));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DataGrid 实际绑定的步骤集合。
|
||||
/// 根程序 + 错误 Tab → ErrorStepCollection;其他情况 → StepCollection。
|
||||
/// </summary>
|
||||
public ObservableCollection<StepVM> DisplaySteps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentProgram == null)
|
||||
return new ObservableCollection<StepVM>();
|
||||
// 在根程序且是错误 Tab → 显示错误步骤集合
|
||||
if (NavigationStack.Count == 0 && IsErrorTab)
|
||||
return CurrentProgram.ErrorStepCollection;
|
||||
// 其他情况(主 Tab 或已进入子程序)→ 显示正常步骤集合
|
||||
return CurrentProgram.StepCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private string _breadcrumbPath = "主程序";
|
||||
public string BreadcrumbPath
|
||||
{
|
||||
get => _breadcrumbPath;
|
||||
set => SetProperty(ref _breadcrumbPath, value);
|
||||
}
|
||||
|
||||
private bool _canGoBack;
|
||||
public bool CanGoBack
|
||||
{
|
||||
get => _canGoBack;
|
||||
set => SetProperty(ref _canGoBack, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用根程序初始化导航状态
|
||||
/// </summary>
|
||||
public void Initialize(ProgramVM rootProgram, string label)
|
||||
{
|
||||
NavigationStack.Clear();
|
||||
CurrentProgram = rootProgram;
|
||||
BreadcrumbPath = label;
|
||||
CanGoBack = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空导航栈,回到根程序
|
||||
/// </summary>
|
||||
public void Reset(ProgramVM rootProgram, string label)
|
||||
{
|
||||
NavigationStack.Clear();
|
||||
CurrentProgram = rootProgram;
|
||||
BreadcrumbPath = label;
|
||||
CanGoBack = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据栈状态刷新 CanGoBack
|
||||
/// </summary>
|
||||
public void UpdateCanGoBack() => CanGoBack = NavigationStack.Count > 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using DeviceCommand.Base;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,9 +15,35 @@ using UIShare.UIViewModel;
|
||||
|
||||
namespace UIShare.GlobalVariable
|
||||
{
|
||||
public class ScopedContext
|
||||
public class ScopedContext : BindableBase
|
||||
{
|
||||
private static readonly Random _randomSeed = new Random();
|
||||
|
||||
#region 子程序导航(主程序 / 错误程序各自独立)
|
||||
|
||||
/// <summary>主程序 Tab 的导航状态</summary>
|
||||
public ProgramNavigationState MainNav { get; } = new();
|
||||
|
||||
/// <summary>错误程序 Tab 的导航状态</summary>
|
||||
public ProgramNavigationState ErrorNav { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据当前选中的 Tab 返回对应的导航状态
|
||||
/// </summary>
|
||||
public ProgramNavigationState ActiveNav =>
|
||||
SelectedStepList == "错误程序" ? ErrorNav : MainNav;
|
||||
|
||||
/// <summary>
|
||||
/// 重置两个 Tab 的导航栈,回到根程序
|
||||
/// </summary>
|
||||
public void ResetNavigation()
|
||||
{
|
||||
MainNav.Reset(Program, "主程序");
|
||||
ErrorNav.Reset(Program, "错误程序");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ProgramVM Program { get; set; } = new();
|
||||
public String SelectedStepList { get; set; } = "主程序";
|
||||
public string CurrentFilePath { get; set; }
|
||||
@@ -45,6 +72,7 @@ namespace UIShare.GlobalVariable
|
||||
public int DebugRandomId { get; private set; }
|
||||
public ScopedContext()
|
||||
{
|
||||
ErrorNav.IsErrorTab = true;
|
||||
lock (_randomSeed)
|
||||
{
|
||||
// 每次诞生一个新上下文,就在 10000 到 99999 之间随机摇一个数
|
||||
|
||||
@@ -181,7 +181,23 @@ namespace UIShare
|
||||
_scopedContext.SingleStep = false;
|
||||
}
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
|
||||
// 发布进入子程序导航事件
|
||||
_eventAggregator.GetEvent<SubProgramNavigateEvent>().Publish(new SubProgramNavigatePayload
|
||||
{
|
||||
Scope = _systemConfig.Title,
|
||||
Action = NavigateAction.Enter,
|
||||
SubProgram = step.SubProgram,
|
||||
StepName = step.Name,
|
||||
IsErrorProgram = true
|
||||
});
|
||||
stepSuccess = await ExecuteSteps(step.SubProgram, depth + 1, cancellationToken);
|
||||
// 发布退出子程序导航事件
|
||||
_eventAggregator.GetEvent<SubProgramNavigateEvent>().Publish(new SubProgramNavigatePayload
|
||||
{
|
||||
Scope = _systemConfig.Title,
|
||||
Action = NavigateAction.Exit,
|
||||
IsErrorProgram = true
|
||||
});
|
||||
UpdateCurrentStepResult(step, true, stepSuccess, depth);
|
||||
if (SubSingleStep)
|
||||
{
|
||||
@@ -356,7 +372,21 @@ namespace UIShare
|
||||
_scopedContext.SingleStep = false;
|
||||
}
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
|
||||
// 发布进入子程序导航事件
|
||||
_eventAggregator.GetEvent<SubProgramNavigateEvent>().Publish(new SubProgramNavigatePayload
|
||||
{
|
||||
Scope = _systemConfig.Title,
|
||||
Action = NavigateAction.Enter,
|
||||
SubProgram = step.SubProgram,
|
||||
StepName = step.Name
|
||||
});
|
||||
stepSuccess = await ExecuteSteps(step.SubProgram, depth + 1, cancellationToken);
|
||||
// 发布退出子程序导航事件
|
||||
_eventAggregator.GetEvent<SubProgramNavigateEvent>().Publish(new SubProgramNavigatePayload
|
||||
{
|
||||
Scope = _systemConfig.Title,
|
||||
Action = NavigateAction.Exit
|
||||
});
|
||||
UpdateCurrentStepResult(step, true, stepSuccess, depth);
|
||||
if (SubSingleStep)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using Prism.Events;
|
||||
using UIShare.UIViewModel;
|
||||
|
||||
namespace UIShare.PubEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 子程序导航事件:运行时进入/退出子程序时发布,
|
||||
/// StepsManagerViewModel 订阅后自动切换显示。
|
||||
/// </summary>
|
||||
public class SubProgramNavigateEvent : PubSubEvent<SubProgramNavigatePayload>
|
||||
{
|
||||
}
|
||||
|
||||
public class SubProgramNavigatePayload
|
||||
{
|
||||
/// <summary>目标台架的作用域标识</summary>
|
||||
public string Scope { get; set; } = "";
|
||||
|
||||
/// <summary>Enter = 进入子程序,Exit = 退出回到上一级</summary>
|
||||
public NavigateAction Action { get; set; }
|
||||
|
||||
/// <summary>进入时:子程序的 ProgramVM;退出时可为 null</summary>
|
||||
public ProgramVM? SubProgram { get; set; }
|
||||
|
||||
/// <summary>子程序步骤的名称(用于面包屑显示)</summary>
|
||||
public string? StepName { get; set; }
|
||||
|
||||
/// <summary>是否为错误程序 Tab 的导航(默认 false = 主程序 Tab)</summary>
|
||||
public bool IsErrorProgram { get; set; }
|
||||
}
|
||||
|
||||
public enum NavigateAction
|
||||
{
|
||||
Enter,
|
||||
Exit
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user