alielie
2026-03-02 12e606635c42ea20f4b7c2bdda5204237a4b4c96
WPFProject/Controls/MainTabControl.xaml.cs
@@ -1,6 +1,5 @@
using 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;
        }
    }
}