1 |
b4d47cc5
|
Oto Šťáva
|
using System.Drawing;
|
2 |
|
|
|
3 |
|
|
namespace DeltarobotVr.Launcher
|
4 |
|
|
{
|
5 |
|
|
public struct LayoutRectangle
|
6 |
|
|
{
|
7 |
|
|
public int Top;
|
8 |
|
|
public int Right;
|
9 |
|
|
public int Bottom;
|
10 |
|
|
public int Left;
|
11 |
|
|
|
12 |
|
|
public int Width => Right - Left;
|
13 |
|
|
public int Height => Bottom - Top;
|
14 |
|
|
|
15 |
|
|
public LayoutRectangle(int top, int right, int bottom, int left)
|
16 |
|
|
{
|
17 |
|
|
Top = top;
|
18 |
|
|
Right = right;
|
19 |
|
|
Bottom = bottom;
|
20 |
|
|
Left = left;
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
public LayoutRectangle(Rectangle rect) : this(rect.Top, rect.Right, rect.Bottom, rect.Left)
|
24 |
|
|
{
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
public Rectangle ToRectangle() => new Rectangle(Left, Top, Right - Left, Bottom - Top);
|
28 |
|
|
|
29 |
|
|
public LayoutRectangle RemoveFromTop(int value)
|
30 |
|
|
{
|
31 |
|
|
if (value > Height)
|
32 |
|
|
{
|
33 |
|
|
value = Height;
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
var result = new LayoutRectangle(Top, Right, Top + value, Left);
|
37 |
|
|
Top += value;
|
38 |
|
|
return result;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
public LayoutRectangle RemoveFromRight(int value)
|
42 |
|
|
{
|
43 |
|
|
if (value > Width)
|
44 |
|
|
{
|
45 |
|
|
value = Width;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
var result = new LayoutRectangle(Top, Right, Bottom, Right - value);
|
49 |
|
|
Right -= value;
|
50 |
|
|
return result;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
public LayoutRectangle RemoveFromBottom(int value)
|
54 |
|
|
{
|
55 |
|
|
if (value > Height)
|
56 |
|
|
{
|
57 |
|
|
value = Height;
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
var result = new LayoutRectangle(Bottom - value, Right, Bottom, Left);
|
61 |
|
|
Bottom -= value;
|
62 |
|
|
return result;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
public LayoutRectangle RemoveFromLeft(int value)
|
66 |
|
|
{
|
67 |
|
|
if (value > Width)
|
68 |
|
|
{
|
69 |
|
|
value = Width;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
var result = new LayoutRectangle(Top, Left + value, Bottom, Left);
|
73 |
|
|
Left += value;
|
74 |
|
|
return result;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
public LayoutRectangle Shrink(int value)
|
78 |
|
|
{
|
79 |
|
|
Top += value;
|
80 |
|
|
Right -= value;
|
81 |
|
|
Bottom -= value;
|
82 |
|
|
Left += value;
|
83 |
|
|
return this;
|
84 |
|
|
}
|
85 |
|
|
}
|
86 |
|
|
}
|