-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
83 lines (78 loc) · 2.73 KB
/
Copy pathApp.xaml.cs
File metadata and controls
83 lines (78 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using HandyControl.Data;
using HandyControl.Themes;
using HandyControl.Tools;
using AngelDLP.Views;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Windows;
using AngelDLP.PMC;
using AngelDLP.PPC;
using System.Threading;
using AngleDLP.Models;
using System.Threading.Tasks;
using AngelDLP.ViewModels;
namespace AngelDLP
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App
{
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
private static System.Threading.Mutex mutex;
protected override void OnStartup(StartupEventArgs e)
{
var currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += UnhandledExceptionOccured;
mutex = new System.Threading.Mutex(true, "AngleDLP");
if (mutex.WaitOne(0, false))
{
base.OnStartup(e);
}
else
{
MessageBox.Show("程序已经在运行!", "提示");
this.Shutdown();
}
}
private static void UnhandledExceptionOccured(object sender, UnhandledExceptionEventArgs args)
{
//全局异常记录
var e = (Exception)args.ExceptionObject;
//Common.Log4netHelper.WriteError("Application has crashed " + e.ToString());
MessageBox.Show($"something went wrong and the application must close:{e.ToString()} ", "Unhandled Error", MessageBoxButton.OK);
}
protected override void OnInitialized()
{
base.OnInitialized();
Container.Resolve<IRegionManager>().RegisterViewWithRegion("ContentRegion", typeof(NoneView));
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<PrintTaskSetup>();
containerRegistry.RegisterForNavigation<NoneView>();
containerRegistry.RegisterSingleton<IPartModelFactory, PartModelFactory>();
containerRegistry.RegisterSingleton<IProjectFactory, ProjectFactory>();
}
public static UserLogin login = new UserLogin();
public static UserLoginViewModel loginVM= new UserLoginViewModel();
protected override void InitializeShell(Window shell)
{
//登录
login.DataContext = loginVM;
if (login.ShowDialog() == false)
{
if (Application.Current != null)
{
Application.Current.Shutdown();
}
return;
}
base.InitializeShell(shell);
}
}
}