-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathGlobalWindowManager.cs
More file actions
52 lines (40 loc) · 1.16 KB
/
GlobalWindowManager.cs
File metadata and controls
52 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Windows.Forms;
namespace ReClassNET.UI
{
public sealed class GlobalWindowManagerEventArgs : EventArgs
{
public Form Form { get; }
public GlobalWindowManagerEventArgs(Form form)
{
Contract.Requires(form != null);
Form = form;
}
}
public static class GlobalWindowManager
{
private static readonly List<Form> windows = new List<Form>();
public static Form TopWindow => windows.LastOrDefault();
public static IEnumerable<Form> Windows => windows;
public static event EventHandler<GlobalWindowManagerEventArgs> WindowAdded;
public static event EventHandler<GlobalWindowManagerEventArgs> WindowRemoved;
public static void AddWindow(Form form)
{
Contract.Requires(form != null);
windows.Add(form);
form.TopMost = Program.Settings.StayOnTop;
WindowAdded?.Invoke(null, new GlobalWindowManagerEventArgs(form));
}
public static void RemoveWindow(Form form)
{
Contract.Requires(form != null);
if (windows.Remove(form))
{
WindowRemoved?.Invoke(null, new GlobalWindowManagerEventArgs(form));
}
}
}
}