refactor: 插件窗体由 static 单例状态改为实例字段(对齐 TextViewer)
将 10 个 CycleGUI 窗体/管理器从进程级 static 单例状态改为实例字段 + 实例方法, 消除本地端/Web 端共享同一可变状态的隐患(对齐 TextViewer 正例)。 每个类保留一个 private static _instance 单实例持有者;静态入口 Open()/OpenViewer() 与实例 Show() 均转发到该实例,调用方零改动、单实例“置前”行为不变。 涉及:ChargeStationManagementForm、ChargeStrategyConfigForm、CommunicationMonitorForm、 AlarmConfigManagementForm、ButtonBoxManager、DoorManager、DoorMonitor、 LoopViewer、DeliveryViewer、TrafficInterlockViewer。 构建:dotnet build StandardScene.sln --no-incremental → 0 错误,30 警告(与基线一致,无新增)。
This commit is contained in:
@@ -14,28 +14,32 @@ namespace StandardScene.Charge
|
||||
{
|
||||
private const string TableId = "alarm-config-list";
|
||||
|
||||
private static readonly string[] LevelNames = { "无", "低", "中", "高", "严重" };
|
||||
private static readonly string[] LevelFilterNames = { "全部", "无", "低", "中", "高", "严重" };
|
||||
private readonly string[] LevelNames = { "无", "低", "中", "高", "严重" };
|
||||
private readonly string[] LevelFilterNames = { "全部", "无", "低", "中", "高", "严重" };
|
||||
|
||||
private static readonly Color CriticalRowColor = Color.FromArgb(255, 235, 238);
|
||||
private static readonly Color HighRowColor = Color.FromArgb(255, 243, 224);
|
||||
private static readonly Color MediumRowColor = Color.FromArgb(255, 249, 196);
|
||||
private static readonly Color LowRowColor = Color.FromArgb(232, 245, 233);
|
||||
private static readonly Color DisabledRowColor = Color.FromArgb(238, 238, 238);
|
||||
private readonly Color CriticalRowColor = Color.FromArgb(255, 235, 238);
|
||||
private readonly Color HighRowColor = Color.FromArgb(255, 243, 224);
|
||||
private readonly Color MediumRowColor = Color.FromArgb(255, 249, 196);
|
||||
private readonly Color LowRowColor = Color.FromArgb(232, 245, 233);
|
||||
private readonly Color DisabledRowColor = Color.FromArgb(238, 238, 238);
|
||||
|
||||
private static readonly AlarmConfigDataService DataService = AlarmConfigDataService.Instance;
|
||||
private readonly AlarmConfigDataService DataService = AlarmConfigDataService.Instance;
|
||||
|
||||
private static Panel _panel;
|
||||
private static Panel _dialog;
|
||||
private static List<AlarmConfig> _allAlarms = new List<AlarmConfig>();
|
||||
private static int _levelFilterIdx;
|
||||
private static string _status = "";
|
||||
private Panel _panel;
|
||||
private Panel _dialog;
|
||||
private List<AlarmConfig> _allAlarms = new List<AlarmConfig>();
|
||||
private int _levelFilterIdx;
|
||||
private string _status = "";
|
||||
|
||||
/// <summary>打开(或置前)报警配置管理面板。兼容原 <c>new AlarmConfigManagementForm().Show()</c> 调用方式。</summary>
|
||||
public void Show() => Open();
|
||||
|
||||
/// <summary>打开(或置前)报警配置管理面板。</summary>
|
||||
public static void Open()
|
||||
public static void Open() => (_instance ??= new AlarmConfigManagementForm()).OpenCore();
|
||||
|
||||
private static AlarmConfigManagementForm _instance;
|
||||
|
||||
private void OpenCore()
|
||||
{
|
||||
if (_panel != null)
|
||||
{
|
||||
@@ -132,7 +136,7 @@ namespace StandardScene.Charge
|
||||
});
|
||||
}
|
||||
|
||||
private static void OpenEditDialog(AlarmConfig existing)
|
||||
private void OpenEditDialog(AlarmConfig existing)
|
||||
{
|
||||
if (_dialog != null)
|
||||
{
|
||||
@@ -276,7 +280,7 @@ namespace StandardScene.Charge
|
||||
});
|
||||
}
|
||||
|
||||
private static void LoadAlarms()
|
||||
private void LoadAlarms()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -289,7 +293,7 @@ namespace StandardScene.Charge
|
||||
}
|
||||
}
|
||||
|
||||
private static List<AlarmConfig> GetFilteredAlarms()
|
||||
private List<AlarmConfig> GetFilteredAlarms()
|
||||
{
|
||||
IEnumerable<AlarmConfig> query = _allAlarms;
|
||||
if (_levelFilterIdx > 0)
|
||||
@@ -297,7 +301,7 @@ namespace StandardScene.Charge
|
||||
return query.ToList();
|
||||
}
|
||||
|
||||
private static string GetStatisticsText()
|
||||
private string GetStatisticsText()
|
||||
{
|
||||
var total = _allAlarms.Count;
|
||||
var enabled = _allAlarms.Count(a => a.Enabled);
|
||||
@@ -307,7 +311,7 @@ namespace StandardScene.Charge
|
||||
return $"启用: {enabled} | 禁用: {disabled} | 严重: {critical} | 高级: {high}";
|
||||
}
|
||||
|
||||
private static string GetLevelText(AlarmLevel level)
|
||||
private string GetLevelText(AlarmLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user