-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
120 lines (102 loc) · 3.63 KB
/
Program.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using Nfu.Properties;
using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Windows.Forms;
namespace Nfu
{
public enum TransferType
{
Ftp,
FtpsExplicit,
Sftp,
SftpKeys,
Cifs
}
static class Program
{
public static Core FormCore;
public static About FormAbout;
public static Cp FormCp;
public static bool AutoSaveSettings = true;
private static readonly Mutex Mutex = new Mutex(true, "NFU {537e6f56-11cb-461a-9983-634307543f5b}");
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Uncomment the following lines to change the UI culture in order to test translations
//Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("nl-NL");
//Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("nl-NL");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Use TLS 1.2, TLS 1.1 and TLS 1.0
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// Automatically save settings on change
Settings.Default.PropertyChanged += (sender, e) =>
{
if (AutoSaveSettings)
{
Settings.Default.Save();
}
};
try
{
if (args.Any(a => a == "debug"))
{
if (!Settings.Default.Debug)
{
try
{
if (!EventLog.SourceExists(Resources.AppName))
{
EventLog.CreateEventSource(Resources.AppName, "Application");
}
Settings.Default.Debug = true;
}
catch { }
}
return;
}
if (Mutex.WaitOne(TimeSpan.Zero, true))
{
if (Settings.Default.NeedsUpgrade)
{
Settings.Default.Upgrade();
Settings.Default.NeedsUpgrade = false;
}
if (Screen.AllScreens.Length > Settings.Default.Screen - 1)
Settings.Default.Screen = 0;
FormCore = new Core();
FormAbout = new About();
FormCp = new Cp();
FormCore.Setup();
if (Settings.Default.FirstRun)
{
FormCore.Load += (sender, e) =>
{
FormCp.ShowDialog();
};
}
if (args.Any(a => a == "minimized"))
{
FormCore.WindowState = FormWindowState.Minimized;
}
Application.Run(FormCore);
}
else
{
MessageBox.Show(Resources.AlreadyRunning,
Resources.AlreadyRunningTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}