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 | 51 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/WPFProject/Controls/MainTabControl.xaml.cs b/WPFProject/Controls/MainTabControl.xaml.cs
index 41e8557..a476ebd 100644
--- a/WPFProject/Controls/MainTabControl.xaml.cs
+++ b/WPFProject/Controls/MainTabControl.xaml.cs
@@ -1,6 +1,5 @@
锘縰sing HMI.Base;
using HMI.Core.Api;
-using Microsoft.DwayneNeed.Interop;
using Panuon.WPF.UI;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -9,9 +8,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
-using System.Windows.Forms.Integration;
-using System.Windows.Media;
-using WPFProject.UI;
namespace WPFProject.Controls
{
@@ -42,7 +38,6 @@
private WinFormHolder winFormHolder;
public MainTabControl()
{
- IPlugin plugin = new WorkControl();
MenuItems = new ObservableCollection<PluginInfo>(PluginLoader.GetLoader().Menus);
SubMenuItems = MenuItems[0].Children;
this.DataContext = this;
@@ -162,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)
@@ -180,8 +193,6 @@
{
page.Child = (UIElement)content;
}
-
- PluginPackage.Get(content)?.Active();
}
}
@@ -201,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