-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
102 lines (87 loc) · 4.33 KB
/
Program.cs
File metadata and controls
102 lines (87 loc) · 4.33 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Windows.Forms;
using Common.Logger;
using SharpFile.ConfigConverters;
using SharpFile.Infrastructure;
namespace SharpFile {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string settingsVersion = string.Empty;
string assemblyVersion = string.Empty;
if (!Settings.CompareSettingsVersion(ref settingsVersion, ref assemblyVersion)) {
ConfigConverter configConverter = ConfigConverterFactory.GetConfigConverter(settingsVersion, assemblyVersion);
string message = configConverter.GetMessage();
// Show the modal dialog asking about converting the settings.
DialogResult dialogResult = MessageBox.Show(message, "Convert Settings?",
MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.OK) {
configConverter.Convert();
startProgram();
} else if (dialogResult == DialogResult.Cancel) {
Application.Exit();
}
// TODO: Write XSL to convert old version of settings XML to new version of settings XML.
/*
string message = string.Format(@"
The current configuration file version is {0}. SharpFile's current version is {1}.
Settings might have changed between the two versions, so a conversion might be necessary.
Press YES to convert the current settings to this version of SharpFile.
Press NO to ignore any settings changes. Note that this might lose custom settings, or might change behavior.
Press CANCEL to exit SharpFile.",
settingsVersion,
assemblyVersion);
// Show the modal dialog asking about converting the settings.
DialogResult dialogResult = MessageBox.Show(message, "Convert Settings?",
MessageBoxButtons.YesNoCancel);
if (dialogResult == DialogResult.Yes) {
// TODO: Convert settings file.
Settings.Instance.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
} else if (dialogResult == DialogResult.No) {
// Start the program normally.
} else if (dialogResult == DialogResult.Cancel) {
Application.Exit();
}
*/
} else {
startProgram();
}
}
private static void startProgram() {
Application.ApplicationExit += delegate {
Settings.Instance.Logger.Log(LogLevelType.Verbose,
"ApplicationExit");
Settings.Save(Settings.Instance);
};
if (Settings.Instance.ParentType == ParentType.Dual) {
Settings.Instance.Logger.Log(LogLevelType.Verbose,
"Start the Dual program");
/*
using (KeyboardHook keyboardHook = new KeyboardHook(HookType.WH_KEYBOARD)) {
keyboardHook.KeyDown += delegate(object sender, KeyEventArgs e) {
Settings.Instance.Logger.Log(LogLevelType.Verbose,
"Keyboard hook event fired for key: {0} w/ modifier: {1}",
e.KeyCode.ToString(),
e.Modifiers.ToString());
foreach (Tool tool in Settings.Instance.DualParent.Tools) {
if (tool.Key.HasValue && e.KeyCode == tool.Key.Value.PrimaryKey) {
if (e.Modifiers == tool.Key.Value.Modifiers) {
tool.Execute();
break;
}
}
}
};
Application.Run(new SharpFile.UI.DualParent());
}
*/
Application.Run(new SharpFile.UI.DualParent());
}
}
}
}