-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
81d1cd2
commit 4332e82
Showing
5 changed files
with
53 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
|
||
namespace FrigoTab { | ||
|
||
public class ApplicationWindows : FrigoForm { | ||
public class ApplicationWindows : IDisposable { | ||
|
||
public Property<ApplicationWindow> Selected; | ||
public readonly LayerUpdater LayerUpdater; | ||
public Property<bool> Visible; | ||
private readonly IList<ApplicationWindow> windows = new List<ApplicationWindow>(); | ||
|
||
public ApplicationWindows (FrigoForm owner, WindowFinder finder) { | ||
Owner = owner; | ||
Bounds = owner.Bounds; | ||
ExStyle |= WindowExStyles.Transparent | WindowExStyles.Layered; | ||
Selected.Changed += (oldWindow, newWindow) => { | ||
oldWindow?.Selected.Set(false); | ||
newWindow?.Selected.Set(true); | ||
}; | ||
LayerUpdater = new LayerUpdater(this); | ||
Visible.Changed += (oldValue, value) => { | ||
foreach( ApplicationWindow window in windows ) { | ||
window.Visible = value; | ||
} | ||
}; | ||
Layout layout = new Layout(finder.Windows); | ||
foreach( WindowHandle handle in finder.Windows ) { | ||
windows.Add(new ApplicationWindow(owner, handle, windows.Count, layout.Bounds[handle], LayerUpdater)); | ||
windows.Add(new ApplicationWindow(owner, handle, windows.Count, layout.Bounds[handle])); | ||
} | ||
} | ||
|
||
public void SelectByIndex (int index) => Selected.Value = index >= 0 && index < windows.Count ? windows[index] : null; | ||
|
||
public void SelectByPoint (Point point) => | ||
Selected.Value = windows.FirstOrDefault(window => window.Bounds.Contains(point.ScreenToClient(WindowHandle))); | ||
~ApplicationWindows () => Dispose(); | ||
|
||
protected override void Dispose (bool disposing) { | ||
public void Dispose () { | ||
foreach( ApplicationWindow window in windows ) { | ||
window.Dispose(); | ||
window.Close(); | ||
} | ||
windows.Clear(); | ||
LayerUpdater.Dispose(); | ||
base.Dispose(disposing); | ||
} | ||
|
||
public void SelectByIndex (int index) => Selected.Value = index >= 0 && index < windows.Count ? windows[index] : null; | ||
public void SelectByPoint (Point point) => Selected.Value = windows.FirstOrDefault(window => window.Bounds.Contains(point)); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters