Widow – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2  
3 namespace Widow
4 {
5 public class Apply : IDisposable
6 {
7 #region Public Enums, Properties and Fields
8  
9 public bool OnWindowCreate { get; set; }
10  
11 public Form1 Form { get; set; }
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  
23 public Apply()
24 {
25 }
26  
27 public Apply(Form1 form1) : this()
28 {
29 Form = form1;
30  
31 Form.WindowCreated += Form_WindowCreated;
32 }
33  
34 public Apply(Form1 form1, Windows.Windows windows) : this(form1)
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
73 }
74 }