-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
82 lines (76 loc) · 2.87 KB
/
App.xaml.cs
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
using MultiBranchTexter.View;
using MultiBranchTexter.Model;
using MultiBranchTexter.ViewModel;
using MultiBranchTexter.Resources;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Windows;
namespace MultiBranchTexter
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
// 创建ViewModel全局映射
Current.Properties.Add("ViewModelMap",new Dictionary<string, object>());
LanguageManager.Instance.PreloadLanguage();
Startup += App_Startup;
}
async void App_Startup(object sender, StartupEventArgs e)
{
MainWindow window = new MainWindow();
this.MainWindow = window;
if (e.Args.Length > 0)
{
string eArgs = e.Args[0];
for (int i = 1; i < e.Args.Length; i++)
{ eArgs += " " + e.Args[i]; }
ViewModelFactory.Main.OpenFile(eArgs);
}
window.Show();
//注册文件关联
await Dispatcher.BeginInvoke(new Action(
delegate
{
if (FileTypeRegister.FileTypeRegistered(".mbjson") == true)
{ return; }
try
{
string culInfo = Thread.CurrentThread.CurrentCulture.TextInfo.CultureName;
int i = culInfo.IndexOf('-');
if (i >= 0)
{
culInfo = culInfo[0..i];
Debug.WriteLine(culInfo);
}
FileTypeRegInfo fileTypeRegInfo = new FileTypeRegInfo(".mbjson")
{
Description = "MBJSON " + culInfo == "zh" ? "文件" : "File",
ExePath = Process.GetCurrentProcess().MainModule.FileName,
ExtendName = ".mbjson",
IconPath = AppDomain.CurrentDomain.BaseDirectory + "Resources\\Images\\icon.ico"
};
FileTypeRegister.RegisterFileType(fileTypeRegInfo);
}
catch
{
#if !DEBUG
MessageBox.Show(LanguageManager.Instance["Msg_FirstStart"]);
#endif
}
}));
await System.Threading.Tasks.Task.Delay(1000);// 这是为了让动画流畅走完
//检查更新
await Dispatcher.BeginInvoke(new Action(
delegate
{
ViewModelFactory.Settings.CheckUpdate();
}));
}
}
}