Widow – Diff between revs 8 and 9

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 8 Rev 9
Line 1... Line 1...
1 using System; 1 using System;
2 using System.Threading; 2 using System.Threading;
3 using System.Threading.Tasks; 3 using System.Threading.Tasks;
-   4 using Widow.Properties;
Line 4... Line 5...
4   5  
5 namespace Widow 6 namespace Widow
6 { 7 {
7 public class WindowRescale : IDisposable 8 public class WindowManipulation : IDisposable
8 { 9 {
Line 9... Line 10...
9 #region Public Enums, Properties and Fields 10 #region Public Enums, Properties and Fields
Line 28... Line 29...
28   29  
Line 29... Line 30...
29 #endregion 30 #endregion
Line 30... Line 31...
30   31  
31 #region Constructors, Destructors and Finalizers 32 #region Constructors, Destructors and Finalizers
32   33  
33 public WindowRescale() 34 public WindowManipulation()
34 { 35 {
Line 35... Line 36...
35 CancellationTokenSource = new CancellationTokenSource(); 36 CancellationTokenSource = new CancellationTokenSource();
36 ApplyEveryTask = ApplyEvery(CancellationTokenSource.Token); 37 ApplyEveryTask = ApplyEvery(CancellationTokenSource.Token);
37 } 38 }
Line 38... Line 39...
38   39  
39 public WindowRescale(MainForm mainForm) : this() 40 public WindowManipulation(MainForm mainForm) : this()
Line 40... Line 41...
40 { 41 {
41 Form = mainForm; 42 Form = mainForm;
42   43  
43 Form.WindowCreated += Form_WindowCreated; 44 Form.WindowCreated += Form_WindowCreated;
Line -... Line 45...
-   45 }
-   46  
-   47 public WindowManipulation(MainForm mainForm, Windows.Windows windows) : this(mainForm)
-   48 {
-   49 Windows = windows;
-   50 }
-   51  
-   52 public WindowManipulation(MainForm mainForm, Windows.Windows windows, Settings settings) : this(mainForm,
-   53 windows)
-   54 {
-   55 OnWindowCreate = settings.OnWindowCreate;
44 } 56 ApplyEveryTimeEnabled = settings.ApplyEveryTimeEnabled;
45   57 if (int.TryParse(settings.ApplyEveryTime, out var time))
46 public WindowRescale(MainForm mainForm, Windows.Windows windows) : this(mainForm) 58 {
47 { 59 ApplyEveryTime = time;
48 Windows = windows; 60 }
Line 66... Line 78...
66 if (!OnWindowCreate) 78 if (!OnWindowCreate)
67 { 79 {
68 return; 80 return;
69 } 81 }
Line 70... Line 82...
70   82  
71 foreach (var window in Windows.Window) 83 if (!Windows.Contains(e.Name))
72 { -  
73 if (window.Name != e.Name) -  
74 { -  
75 continue; 84 {
76 } -  
77   -  
78 var hWnd = Helpers.FindWindowByTitle(window.Name); -  
79 if (hWnd == IntPtr.Zero) -  
80 { -  
81 continue; -  
82 } -  
83   -  
84 Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); 85 return;
-   86 }
-   87  
85 } 88 Apply();
Line 86... Line 89...
86 } 89 }
Line 87... Line 90...
87   90  
Line 97... Line 100...
97 if (hWnd == IntPtr.Zero) 100 if (hWnd == IntPtr.Zero)
98 { 101 {
99 continue; 102 continue;
100 } 103 }
Line -... Line 104...
-   104  
-   105 if (!Natives.GetWindowRect(hWnd, out var rect))
-   106 {
-   107 continue;
-   108 }
-   109  
-   110 var left = window.Left;
-   111 if (window.IgnoreLeft)
-   112 {
-   113 left = rect.Left;
-   114 }
-   115  
-   116 var top = window.Top;
-   117 if (window.IgnoreTop)
-   118 {
-   119 top = rect.Top;
-   120 }
-   121  
-   122 var width = window.Width;
-   123 if (window.IgnoreWidth)
-   124 {
-   125 width = rect.Left - rect.Right;
-   126 }
-   127  
-   128 var height = window.Height;
-   129 if (window.IgnoreHeight)
-   130 {
-   131 height = rect.Top - rect.Bottom;
-   132 }
101   133  
102 Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); 134 Natives.MoveWindow(hWnd, left, top, width, height, true);
103 } 135 }
Line 104... Line 136...
104 } 136 }