using BPASmartClient.CustomResource.Pages.Enums;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.Pages.View;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using BPASmart.Model;
using BPA.Helper;
using System.IO;
namespace BPASmart.VariableManager
{
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ServiceCenter.GetInstance.PipeInit();
Json.Read();
FileConfigModel.ConstPath = Json.Data.ProjectPath;
DataRead();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
MenuInit();
MainView mv = new MainView();
mv.WindowState = WindowState.Normal;
MainWindow = mv;
mv.Show();
ServiceCenter.GetInstance.ExitNotify = new Action(() => { App.Current.Dispatcher.Invoke(() => { mv.Close(); }); });
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
DataSave();
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
DataSave();
}
private void MenuInit()
{
#region 设备管理
ObservableCollection DeviceMonitor = new ObservableCollection();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备管理",
AssemblyName = "BPASmart.VariableManager",
ToggleWindowPath = "Views.CommunicationSetView",
SubMenuVisibility = Visibility.Visible,
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
MainMenuName = "设备管理",
Alias = "Device Management",
subMenumodels = DeviceMonitor,
});
#endregion
#region 变量管理,根据创建的通讯设备自动生成子菜单
ObservableCollection RecipeManage = new ObservableCollection();
ActionManage.GetInstance.Register(new Action