markus / KCOM / Extensions / VisualHelper.cs @ dea506e2
이력 | 보기 | 이력해설 | 다운로드 (1.35 KB)
1 | 8e5a4a6a | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | using System.Windows; |
||
7 | using System.Windows.Media; |
||
8 | |||
9 | namespace KCOM |
||
10 | { |
||
11 | public static class VisualHelper |
||
12 | { |
||
13 | public static Rect Bounds(this UIElement element, Visual parent) |
||
14 | { |
||
15 | return element.TransformToVisual(parent).TransformBounds(new Rect(element.RenderSize)); |
||
16 | } |
||
17 | |||
18 | public static Rect Rect(this UIElement element) |
||
19 | { |
||
20 | return new Rect(element.RenderSize); |
||
21 | } |
||
22 | |||
23 | public static MoveDirection Movement(this Rect Owner,Rect contentRect) |
||
24 | { |
||
25 | MoveDirection result = new MoveDirection(); |
||
26 | |||
27 | if(contentRect.Top > 0) |
||
28 | { |
||
29 | result.Up = true; |
||
30 | } |
||
31 | |||
32 | if(contentRect.Left > 0) |
||
33 | { |
||
34 | result.Left = true; |
||
35 | } |
||
36 | |||
37 | if(Owner.Width > contentRect.Right) |
||
38 | { |
||
39 | result.Right = true; |
||
40 | } |
||
41 | |||
42 | if (Owner.Height > contentRect.Bottom) |
||
43 | { |
||
44 | result.Down = true; |
||
45 | } |
||
46 | |||
47 | return result; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | public class MoveDirection |
||
52 | { |
||
53 | public bool Left { get; set; } |
||
54 | |||
55 | public bool Right { get; set; } |
||
56 | |||
57 | public bool Up { get; set; } |
||
58 | |||
59 | public bool Down { get; set; } |
||
60 | } |
||
61 | } |