Widow – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | |||
3 | namespace Widow |
||
4 | { |
||
7 | office | 5 | public class WindowRescale : IDisposable |
1 | office | 6 | { |
7 | #region Public Enums, Properties and Fields |
||
8 | |||
9 | public bool OnWindowCreate { get; set; } |
||
10 | |||
6 | office | 11 | public MainForm Form { get; set; } |
1 | office | 12 | |
13 | #endregion |
||
14 | |||
15 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
16 | |||
17 | private Windows.Windows Windows { get; } |
||
18 | |||
19 | #endregion |
||
20 | |||
21 | #region Constructors, Destructors and Finalizers |
||
22 | |||
7 | office | 23 | public WindowRescale() |
1 | office | 24 | { |
25 | } |
||
26 | |||
7 | office | 27 | public WindowRescale(MainForm mainForm) : this() |
1 | office | 28 | { |
6 | office | 29 | Form = mainForm; |
1 | office | 30 | |
31 | Form.WindowCreated += Form_WindowCreated; |
||
32 | } |
||
33 | |||
7 | office | 34 | public WindowRescale(MainForm mainForm, Windows.Windows windows) : this(mainForm) |
1 | office | 35 | { |
36 | Windows = windows; |
||
37 | } |
||
38 | |||
39 | public void Dispose() |
||
40 | { |
||
41 | Form.WindowCreated -= Form_WindowCreated; |
||
42 | } |
||
43 | |||
44 | #endregion |
||
45 | |||
46 | #region Event Handlers |
||
47 | |||
48 | private void Form_WindowCreated(object sender, WindowCreatedEventArgs e) |
||
49 | { |
||
50 | if (!OnWindowCreate) |
||
51 | { |
||
52 | return; |
||
53 | } |
||
54 | |||
55 | foreach (var window in Windows.Window) |
||
56 | { |
||
57 | if (window.Name != e.Name) |
||
58 | { |
||
59 | continue; |
||
60 | } |
||
61 | |||
62 | var hWnd = Helpers.FindWindowByTitle(window.Name); |
||
63 | if (hWnd == IntPtr.Zero) |
||
64 | { |
||
65 | continue; |
||
66 | } |
||
67 | |||
68 | Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | #endregion |
||
7 | office | 73 | |
74 | #region Public Methods |
||
75 | |||
76 | public void Apply() |
||
77 | { |
||
78 | foreach (var window in Windows.Window) |
||
79 | { |
||
80 | var hWnd = Helpers.FindWindowByTitle(window.Name); |
||
81 | if (hWnd == IntPtr.Zero) |
||
82 | { |
||
83 | continue; |
||
84 | } |
||
85 | |||
86 | Natives.MoveWindow(hWnd, window.Left, window.Top, window.Width, window.Height, true); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | #endregion |
||
1 | office | 91 | } |
92 | } |