子程序优化

This commit is contained in:
2026-08-07 16:30:13 +08:00
parent 8daa1df8e9
commit a9355087ad
9 changed files with 408 additions and 10 deletions
+29 -1
View File
@@ -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 之间随机摇一个数