Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
66 lines (57 loc) · 2.55 KB
/
Copy pathProgram.cs
File metadata and controls
66 lines (57 loc) · 2.55 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
using System;
using System.Linq;
using System.Windows.Forms;
namespace ScreenToRTSP
{
internal static class Program
{
static System.Threading.Mutex mutex = new System.Threading.Mutex(true, "{0FF32F1A-B829-450F-A9D4-ScreenToRTSP}");
[STAThread]
static void Main(string[] args)
{
if (!mutex.WaitOne(TimeSpan.Zero, true))
{
MessageBox.Show("O ScreenToRTSP já está em execução.\nPor favor, verifique a bandeja do sistema (perto do relógio).", "Screen to RTSP", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Application.ThreadException += (sender, e) => {
string p = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "crash.log");
System.IO.File.WriteAllText(p, e.Exception.ToString());
MessageBox.Show(e.Exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
string p = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "crash.log");
System.IO.File.WriteAllText(p, e.ExceptionObject.ToString());
MessageBox.Show(e.ExceptionObject.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
try {
ApplicationConfiguration.Initialize();
if (!ScreenToRTSP.Core.DependencyManager.CheckAndDownloadDependencies())
{
return;
}
var form = new Main();
if (args.Contains("--minimized"))
{
form.WindowState = FormWindowState.Minimized;
form.ShowInTaskbar = false;
form.Load += (s, e) => {
form.Hide();
form.StartAuto();
};
}
else if (args.Contains("--resume"))
{
form.Load += (s, e) => {
form.StartClick();
};
}
Application.Run(form);
} catch (Exception ex) {
string p = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "crash.log");
System.IO.File.WriteAllText(p, ex.ToString());
MessageBox.Show(ex.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}