-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDeckWindow.cs
52 lines (50 loc) · 1.43 KB
/
DeckWindow.cs
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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CropperDeck {
public class DeckWindow {
public DeckColumn Column;
public IntPtr Handle;
public WinAPI_Rect OrigRect = new WinAPI_Rect();
public string Title {
get => WinAPI.GetWindowText(Handle);
}
public CropMarginsResult GetCropMargins() {
var m = Column.CropMargins;
if (m.Func != null) {
return m.Func(this);
} else return new CropMarginsResult(m);
}
public DeckWindow(IntPtr hwnd, DeckColumn col) {
Handle = hwnd;
Column = col;
WinAPI.GetWindowRect(Handle, out OrigRect);
}
public int GetWidth() {
var m = GetCropMargins();
return OrigRect.Width - m.Left - m.Right;
}
public void Insert() {
WinAPI.SetParent(Handle, Column.WindowCtr.Handle);
}
public void Eject() {
WinAPI.SetParent(Handle, IntPtr.Zero);
WinAPI.SetWindowRect(Handle,
OrigRect.Left, OrigRect.Top, OrigRect.Right - OrigRect.Left, OrigRect.Bottom - OrigRect.Top);
}
public void Update() {
var stripHeight = 0;//Panel.ToolStrip.Height;
var height = Column.WindowCtr.Height - stripHeight;
if (height <= 0) return; // the deck's probably minimized
var width = Column.WindowCtr.Width;
var m = GetCropMargins();
WinAPI.SetWindowRect(Handle,
-m.Left, -m.Top + stripHeight,
width + m.Left + m.Right,
height + m.Top + m.Bottom);
}
}
}