Widow – Diff between revs 19 and 20
?pathlinks?
Rev 19 | Rev 20 | |||
---|---|---|---|---|
1 | using System; |
1 | using System; |
|
2 | using System.Threading; |
2 | using System.Threading; |
|
3 | using System.Windows.Forms; |
3 | using System.Windows.Forms; |
|
4 | |
4 | |
|
5 | namespace Widow |
5 | namespace Widow |
|
6 | { |
6 | { |
|
7 | internal class Program : IDisposable |
7 | internal class Program : IDisposable |
|
8 | { |
8 | { |
|
9 | #region Static Fields and Constants |
9 | #region Static Fields and Constants |
|
10 | |
10 | |
|
11 | private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid); |
11 | private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid); |
|
12 | |
12 | |
|
13 | private static Form _form; |
13 | private static Form _form; |
|
14 | |
14 | |
|
15 | #endregion |
15 | #endregion |
|
16 | |
16 | |
|
17 | #region Constructors, Destructors and Finalizers |
17 | #region Constructors, Destructors and Finalizers |
|
18 | |
18 | |
|
19 | public void Dispose() |
19 | public void Dispose() |
|
20 | { |
20 | { |
|
21 | _form?.Dispose(); |
21 | _form?.Dispose(); |
|
22 | _form = null; |
22 | _form = null; |
|
23 | } |
23 | } |
|
24 | |
24 | |
|
25 | #endregion |
25 | #endregion |
|
26 | |
26 | |
|
27 | #region Private Methods |
27 | #region Private Methods |
|
28 | |
28 | |
|
29 | /// <summary> |
29 | /// <summary> |
|
30 | /// The main entry point for the application. |
30 | /// The main entry point for the application. |
|
31 | /// </summary> |
31 | /// </summary> |
|
32 | [STAThread] |
32 | [STAThread] |
|
33 | private static void Main() |
33 | private static void Main() |
|
34 | { |
34 | { |
|
35 | if (Mutex.WaitOne(TimeSpan.Zero, true)) |
35 | if (Mutex.WaitOne(TimeSpan.Zero, true)) |
|
36 | { |
36 | { |
|
- | 37 | Application.EnableVisualStyles(); |
||
37 | Application.SetCompatibleTextRenderingDefault(false); |
38 | Application.SetCompatibleTextRenderingDefault(false); |
|
38 | _form = new MainForm(); |
39 | _form = new MainForm(); |
|
39 | Application.Run(); |
40 | Application.Run(); |
|
40 | Mutex.ReleaseMutex(); |
41 | Mutex.ReleaseMutex(); |
|
41 | return; |
42 | return; |
|
42 | } |
43 | } |
|
43 | |
44 | |
|
44 | // Foreground current other application window. |
45 | // Foreground current other application window. |
|
45 | Natives.PostMessage( |
46 | Natives.PostMessage( |
|
46 | (IntPtr) Natives.HWND_BROADCAST, |
47 | (IntPtr) Natives.HWND_BROADCAST, |
|
47 | Natives.WM_SHOWME, |
48 | Natives.WM_SHOWME, |
|
48 | IntPtr.Zero, |
49 | IntPtr.Zero, |
|
49 | IntPtr.Zero); |
50 | IntPtr.Zero); |
|
50 | } |
51 | } |
|
51 | |
52 | |
|
52 | #endregion |
53 | #endregion |
|
53 | } |
54 | } |
|
54 | } |
55 | } |
|
55 | |
56 | |
|
56 |
|
57 |
|
|
57 | |
58 | |
|
58 | |
59 | |
|
59 | |
60 | |