-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rect.cs
32 lines (26 loc) · 778 Bytes
/
Rect.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
using System.Windows;
namespace Split_Schnitzel;
public struct Rect
{
public int X;
public int Y;
public int Width;
public int Height;
public Rect() { } // default values
public Rect(FrameworkElement element, UIElement? relativeTo = null)
{
Update(element, relativeTo);
}
public void Update(FrameworkElement element, UIElement? relativeTo = null)
{
// position
Point point = new(0, 0);
point = element.TranslatePoint(point, relativeTo);
X = (int) point.X;
Y = (int) point.Y;
// size
Width = (int) element.RenderSize.Width;
Height = (int) element.RenderSize.Height;
}
public override string ToString() => $"{X},{Y} : {Width}x{Height}";
}