Widow – Diff between revs 7 and 8
?pathlinks?
Rev 7 | Rev 8 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
- | 2 | using System.Threading; |
||
- | 3 | using System.Threading.Tasks; |
||
Line 2... | Line 4... | |||
2 | |
4 | |
|
3 | namespace Widow |
5 | namespace Widow |
|
4 | { |
6 | { |
|
5 | public class WindowRescale : IDisposable |
7 | public class WindowRescale : IDisposable |
|
6 | { |
8 | { |
|
Line 7... | Line 9... | |||
7 | #region Public Enums, Properties and Fields |
9 | #region Public Enums, Properties and Fields |
|
Line 8... | Line 10... | |||
8 | |
10 | |
|
- | 11 | public bool OnWindowCreate { get; set; } |
||
- | 12 | |
||
Line 9... | Line 13... | |||
9 | public bool OnWindowCreate { get; set; } |
13 | public int ApplyEveryTime { get; set; } |
|
Line 10... | Line 14... | |||
10 | |
14 | |
|
Line -... | Line 15... | |||
- | 15 | public bool ApplyEveryTimeEnabled { get; set; } |
||
- | 16 | |
||
11 | public MainForm Form { get; set; } |
17 | #endregion |
|
Line -... | Line 18... | |||
- | 18 | |
||
- | 19 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
- | 20 | |
||
- | 21 | private MainForm Form { get; } |
||
12 | |
22 | |
|
Line 13... | Line 23... | |||
13 | #endregion |
23 | private Windows.Windows Windows { get; } |
|
Line 14... | Line 24... | |||
14 | |
24 | |
|
15 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
25 | private CancellationTokenSource CancellationTokenSource { get; set; } |
|
- | 26 | |
||
- | 27 | private Task ApplyEveryTask { get; } |
||
16 | |
28 | |
|
Line 17... | Line 29... | |||
17 | private Windows.Windows Windows { get; } |
29 | #endregion |
|
18 | |
30 | |
|
19 | #endregion |
31 | #region Constructors, Destructors and Finalizers |
|
Line 37... | Line 49... | |||
37 | } |
49 | } |
|
Line 38... | Line 50... | |||
38 | |
50 | |
|
39 | public void Dispose() |
51 | public void Dispose() |
|
40 | { |
52 | { |
|
- | 53 | Form.WindowCreated -= Form_WindowCreated; |
||
- | 54 | CancellationTokenSource.Cancel(); |
||
- | 55 | ApplyEveryTask.Wait(); |
||
- | 56 | CancellationTokenSource.Dispose(); |
||
41 | Form.WindowCreated -= Form_WindowCreated; |
57 | CancellationTokenSource = null; |
|
Line 42... | Line 58... | |||
42 | } |
58 | } |
|
Line 43... | Line 59... | |||
43 | |
59 | |
|
Line 86... | Line 102... | |||
86 | Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); |
102 | Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); |
|
87 | } |
103 | } |
|
88 | } |
104 | } |
|
Line 89... | Line 105... | |||
89 | |
105 | |
|
- | 106 | #endregion |
||
- | 107 | |
||
- | 108 | #region Private Methods |
||
- | 109 | |
||
- | 110 | private async Task ApplyEvery(CancellationToken cancellationToken) |
||
- | 111 | { |
||
- | 112 | do |
||
- | 113 | { |
||
- | 114 | if (!ApplyEveryTimeEnabled) |
||
- | 115 | { |
||
- | 116 | await Task.Delay(1000, cancellationToken); |
||
- | 117 | continue; |
||
- | 118 | } |
||
- | 119 | |
||
- | 120 | await Task.Delay(ApplyEveryTime, cancellationToken); |
||
- | 121 | |
||
- | 122 | Apply(); |
||
- | 123 | } while (!cancellationToken.IsCancellationRequested); |
||
- | 124 | } |
||
- | 125 | |
||
90 | #endregion |
126 | #endregion |
|
91 | } |
127 | } |
|
92 | } |
128 | } |