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