From 12e606635c42ea20f4b7c2bdda5204237a4b4c96 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 02 三月 2026 16:14:49 +0800
Subject: [PATCH] 优化
---
WPFProject/Controls/MainTabControl.xaml.cs | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/WPFProject/Controls/MainTabControl.xaml.cs b/WPFProject/Controls/MainTabControl.xaml.cs
index 874fe44..a476ebd 100644
--- a/WPFProject/Controls/MainTabControl.xaml.cs
+++ b/WPFProject/Controls/MainTabControl.xaml.cs
@@ -157,8 +157,26 @@
}
var content = data.Content;
- var last = page.Child;
- PluginPackage.Get(last)?.DeActive();
+ var newPlugin = PluginPackage.Get(content);
+ var last = PluginPackage.Get(page.Child);
+
+ if (last != null && !last.CanDeActive())
+ {
+ SelectedSubMenu = (PluginInfo)e.RemovedItems[0];
+ return;
+ }
+
+ if (newPlugin != null && !newPlugin.CanActive())
+ {
+ if (e.RemovedItems.Count > 0)
+ {
+ SelectedSubMenu = (PluginInfo)e.RemovedItems[0];
+ }
+ return;
+ }
+
+ last?.DeActive();
+ newPlugin?.Active();
if (data.Type == "WinForm")
{
if (content is System.Windows.Forms.Form form)
@@ -175,8 +193,6 @@
{
page.Child = (UIElement)content;
}
-
- PluginPackage.Get(content)?.Active();
}
}
@@ -196,5 +212,27 @@
}
Loaded -= UserControl_Loaded;
}
+
+ private string alarmInfo;
+ public string AlarmInfo
+ {
+ get => alarmInfo;
+ set
+ {
+ RaiseAndSetIfChanged(ref alarmInfo, value);
+ }
+ }
+
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ alarmBorder.Visibility = Visibility.Collapsed;
+ AlarmInfo = string.Empty;
+ }
+
+ public void ShowAlarm(string message)
+ {
+ AlarmInfo = message;
+ alarmBorder.Visibility = Visibility.Visible;
+ }
}
}
--
Gitblit v1.9.1