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 BPA.Helper;
using BPASmartClient.CustomResource.Pages.Enums;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.Pages.View;
namespace BPASmartClient.SmallBatchingSystem
{
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
{
//1366*768
base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Json.Read();
Json.Read();
MenuInit();
MainView mv = new MainView();
Control.GetInstance.Init();
mv.TitleName = "黑菠萝自动化配料系统";
//mv.Show();
LoginView lv = new LoginView();
var res = lv.ShowDialog();
if (res != null && res == true)
{
Control.GetInstance.OperationLog("用户登录");
mv.Show();
}
else
mv.Close();
MainWindow = mv;
}
private void MenuInit()
{
#region 配方管理菜单
ObservableCollection RecipeManage = new ObservableCollection();
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "料仓管理",
AssemblyName = "BPASmartClient.SmallBatchingSystem",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Views.SiloManagementView"
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "出料口管理",
AssemblyName = "BPASmartClient.SmallBatchingSystem",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Views.OutletManagementView"
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方管理",
AssemblyName = "BPASmartClient.SmallBatchingSystem",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Views.RecipeView"
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方下发",
AssemblyName = "BPASmartClient.SmallBatchingSystem",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Views.RecipeControlView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
MainMenuName = "配方管理",
Alias = "Recipe Management",
subMenumodels = RecipeManage,
});
#endregion
#region 消息日志
ObservableCollection InfoLog = new ObservableCollection();
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "操作日志",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.UserLogView"
});
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "运行日志",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.RunLogView"
});
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "调试日志",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.DebugLogView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
MainMenuName = "消息日志",
Alias = "Message Log",
subMenumodels = InfoLog,
});
#endregion
#region 用户管理
ObservableCollection UserManager = new ObservableCollection();
UserManager.Add(new SubMenumodel()
{
SubMenuName = "用户登录",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.SubPagLoginView"
});
UserManager.Add(new SubMenumodel()
{
SubMenuName = "密码修改",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.PasswordChangeView"
});
UserManager.Add(new SubMenumodel()
{
SubMenuName = "用户管理",
AssemblyName = "BPASmartClient.CustomResource",
SubMenuVisibility = Visibility.Visible,
ToggleWindowPath = "Pages.View.UserManagerView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
MainMenuName = "用户管理",
Alias = "User Management",
subMenumodels = UserManager,
});
#endregion
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Json.Save();
Json.Save();
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
Json.Save();
}
}
}