-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
144 lines (127 loc) · 3.06 KB
/
App.xaml.cs
File metadata and controls
144 lines (127 loc) · 3.06 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Windows;
using System.Data;
using System.Xml;
using System.Configuration;
using System.Collections;
using System.Diagnostics;
using System.Threading;
using Microsoft.Win32;
namespace SlideDiscWPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private const string cSyntax =
@"Syntax:
SlideDiscWpf: [rootPath] [options]
Options:
/c Configure screensaver (puts up message box) for compability with .scr screensavers.
/s Show screensaver for compability with .scr screensavers.
";
private const string cMutexName = "SlideDiscWPF";
private bool fIsScreenSaver;
private Mutex fAppMutex;
public App()
{
bool firstInstance;
fAppMutex = new Mutex(true, cMutexName, out firstInstance);
if (!firstInstance)
{
Debug.WriteLine("Instance already running.");
Shutdown();
return;
}
//InitializeComponent();
#if DEBUG && false
FolderTreeEnumerator.Test();
#endif
bool noShow = false;
bool syntaxError = false;
string rootPath = null;
{
string[] commandLineArgs = Environment.GetCommandLineArgs();
fIsScreenSaver = System.IO.Path.GetExtension(commandLineArgs[0]).Equals(".scr", StringComparison.OrdinalIgnoreCase);
IEnumerator p = commandLineArgs.GetEnumerator();
p.MoveNext(); // Skip exe name
while (p.MoveNext())
{
string arg = p.Current as string;
if (arg[0] == '-' || arg[0] == '/')
{
int colon = arg.IndexOf(':');
string option;
string value;
if (colon >= 0)
{
option = arg.Substring(1, colon - 1).ToLower();
value = arg.Substring(colon + 1);
}
else
{
option = arg.Substring(1).ToLower();
value = null;
}
switch (option)
{
case "c": // Screen saver configuration
MessageBox.Show("Right-click on the screen saver while it's running to change configuration.");
noShow = true;
break;
case "s": // Screen saver show
break; // do nothing
default:
syntaxError = true;
noShow = true;
break;
}
}
else if (rootPath == null)
{
rootPath = arg;
}
else
{
syntaxError = true;
noShow = true;
}
}
}
if (syntaxError)
{
MessageBox.Show(cSyntax);
}
if (noShow)
{
return;
}
SlideShowWindow mainWindow = new SlideShowWindow();
mainWindow.Height = 800; // QQQ Maximize the window here
mainWindow.Width = 800;
mainWindow.LoadState();
if (rootPath != null)
{
if (!string.Equals(mainWindow.RootPath, rootPath, StringComparison.OrdinalIgnoreCase))
{
mainWindow.SelectedDirectories = new string[] { rootPath };
}
mainWindow.RootPath = rootPath;
}
mainWindow.Show();
mainWindow.Start();
//Window otherWindow = new Window1();
//otherWindow.Show();
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
if (fAppMutex != null)
{
fAppMutex.Close();
fAppMutex = null;
}
}
}
}