-
Notifications
You must be signed in to change notification settings - Fork 0
/
AboutControlViewModel.cs
358 lines (325 loc) · 11.5 KB
/
AboutControlViewModel.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
// <copyright file="AboutControlViewModel.cs" company="None">
// MIT License (MIT). All rights reserved
// </copyright>
// <author>Christoph Gattnar</author>
// <summary>This is the AboutControlViewModel class.</summary>
namespace BlueDot
{
using System;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Media;
public class AboutControlViewModel : INotifyPropertyChanged
{
private ImageSource _ApplicationLogo;
private string _Title;
private string _Description;
private string _Version;
private ImageSource _PublisherLogo;
private string _Copyright;
private string _AdditionalNotes;
private string _HyperlinkText;
private Uri _Hyperlink;
private string _Publisher;
private bool _isSemanticVersioning;
public AboutControlViewModel()
{
Window = new Window();
Window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
Window.SizeToContent = SizeToContent.WidthAndHeight;
Window.ResizeMode = ResizeMode.NoResize;
Window.WindowStyle = WindowStyle.None;
Window.ShowInTaskbar = false;
Window.Title = "About";
Window.Deactivated += this.Window_Deactivated;
Assembly assembly = Assembly.GetEntryAssembly();
this.Version = assembly.GetName().Version.ToString();
this.Title = assembly.GetName().Name;
#if NET35 || NET40
AssemblyCopyrightAttribute copyright = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
AssemblyDescriptionAttribute description = Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
AssemblyCompanyAttribute company = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
#else
AssemblyCopyrightAttribute copyright = assembly.GetCustomAttribute<AssemblyCopyrightAttribute>();
AssemblyDescriptionAttribute description = assembly.GetCustomAttribute<AssemblyDescriptionAttribute>();
AssemblyCompanyAttribute company = assembly.GetCustomAttribute<AssemblyCompanyAttribute>();
#endif
this.Copyright = copyright.Copyright;
this.Description = description.Description;
this.Publisher = company.Company;
StringBuilder sb = new StringBuilder();
sb.AppendLine("Further information about BlueDot... Every 2 seconds BlueDot will send a key press to F15, this is a key most computers do not have.");
sb.AppendLine("Also BlueDot will keep it's icon visible in the system tray, And it will flash every two seconds to remind you your screen lock is disable.");
sb.AppendLine("You will need to click on \"System Tray Customize...\" find BlueDot and change icon setting to \"Show Icon and notifications\".");
sb.AppendLine(string.Empty);
sb.AppendLine("BlueDot is free and open source.");
sb.AppendLine(string.Empty);
sb.AppendLine("FAQ");
sb.AppendLine("Why id BlueDot an WPF application?");
sb.AppendLine("No reason I just wanted to create an WPF application.");
sb.AppendLine(string.Empty);
sb.AppendLine("Can I increase or decrease the time interval?");
sb.AppendLine("No I hard coded it, maybe later if people ask for it.");
sb.AppendLine(string.Empty);
sb.AppendLine("What does the stop button do?");
sb.AppendLine("Stops the icon from blinking and BlueDot will not send a key press.");
sb.AppendLine("");
sb.AppendLine("Do I need to press stop before exiting the program?");
sb.AppendLine("No I just thought it might be nice if you are going from meeting to meeting you don't have to restart the program.");
sb.AppendLine(string.Empty);
sb.AppendLine("Does BlueDot take up a lot of cpu resources?");
sb.AppendLine("No, it should have mininal impact on your machine.");
this.AdditionalNotes = sb.ToString();
}
/// <summary>
/// Gets or sets the application logo.
/// </summary>
/// <value>The application logo.</value>
public ImageSource ApplicationLogo
{
get
{
return this._ApplicationLogo;
}
set
{
if (this._ApplicationLogo != value)
{
this._ApplicationLogo = value;
this.OnPropertyChanged("ApplicationLogo");
}
}
}
/// <summary>
/// Gets or sets the application title.
/// </summary>
/// <value>The application title.</value>
public string Title
{
get
{
return this._Title;
}
set
{
if (this._Title != value)
{
this._Title = value;
this.OnPropertyChanged("Title");
}
}
}
/// <summary>
/// Gets or sets the application info.
/// </summary>
/// <value>The application info.</value>
public string Description
{
get
{
return this._Description;
}
set
{
if (this._Description != value)
{
this._Description = value;
this.OnPropertyChanged("Description");
}
}
}
/// <summary>
/// Gets or sets a value indicating whether Semantic Versioning is used.
/// </summary>
/// <value>Semantic Versioning</value>
public bool IsSemanticVersioning
{
get
{
return this._isSemanticVersioning;
}
set
{
this._isSemanticVersioning = value;
this.OnPropertyChanged("Version");
}
}
/// <summary>
/// Gets or sets the application version.
/// </summary>
/// <value>The application version.</value>
public string Version
{
get
{
if (this.IsSemanticVersioning)
{
var tmp = this._Version.Split('.');
var version = string.Format("{0}.{1}.{2}", tmp[0], tmp[1], tmp[2]);
return version;
}
return this._Version;
}
set
{
if (this._Version != value)
{
this._Version = value;
this.OnPropertyChanged("Version");
}
}
}
/// <summary>
/// Gets or sets the publisher logo.
/// </summary>
/// <value>The publisher logo.</value>
public ImageSource PublisherLogo
{
get
{
return this._PublisherLogo;
}
set
{
if (this._PublisherLogo != value)
{
this._PublisherLogo = value;
this.OnPropertyChanged("PublisherLogo");
}
}
}
/// <summary>
/// Gets or sets the publisher.
/// </summary>
/// <value>The publisher.</value>
public string Publisher
{
get
{
return this._Publisher;
}
set
{
if (this._Publisher != value)
{
this._Publisher = value;
this.OnPropertyChanged("Publisher");
}
}
}
/// <summary>
/// Gets or sets the copyright label.
/// </summary>
/// <value>The copyright label.</value>
public string Copyright
{
get
{
return this._Copyright;
}
set
{
if (this._Copyright != value)
{
this._Copyright = value;
this.OnPropertyChanged("Copyright");
}
}
}
/// <summary>
/// Gets or sets the hyperlink text.
/// </summary>
/// <value>The hyperlink text.</value>
public string HyperlinkText
{
get
{
return this._HyperlinkText;
}
set
{
try
{
this.Hyperlink = new Uri(value);
this._HyperlinkText = value;
this.OnPropertyChanged("HyperlinkText");
}
catch
{
}
}
}
/// <summary>
/// Gets or sets Hyperlink.
/// </summary>
/// <value>Hyperlink in about box.</value>
public Uri Hyperlink
{
get
{
return this._Hyperlink;
}
set
{
if (this._Hyperlink != value)
{
this._Hyperlink = value;
this.OnPropertyChanged("Hyperlink");
}
}
}
/// <summary>
/// Gets or sets AdditionalNotes.
/// </summary>
/// <value>The further info.</value>
public string AdditionalNotes
{
get
{
return this._AdditionalNotes;
}
set
{
if (this._AdditionalNotes != value)
{
this._AdditionalNotes = value;
this.OnPropertyChanged("AdditionalNotes");
}
}
}
/// <summary>
/// Gets or sets Window.
/// </summary>
/// <value>The Window.</value>
public Window Window
{
get;
set;
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
///Close Window.
/// </summary>
/// <param name="sender">Object System.</param>
/// <param name="e">Event Arguments.</param>
void Window_Deactivated(object sender, System.EventArgs e)
{
Window.Close();
}
/// <summary>
/// Called when a property value has changed.
/// </summary>
/// <param name="propertyName">The name of the property that has changed.</param>
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
}
}