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