개정판 dbddfdd0
issue #0000 color select 제거
Change-Id: I026e52ed99c0f2ad2b48692a8ae111024aab9d6e
KCOM/Extensions/VisualHelper.cs | ||
---|---|---|
1 |
using System; |
|
1 |
using MarkupToPDF.Common; |
|
2 |
using System; |
|
2 | 3 |
using System.Collections.Generic; |
3 | 4 |
using System.Linq; |
4 | 5 |
using System.Text; |
5 | 6 |
using System.Threading.Tasks; |
6 | 7 |
using System.Windows; |
8 |
using System.Windows.Controls; |
|
7 | 9 |
using System.Windows.Media; |
8 | 10 |
|
9 | 11 |
namespace KCOM |
... | ... | |
99 | 101 |
//results.AddRange(subChildren); |
100 | 102 |
} |
101 | 103 |
} |
104 |
|
|
105 |
public static IEnumerable<CommentUserInfo> FindComment(this System.Windows.Controls.Canvas canvas, Rect searchRect) |
|
106 |
{ |
|
107 |
foreach (CommentUserInfo child in canvas.FindAllChildren(x=>x is CommentUserInfo)) |
|
108 |
{ |
|
109 |
if (child is CommentUserInfo comment) |
|
110 |
{ |
|
111 |
if (searchRect.IntersectsWith(child.ItemRect)) |
|
112 |
{ |
|
113 |
yield return child; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
public static CommentUserInfo FindDistanceComment(this Canvas canvas, Point point,double squareSize = 1) |
|
120 |
{ |
|
121 |
double minDistance = double.MaxValue; |
|
122 |
CommentUserInfo closestComment = null; |
|
123 |
|
|
124 |
Rect searchRect = new Rect( |
|
125 |
point.X - squareSize, |
|
126 |
point.Y - squareSize, |
|
127 |
squareSize * 2, |
|
128 |
squareSize * 2 |
|
129 |
); |
|
130 |
|
|
131 |
foreach (CommentUserInfo child in canvas.FindComment(searchRect)) |
|
132 |
{ |
|
133 |
if (child is CommentUserInfo comment) |
|
134 |
{ |
|
135 |
double left = comment.ItemRect.Left; |
|
136 |
double top = comment.ItemRect.Top; |
|
137 |
double centerX = left + comment.ItemRect.Width / 2; |
|
138 |
double centerY = top + comment.ItemRect.Height / 2; |
|
139 |
double distance = Math.Sqrt(Math.Pow(point.X - centerX, 2) + Math.Pow(point.Y - centerY, 2)); |
|
140 |
|
|
141 |
if (distance < minDistance) |
|
142 |
{ |
|
143 |
minDistance = distance; |
|
144 |
closestComment = comment; |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
return closestComment; |
|
150 |
} |
|
102 | 151 |
} |
103 | 152 |
|
104 | 153 |
public class MoveDirection |
내보내기 Unified diff