markus / KCOM / Controls / AdornerFinal.xaml.cs @ b643fcca
이력 | 보기 | 이력해설 | 다운로드 (71.9 KB)
1 | 787a4489 | KangIngu | using KCOM.Common; |
---|---|---|---|
2 | d128ceb2 | humkyung | using KCOM.Events; |
3 | 787a4489 | KangIngu | using MarkupToPDF.Common; |
4 | 684ef11c | ljiyeon | using MarkupToPDF.Controls.Cad; |
5 | 787a4489 | KangIngu | using MarkupToPDF.Controls.Common; |
6 | using MarkupToPDF.Controls.Etc; |
||
7 | using MarkupToPDF.Controls.Line; |
||
8 | 105359ce | ljiyeon | using MarkupToPDF.Controls.Parsing; |
9 | 787a4489 | KangIngu | using MarkupToPDF.Controls.Polygon; |
10 | using MarkupToPDF.Controls.Shape; |
||
11 | using MarkupToPDF.Controls.Text; |
||
12 | using System; |
||
13 | using System.Collections.Generic; |
||
14 | 53880c83 | ljiyeon | using System.Diagnostics; |
15 | 787a4489 | KangIngu | using System.Linq; |
16 | using System.Reactive.Linq; |
||
17 | using System.Text; |
||
18 | 8e5a4a6a | taeseongkim | using System.Threading.Tasks; |
19 | 787a4489 | KangIngu | using System.Windows; |
20 | using System.Windows.Controls; |
||
21 | using System.Windows.Controls.Primitives; |
||
22 | using System.Windows.Input; |
||
23 | using System.Windows.Media; |
||
24 | using Telerik.Windows.Controls; |
||
25 | |||
26 | namespace KCOM.Controls |
||
27 | { |
||
28 | f513c215 | humkyung | public class MyThumb : Thumb |
29 | { |
||
30 | public MyThumb() |
||
31 | { |
||
32 | this.Opacity = 0.6; |
||
33 | this.MouseEnter += MyThumb_MouseEnter; |
||
34 | this.MouseLeave += MyThumb_MouseLeave; |
||
35 | } |
||
36 | |||
37 | /// <summary> |
||
38 | d2114d3b | humkyung | /// translate thumb with given delta and angle |
39 | /// </summary> |
||
40 | /// <param name="e"></param> |
||
41 | /// <param name="angle"></param> |
||
42 | 0d00f9c8 | humkyung | public void Translate(double dx, double dy, double angle) |
43 | d2114d3b | humkyung | { |
44 | double radian = angle * Math.PI / 180; |
||
45 | double cos = Math.Cos(radian); |
||
46 | double sin = Math.Sin(radian); |
||
47 | |||
48 | 0d00f9c8 | humkyung | double _dx = dx * cos - dy * sin; |
49 | double _dy = dx * sin + dy * cos; |
||
50 | Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx); |
||
51 | Canvas.SetTop(this, Canvas.GetTop(this) + _dy); |
||
52 | d2114d3b | humkyung | } |
53 | |||
54 | /// <summary> |
||
55 | f513c215 | humkyung | /// </summary> |
56 | /// <param name="sender"></param> |
||
57 | /// <param name="e"></param> |
||
58 | private void MyThumb_MouseLeave(object sender, MouseEventArgs e) |
||
59 | { |
||
60 | this.Opacity = 0.6; |
||
61 | } |
||
62 | |||
63 | /// <summary> |
||
64 | /// |
||
65 | /// </summary> |
||
66 | /// <param name="sender"></param> |
||
67 | /// <param name="e"></param> |
||
68 | private void MyThumb_MouseEnter(object sender, MouseEventArgs e) |
||
69 | { |
||
70 | this.Opacity = 1.0; |
||
71 | } |
||
72 | } |
||
73 | |||
74 | 787a4489 | KangIngu | /// <summary> |
75 | /// Interaction logic for AdornerFinal.xaml |
||
76 | /// </summary> |
||
77 | public class AdornerMember |
||
78 | { |
||
79 | public UIElement DrawingData { get; set; } |
||
80 | public ControlType Drawingtype { get; set; } |
||
81 | public double DrawingAngle { get; set; } |
||
82 | f513c215 | humkyung | public List<MyThumb> ThumbList { get; set; } |
83 | c8e9b3e4 | ljiyeon | public string Symbol_ID { get; set; } |
84 | 53880c83 | ljiyeon | public long Group_ID { get; set; } |
85 | 508c3ac5 | humkyung | |
86 | /// <summary> |
||
87 | /// update thumb |
||
88 | /// </summary> |
||
89 | public void UpdateThumb() |
||
90 | { |
||
91 | var path = this.DrawingData as IPath; |
||
92 | for (int i = 0; i < path.PointSet.Count; ++i) |
||
93 | { |
||
94 | Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X); |
||
95 | Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y); |
||
96 | } |
||
97 | |||
98 | if (this.DrawingData as ArrowTextControl != null) |
||
99 | { |
||
100 | if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우 |
||
101 | { |
||
102 | List<Point> ps = new List<Point>(); |
||
103 | |||
104 | var temp = this.DrawingData as ArrowTextControl; |
||
105 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
106 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
107 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
108 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
109 | |||
110 | if (temp.isFixed) |
||
111 | { |
||
112 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
113 | var testP = endP; |
||
114 | if (ps[0] == endP) //상단 |
||
115 | { |
||
116 | testP = new Point(endP.X, endP.Y - 50); |
||
117 | } |
||
118 | else if (ps[1] == endP) //하단 |
||
119 | { |
||
120 | testP = new Point(endP.X, endP.Y + 50); |
||
121 | } |
||
122 | else if (ps[2] == endP) //좌단 |
||
123 | { |
||
124 | testP = new Point(endP.X - 50, endP.Y); |
||
125 | } |
||
126 | else if (ps[3] == endP) //우단 |
||
127 | { |
||
128 | testP = new Point(endP.X + 50, endP.Y); |
||
129 | } |
||
130 | Canvas.SetLeft(this.ThumbList[1], testP.X); |
||
131 | Canvas.SetTop(this.ThumbList[1], testP.Y); |
||
132 | } |
||
133 | else |
||
134 | { |
||
135 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
136 | var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
137 | Canvas.SetLeft(this.ThumbList[1], tempP.X); |
||
138 | Canvas.SetTop(this.ThumbList[1], tempP.Y); |
||
139 | } |
||
140 | } |
||
141 | } |
||
142 | } |
||
143 | 554aae3b | humkyung | |
144 | /// <summary> |
||
145 | /// rotate members about given position and angle |
||
146 | /// </summary> |
||
147 | /// <param name="at"></param> |
||
148 | /// <param name="angle">in degree</param> |
||
149 | public void RotateAbout(Point at, double angle) |
||
150 | { |
||
151 | for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++) |
||
152 | { |
||
153 | (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle); |
||
154 | } |
||
155 | (this.DrawingData as CommentUserInfo).UpdateControl(); |
||
156 | |||
157 | this.UpdateThumb(); |
||
158 | } |
||
159 | 787a4489 | KangIngu | } |
160 | 4913851c | humkyung | |
161 | 787a4489 | KangIngu | public partial class AdornerFinal : UserControl |
162 | { |
||
163 | public TextBox editTextBox { get; set; } |
||
164 | #region 공용 인스턴스 |
||
165 | 4913851c | humkyung | public List<AdornerMember> Members { get; } = new List<AdornerMember>(); |
166 | 787a4489 | KangIngu | public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>(); |
167 | b643fcca | taeseongkim | |
168 | private double angleValue; |
||
169 | |||
170 | public double AngleValue { get => angleValue; |
||
171 | set |
||
172 | { |
||
173 | if(angleValue != value) |
||
174 | { |
||
175 | angleValue = value; |
||
176 | } |
||
177 | } |
||
178 | } |
||
179 | |||
180 | |||
181 | 787a4489 | KangIngu | public bool IsTextAngle = false; |
182 | public Rect BorderSize { get; set; } |
||
183 | public bool TextCompensation = false; |
||
184 | public bool isDragging { get; set; } |
||
185 | public Thumb DraggerThumb { get; set; } |
||
186 | public RadDropDownButton dropData; |
||
187 | public RadCalendar dropCalendar; |
||
188 | public Thumb mainDragThumb { get; set; } |
||
189 | |||
190 | 4913851c | humkyung | private bool disposed; |
191 | |||
192 | 787a4489 | KangIngu | public Point reSizePoint { get; set; } |
193 | 992a98b4 | KangIngu | private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung |
194 | 0d00f9c8 | humkyung | private Point MouseDownPoint = new Point(); |
195 | private Point CurrentMousePoint = new Point(); |
||
196 | 787a4489 | KangIngu | #endregion |
197 | #region 생성자 |
||
198 | private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e) |
||
199 | { |
||
200 | dropData = sender as RadDropDownButton; |
||
201 | } |
||
202 | 4913851c | humkyung | |
203 | 787a4489 | KangIngu | private void Date_Calendar_Loaded(object sender, RoutedEventArgs e) |
204 | { |
||
205 | dropCalendar = sender as RadCalendar; |
||
206 | dropCalendar.SelectionChanged += (sen, ea) => |
||
207 | { |
||
208 | dropData.IsOpen = false; |
||
209 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
210 | 787a4489 | KangIngu | { |
211 | 4913851c | humkyung | DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl; |
212 | 787a4489 | KangIngu | data.Text = dropCalendar.SelectedDate.Value.ToShortDateString(); |
213 | } |
||
214 | }; |
||
215 | } |
||
216 | 4913851c | humkyung | |
217 | 787a4489 | KangIngu | public AdornerFinal() |
218 | { |
||
219 | InitializeComponent(); |
||
220 | BorderSize = new Rect(); |
||
221 | _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true }); |
||
222 | 4913851c | humkyung | } |
223 | |||
224 | ~AdornerFinal() |
||
225 | { |
||
226 | this.Dispose(false); |
||
227 | } |
||
228 | |||
229 | public void Dispose() |
||
230 | { |
||
231 | this.Dispose(true); |
||
232 | GC.SuppressFinalize(this); |
||
233 | } |
||
234 | |||
235 | protected virtual void Dispose(bool disposing) |
||
236 | { |
||
237 | if (this.disposed) return; |
||
238 | if (disposing) |
||
239 | { |
||
240 | foreach (var member in this.Members) |
||
241 | { |
||
242 | if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData)) |
||
243 | Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo); |
||
244 | } |
||
245 | // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
||
246 | } |
||
247 | // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
||
248 | this.disposed = true; |
||
249 | 787a4489 | KangIngu | } |
250 | |||
251 | void DragThumb_Loaded(object sender, RoutedEventArgs e) |
||
252 | { |
||
253 | mainDragThumb = DragThumb; |
||
254 | } |
||
255 | |||
256 | public AdornerFinal(CommentUserInfo objectData) : this() |
||
257 | { |
||
258 | InitializeComponent(); |
||
259 | objectData.IsHitTestVisible = false; |
||
260 | if ((objectData as ArrowTextControl) != null) |
||
261 | { |
||
262 | (objectData as ArrowTextControl).Base_TextBox.Focusable = true; |
||
263 | } |
||
264 | Canvas.SetZIndex(objectData, 84); |
||
265 | try |
||
266 | { |
||
267 | 05009a0e | ljiyeon | ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData); |
268 | 787a4489 | KangIngu | this.ContainerContent.Children.Add(objectData); |
269 | } |
||
270 | 1066bae3 | ljiyeon | catch (Exception ex) |
271 | 787a4489 | KangIngu | { |
272 | |||
273 | } |
||
274 | 1066bae3 | ljiyeon | |
275 | 787a4489 | KangIngu | SetAdornerMember(objectData as CommentUserInfo); |
276 | this.Focus(); |
||
277 | } |
||
278 | 4913851c | humkyung | |
279 | 9b7cda70 | KangIngu | public AdornerFinal(List<CommentUserInfo> objectData) : this() |
280 | 787a4489 | KangIngu | { |
281 | InitializeComponent(); |
||
282 | foreach (var item in objectData) |
||
283 | { |
||
284 | //item.IsHitTestVisible = false; |
||
285 | if ((item as ArrowTextControl) != null) |
||
286 | { |
||
287 | (item as ArrowTextControl).Base_TextBox.Focusable = true; |
||
288 | } |
||
289 | try |
||
290 | { |
||
291 | a0bab669 | KangIngu | Canvas.SetZIndex(item, 80); |
292 | 05009a0e | ljiyeon | ViewerDataModel.Instance.MarkupControls_USER.Remove(item); |
293 | 787a4489 | KangIngu | this.ContainerContent.Children.Add(item); |
294 | } |
||
295 | 53880c83 | ljiyeon | catch //(Exception ex) |
296 | 787a4489 | KangIngu | { |
297 | } |
||
298 | 1066bae3 | ljiyeon | finally |
299 | { |
||
300 | |||
301 | } |
||
302 | 787a4489 | KangIngu | } |
303 | 4913851c | humkyung | this.SetAdornerMember(objectData); |
304 | 787a4489 | KangIngu | this.Focus(); |
305 | } |
||
306 | |||
307 | 62b6bcde | humkyung | public Point Centeroid |
308 | { |
||
309 | get |
||
310 | { |
||
311 | List<Point> pts = new List<Point>(); |
||
312 | |||
313 | #region 센터 포인트 구하기 (그룹핑) |
||
314 | foreach (var item in this.Members) |
||
315 | { |
||
316 | if (item.DrawingData.GetType().Name == "TextControl") |
||
317 | { |
||
318 | if (AngleValue == 0) |
||
319 | { |
||
320 | fa48eb85 | taeseongkim | AngleValue = (item.DrawingData as TextControl).CommentAngle; |
321 | 62b6bcde | humkyung | } |
322 | double X = Canvas.GetLeft((item.DrawingData as TextControl)); |
||
323 | double Y = Canvas.GetTop((item.DrawingData as TextControl)); |
||
324 | pts.Add(new Point(X, Y)); |
||
325 | } |
||
326 | else |
||
327 | { |
||
328 | pts.AddRange((item.DrawingData as IPath).PointSet); |
||
329 | } |
||
330 | } |
||
331 | #endregion |
||
332 | |||
333 | return MathSet.FindCentroid(pts); |
||
334 | } |
||
335 | } |
||
336 | |||
337 | b643fcca | taeseongkim | #endregion |
338 | #region 메서드 |
||
339 | public Rect getAdornerSize() |
||
340 | 787a4489 | KangIngu | { |
341 | return BorderSize; |
||
342 | } |
||
343 | public void addMemberControl(UIElement objectData) |
||
344 | { |
||
345 | this.ContainerContent.Children.Add(objectData); |
||
346 | SetAdornerMember(objectData as CommentUserInfo); |
||
347 | this.Focus(); |
||
348 | } |
||
349 | /// <summary> |
||
350 | /// UIElement를 종류에 맞게 등록시킴 |
||
351 | /// </summary> |
||
352 | /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param> |
||
353 | public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member) |
||
354 | 53880c83 | ljiyeon | { |
355 | 787a4489 | KangIngu | switch (member.GetType().Name) |
356 | { |
||
357 | #region 컨트롤 조건 |
||
358 | 554aae3b | humkyung | case "LineControl": |
359 | case "PolygonControl": |
||
360 | 787a4489 | KangIngu | case "ArrowControl": |
361 | 554aae3b | humkyung | case "ArcControl": |
362 | case "ArrowArcControl": |
||
363 | case "ArrowControl_Multi": |
||
364 | case "RectangleControl": |
||
365 | case "TriControl": |
||
366 | case "CircleControl": |
||
367 | case "CloudControl": |
||
368 | case "RectCloudControl": |
||
369 | case "InkControl": |
||
370 | case "InsideWhiteControl": |
||
371 | case "OverlapWhiteControl": |
||
372 | case "ClipWhiteControl": |
||
373 | case "CoordinateControl": |
||
374 | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
||
375 | 787a4489 | KangIngu | break; |
376 | case "ArrowTextControl": |
||
377 | 4913851c | humkyung | this.Members.Add(new AdornerMember |
378 | 53880c83 | ljiyeon | { |
379 | DrawingData = member, |
||
380 | Drawingtype = ControlType.ArrowTextControl, |
||
381 | f513c215 | humkyung | ThumbList = new List<MyThumb>(), |
382 | 53880c83 | ljiyeon | Symbol_ID = member.SymbolID, |
383 | Group_ID = member.GroupID, |
||
384 | }); |
||
385 | 787a4489 | KangIngu | (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
386 | fa48eb85 | taeseongkim | AngleValue = (member as ArrowTextControl).CommentAngle; |
387 | 787a4489 | KangIngu | Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a => |
388 | { |
||
389 | TextCompensation = false; |
||
390 | BorderUpdate(); |
||
391 | if ((a.Sender as TextBox).Text == "") //보류 |
||
392 | { |
||
393 | this.ContainerContent.Children.Remove(member); |
||
394 | this.Visibility = Visibility.Collapsed; |
||
395 | } |
||
396 | }); |
||
397 | break; |
||
398 | 554aae3b | humkyung | case "ImgControl": |
399 | 2d2252ba | ljiyeon | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
400 | fa48eb85 | taeseongkim | AngleValue = (member as ImgControl).CommentAngle; |
401 | 2d2252ba | ljiyeon | break; |
402 | 787a4489 | KangIngu | case "DateControl": |
403 | 2d2252ba | ljiyeon | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
404 | fa48eb85 | taeseongkim | AngleValue = (member as DateControl).CommentAngle; |
405 | 2d2252ba | ljiyeon | break; |
406 | 787a4489 | KangIngu | case "SignControl": |
407 | 2d2252ba | ljiyeon | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
408 | fa48eb85 | taeseongkim | AngleValue = (member as SignControl).CommentAngle; |
409 | 2d2252ba | ljiyeon | break; |
410 | 787a4489 | KangIngu | case "SymControl": |
411 | 2d2252ba | ljiyeon | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
412 | fa48eb85 | taeseongkim | AngleValue = (member as SymControl).CommentAngle; |
413 | 2d2252ba | ljiyeon | break; |
414 | 787a4489 | KangIngu | case "SymControlN": |
415 | 554aae3b | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
416 | fa48eb85 | taeseongkim | AngleValue = (member as SymControlN).CommentAngle; |
417 | 787a4489 | KangIngu | break; |
418 | case "TextControl": |
||
419 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
420 | 787a4489 | KangIngu | RectangleGeometry Data = new RectangleGeometry |
421 | { |
||
422 | Rect = new Rect() |
||
423 | { |
||
424 | X = Canvas.GetLeft((member as TextControl)), |
||
425 | Y = Canvas.GetTop((member as TextControl)), |
||
426 | Width = (member as TextControl).Base_TextBlock.ActualWidth / 2, |
||
427 | Height = (member as TextControl).Base_TextBlock.ActualHeight / 2, |
||
428 | //Width = (member as TextControl).BoxWidth / 2, |
||
429 | //Height = (member as TextControl).BoxHeight / 2, |
||
430 | } |
||
431 | }; |
||
432 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
433 | Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV); |
||
434 | |||
435 | |||
436 | DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
||
437 | DragThumb.RenderTransform = new RotateTransform() |
||
438 | { |
||
439 | fa48eb85 | taeseongkim | Angle = (member as TextControl).CommentAngle, |
440 | 9b7cda70 | KangIngu | //CenterX = middle.X, |
441 | //CenterY = middle.Y, |
||
442 | 787a4489 | KangIngu | }; |
443 | |||
444 | AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
||
445 | AdornerBorder.RenderTransform = new RotateTransform() |
||
446 | { |
||
447 | fa48eb85 | taeseongkim | Angle = (member as TextControl).CommentAngle, |
448 | 9b7cda70 | KangIngu | //CenterX = middle.X, |
449 | //CenterY = middle.Y, |
||
450 | 787a4489 | KangIngu | }; |
451 | Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
||
452 | { |
||
453 | TextCompensation = true; |
||
454 | BorderUpdate(); |
||
455 | ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; |
||
456 | }); |
||
457 | Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a => |
||
458 | { |
||
459 | TextCompensation = false; |
||
460 | BorderUpdate(); |
||
461 | if ((a.Sender as TextBox).Text == "") //보류 |
||
462 | { |
||
463 | this.ContainerContent.Children.Remove(member); |
||
464 | this.Visibility = Visibility.Collapsed; |
||
465 | } |
||
466 | 9b7cda70 | KangIngu | |
467 | //((TextControl)member).UnEditingMode(); |
||
468 | //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed; |
||
469 | //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed; |
||
470 | //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed; |
||
471 | 787a4489 | KangIngu | }); |
472 | break; |
||
473 | default: |
||
474 | break; |
||
475 | #endregion |
||
476 | } |
||
477 | 554aae3b | humkyung | |
478 | 787a4489 | KangIngu | if (member.GetType().Name == "TextControl") |
479 | { |
||
480 | TextControl content = ((TextControl)member); |
||
481 | content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
||
482 | content.EndPoint = content.StartPoint; |
||
483 | } |
||
484 | else |
||
485 | { |
||
486 | RegistryPoint(member); |
||
487 | } |
||
488 | BorderUpdate(); |
||
489 | 4913851c | humkyung | |
490 | if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); |
||
491 | 787a4489 | KangIngu | } |
492 | |||
493 | private void ViewBoxRotate(UIElement member) |
||
494 | { |
||
495 | AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5); |
||
496 | DragThumb.RenderTransformOrigin = new Point(0.5, 0.5); |
||
497 | fa48eb85 | taeseongkim | AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle }; |
498 | DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle }; |
||
499 | 787a4489 | KangIngu | } |
500 | 4913851c | humkyung | |
501 | 787a4489 | KangIngu | public void SetAdornerMember(List<CommentUserInfo> members) |
502 | { |
||
503 | foreach (var member in members) |
||
504 | { |
||
505 | switch (member.GetType().Name) |
||
506 | { |
||
507 | #region 컨트롤 조건 |
||
508 | 53880c83 | ljiyeon | case "LineControl": |
509 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
510 | 53880c83 | ljiyeon | break; |
511 | case "ImgControl": |
||
512 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
513 | 787a4489 | KangIngu | break; |
514 | case "ArrowControl": |
||
515 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
516 | 787a4489 | KangIngu | break; |
517 | 53880c83 | ljiyeon | case "PolygonControl": |
518 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
519 | 787a4489 | KangIngu | break; |
520 | case "ArrowTextControl": |
||
521 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
522 | 787a4489 | KangIngu | (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
523 | break; |
||
524 | case "ArcControl": |
||
525 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
526 | 787a4489 | KangIngu | break; |
527 | 40b3ce25 | ljiyeon | case "ArrowArcControl": |
528 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
529 | 40b3ce25 | ljiyeon | break; |
530 | 787a4489 | KangIngu | case "DateControl": |
531 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
532 | 787a4489 | KangIngu | break; |
533 | case "ArrowControl_Multi": |
||
534 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
535 | 787a4489 | KangIngu | break; |
536 | case "RectangleControl": |
||
537 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
538 | 787a4489 | KangIngu | break; |
539 | case "TriControl": |
||
540 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
541 | 787a4489 | KangIngu | break; |
542 | case "CircleControl": |
||
543 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
544 | 787a4489 | KangIngu | break; |
545 | case "CloudControl": |
||
546 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
547 | 787a4489 | KangIngu | break; |
548 | case "RectCloudControl": |
||
549 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
550 | 787a4489 | KangIngu | break; |
551 | case "SignControl": |
||
552 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
553 | 787a4489 | KangIngu | break; |
554 | case "SymControl": |
||
555 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
556 | 787a4489 | KangIngu | break; |
557 | case "SymControlN": |
||
558 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
559 | 787a4489 | KangIngu | break; |
560 | 53880c83 | ljiyeon | case "InkControl": |
561 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
562 | 787a4489 | KangIngu | break; |
563 | case "TextControl": |
||
564 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
565 | 787a4489 | KangIngu | Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
566 | { |
||
567 | BorderUpdate(); |
||
568 | try |
||
569 | { |
||
570 | 29010418 | ljiyeon | ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; |
571 | 787a4489 | KangIngu | } |
572 | catch (Exception) |
||
573 | { |
||
574 | |||
575 | } |
||
576 | |||
577 | }); |
||
578 | Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a => |
||
579 | { |
||
580 | BorderUpdate(); |
||
581 | }); |
||
582 | break; |
||
583 | 684ef11c | ljiyeon | case "InsideWhiteControl": |
584 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
585 | 684ef11c | ljiyeon | break; |
586 | case "OverlapWhiteControl": |
||
587 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
588 | 684ef11c | ljiyeon | break; |
589 | case "ClipWhiteControl": |
||
590 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
591 | 684ef11c | ljiyeon | break; |
592 | case "CoordinateControl": |
||
593 | f513c215 | humkyung | this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
594 | 684ef11c | ljiyeon | break; |
595 | 787a4489 | KangIngu | default: |
596 | break; |
||
597 | #endregion |
||
598 | } |
||
599 | if (member.GetType().Name == "TextControl") |
||
600 | { |
||
601 | TextControl content = ((TextControl)member); |
||
602 | content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
||
603 | content.EndPoint = content.StartPoint; |
||
604 | } |
||
605 | else |
||
606 | { |
||
607 | RegistryPoint(member, members.Count); |
||
608 | } |
||
609 | 4913851c | humkyung | |
610 | if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols |
||
611 | 787a4489 | KangIngu | } |
612 | |||
613 | BorderUpdate(); |
||
614 | } |
||
615 | |||
616 | /// <summary> |
||
617 | /// Border 를 갱신 |
||
618 | /// </summary> |
||
619 | public void BorderUpdate() |
||
620 | { |
||
621 | AdornerBorder.MinWidth = 10; |
||
622 | AdornerBorder.MinHeight = 10; |
||
623 | |||
624 | 992a98b4 | KangIngu | double minX = double.MaxValue; |
625 | double minY = double.MaxValue; |
||
626 | double maxX = double.MinValue; |
||
627 | double maxY = double.MinValue; |
||
628 | 787a4489 | KangIngu | |
629 | 4913851c | humkyung | if (this.Members.Count == 1) |
630 | 787a4489 | KangIngu | { |
631 | 4913851c | humkyung | if (this.Members.First().DrawingData.GetType().Name == "TextControl") |
632 | 787a4489 | KangIngu | { |
633 | fa48eb85 | taeseongkim | if ((this.Members.First().DrawingData as TextControl).CommentAngle != 0) |
634 | 787a4489 | KangIngu | { |
635 | fa48eb85 | taeseongkim | trRotate.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle; |
636 | trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle; |
||
637 | 787a4489 | KangIngu | } |
638 | else |
||
639 | { |
||
640 | trRotate.Angle = 0; |
||
641 | trRotateThumb.Angle = 0; |
||
642 | } |
||
643 | } |
||
644 | } |
||
645 | 4913851c | humkyung | foreach (var item in this.Members) |
646 | 787a4489 | KangIngu | { |
647 | UIElement currentControl = (item as AdornerMember).DrawingData; |
||
648 | b643fcca | taeseongkim | |
649 | Point startP = (currentControl as IPath).StartPoint; |
||
650 | Point endP = (currentControl as IPath).EndPoint; |
||
651 | |||
652 | ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift); |
||
653 | |||
654 | 787a4489 | KangIngu | if (item.DrawingData.GetType().Name == "TextControl") |
655 | { |
||
656 | double textControlWidth; |
||
657 | double textControlHeight; |
||
658 | fa48eb85 | taeseongkim | |
659 | 787a4489 | KangIngu | if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0) |
660 | { |
||
661 | textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth); |
||
662 | textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight); |
||
663 | } |
||
664 | else |
||
665 | { |
||
666 | textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth); |
||
667 | textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight); |
||
668 | } |
||
669 | 29010418 | ljiyeon | |
670 | 787a4489 | KangIngu | if ((currentControl as TextControl).EndPoint.X < minX) |
671 | { |
||
672 | minX = (currentControl as TextControl).EndPoint.X; |
||
673 | } |
||
674 | fa48eb85 | taeseongkim | |
675 | 787a4489 | KangIngu | if ((currentControl as TextControl).EndPoint.Y < minY) |
676 | { |
||
677 | minY = (currentControl as TextControl).EndPoint.Y; |
||
678 | } |
||
679 | fa48eb85 | taeseongkim | |
680 | 787a4489 | KangIngu | if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX) |
681 | { |
||
682 | maxX = textControlWidth + (currentControl as TextControl).EndPoint.X; |
||
683 | } |
||
684 | fa48eb85 | taeseongkim | |
685 | 787a4489 | KangIngu | if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY) |
686 | { |
||
687 | maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y; |
||
688 | } |
||
689 | } |
||
690 | else if ((currentControl as IViewBox) != null) |
||
691 | { |
||
692 | IViewBox instance = currentControl as IViewBox; |
||
693 | List<Point> am = (currentControl as IPath).PointSet; |
||
694 | List<double> xSet = am.Select(p => p.X).ToList(); |
||
695 | List<double> ySet = am.Select(p => p.Y).ToList(); |
||
696 | if (xSet.Min() < minX) minX = xSet.Min(); |
||
697 | if (ySet.Min() < minY) minY = ySet.Min(); |
||
698 | if (xSet.Max() > maxX) maxX = xSet.Max(); |
||
699 | if (ySet.Max() > maxY) maxY = ySet.Max(); |
||
700 | } |
||
701 | else if ((currentControl as IPath).PathData == null) |
||
702 | { |
||
703 | Rect rt = new Rect |
||
704 | { |
||
705 | X = (currentControl as IPath).StartPoint.X, |
||
706 | Y = (currentControl as IPath).StartPoint.Y, |
||
707 | Width = Math.Max((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X) - Math.Min((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X), |
||
708 | Height = Math.Max((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y) - Math.Min((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y), |
||
709 | }; |
||
710 | if (rt.Left < minX) minX = rt.Left; |
||
711 | if (rt.Top < minY) minY = rt.Top; |
||
712 | if (rt.Right > maxX) maxX = rt.Right; |
||
713 | if (rt.Bottom > maxY) maxY = rt.Bottom; |
||
714 | } |
||
715 | else if ((currentControl as IPath) == null) |
||
716 | { |
||
717 | Rect rt = new Rect |
||
718 | { |
||
719 | X = (currentControl as IPath).StartPoint.X, |
||
720 | Y = (currentControl as IPath).StartPoint.Y, |
||
721 | Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X, |
||
722 | Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y |
||
723 | }; |
||
724 | if (rt.Left < minX) minX = rt.Left; |
||
725 | if (rt.Top < minY) minY = rt.Top; |
||
726 | if (rt.Right > maxX) maxX = rt.Right; |
||
727 | if (rt.Bottom > maxY) maxY = rt.Bottom; |
||
728 | } |
||
729 | else if ((currentControl as CircleControl) != null) |
||
730 | 29010418 | ljiyeon | { |
731 | 787a4489 | KangIngu | List<Point> am = (currentControl as IPath).PointSet; |
732 | List<double> xSet = am.Select(p => p.X).ToList(); |
||
733 | List<double> ySet = am.Select(p => p.Y).ToList(); |
||
734 | if (xSet.Min() < minX) minX = xSet.Min(); |
||
735 | if (ySet.Min() < minY) minY = ySet.Min(); |
||
736 | if (xSet.Max() > maxX) maxX = xSet.Max(); |
||
737 | if (ySet.Max() > maxY) maxY = ySet.Max(); |
||
738 | } |
||
739 | else |
||
740 | { |
||
741 | if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left; |
||
742 | if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top; |
||
743 | if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right; |
||
744 | if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom; |
||
745 | } |
||
746 | } |
||
747 | |||
748 | Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY); |
||
749 | bool addWidthSize = false; |
||
750 | bool addHeightSize = false; |
||
751 | if (ac.Width <= 10) |
||
752 | { |
||
753 | ac.Width += 10; |
||
754 | addWidthSize = true; |
||
755 | } |
||
756 | if (ac.Height <= 10) |
||
757 | { |
||
758 | ac.Height += 10; |
||
759 | addHeightSize = true; |
||
760 | } |
||
761 | BorderSize = ac; |
||
762 | AdornerBorder.MinWidth = 10; |
||
763 | AdornerBorder.MinHeight = 10; |
||
764 | AdornerBorder.Width = ac.Width; |
||
765 | AdornerBorder.Height = ac.Height; |
||
766 | Canvas.SetLeft(AdornerBorder, minX); |
||
767 | Canvas.SetTop(AdornerBorder, minY); |
||
768 | |||
769 | DragThumb.Width = ac.Width; |
||
770 | DragThumb.Height = ac.Height; |
||
771 | |||
772 | DragThumb.MinWidth = 10; |
||
773 | DragThumb.MinHeight = 10; |
||
774 | if (addWidthSize) |
||
775 | { |
||
776 | Canvas.SetLeft(DragThumb, minX - 5); |
||
777 | } |
||
778 | else |
||
779 | { |
||
780 | Canvas.SetLeft(DragThumb, minX); |
||
781 | } |
||
782 | |||
783 | if (addHeightSize) |
||
784 | { |
||
785 | Canvas.SetTop(DragThumb, minY - 5); |
||
786 | } |
||
787 | else |
||
788 | { |
||
789 | Canvas.SetTop(DragThumb, minY); |
||
790 | } |
||
791 | } |
||
792 | /// <summary> |
||
793 | /// UIElement 해제 |
||
794 | /// </summary> |
||
795 | public void unRegister() |
||
796 | { |
||
797 | foreach (var item in this.ContainerContent.Children) |
||
798 | { |
||
799 | if (item is MarkupToPDF.Common.CommentUserInfo) |
||
800 | { |
||
801 | (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true; |
||
802 | } |
||
803 | } |
||
804 | this.ContainerContent.Children.Clear(); |
||
805 | } |
||
806 | f513c215 | humkyung | |
807 | 787a4489 | KangIngu | /// <summary> |
808 | /// 각 포인트들을 등록합니다. |
||
809 | /// </summary> |
||
810 | /// <param name="pointset">Drawing Point</param> |
||
811 | public void RegistryPoint(CommentUserInfo member, int cnt = 1) |
||
812 | 53880c83 | ljiyeon | { |
813 | 787a4489 | KangIngu | int count = 0; |
814 | double Minx = 100000000; |
||
815 | double Miny = 100000000; |
||
816 | List<Point> list = (member as IPath).PointSet; |
||
817 | if (member.GetType().Name == "InkControl") |
||
818 | { |
||
819 | list.Clear(); |
||
820 | list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y)); |
||
821 | list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom)); |
||
822 | list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom)); |
||
823 | list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top)); |
||
824 | } |
||
825 | 4913851c | humkyung | ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype; |
826 | 787a4489 | KangIngu | foreach (var ax in list) |
827 | { |
||
828 | Minx = (ax.X < Minx) ? ax.X : Minx; |
||
829 | Miny = (ax.Y < Miny) ? ax.Y : Miny; |
||
830 | } |
||
831 | for (int i = 0; i < list.Count(); i++) |
||
832 | { |
||
833 | f513c215 | humkyung | MyThumb tm = new MyThumb |
834 | 787a4489 | KangIngu | { |
835 | Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"], |
||
836 | }; |
||
837 | |||
838 | 4913851c | humkyung | this.Members.Last().ThumbList.Add(tm); |
839 | 29010418 | ljiyeon | |
840 | 40b3ce25 | ljiyeon | if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint)) |
841 | 787a4489 | KangIngu | { |
842 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
||
843 | } |
||
844 | if (member.GetType().Name == "ArrowTextControl" && i == 1) |
||
845 | { |
||
846 | 4913851c | humkyung | //if (this.Members.Count()<=1) |
847 | 787a4489 | KangIngu | //{ |
848 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
||
849 | List<Point> ps = new List<Point>(); |
||
850 | |||
851 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null) |
852 | 787a4489 | KangIngu | { |
853 | 4913851c | humkyung | var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl; |
854 | 787a4489 | KangIngu | |
855 | 9b7cda70 | KangIngu | |
856 | fa48eb85 | taeseongkim | switch (Math.Abs(temp.CommentAngle).ToString()) |
857 | 787a4489 | KangIngu | { |
858 | case "90": |
||
859 | { |
||
860 | ps.Clear(); |
||
861 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
862 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
||
863 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
||
864 | |||
865 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
866 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
867 | |||
868 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
||
869 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
||
870 | |||
871 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
||
872 | } |
||
873 | break; |
||
874 | case "270": |
||
875 | { |
||
876 | ps.Clear(); |
||
877 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
878 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
||
879 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
||
880 | |||
881 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
882 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
883 | |||
884 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
||
885 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
||
886 | |||
887 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
||
888 | } |
||
889 | break; |
||
890 | default: |
||
891 | { |
||
892 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
893 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
894 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
895 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
896 | } |
||
897 | break; |
||
898 | } |
||
899 | |||
900 | ArrowTextControl instance = (member as ArrowTextControl); |
||
901 | if (instance.isTrans) |
||
902 | { |
||
903 | //var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
904 | //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
905 | //list[count] = tempP; |
||
906 | list[count] = temp.MidPoint; |
||
907 | } |
||
908 | else |
||
909 | { |
||
910 | if (temp.isFixed) |
||
911 | { |
||
912 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
913 | var testP = endP; |
||
914 | if (ps[0] == endP) //상단 |
||
915 | { |
||
916 | testP = new Point(endP.X, endP.Y - 50); |
||
917 | } |
||
918 | else if (ps[1] == endP) //하단 |
||
919 | { |
||
920 | testP = new Point(endP.X, endP.Y + 50); |
||
921 | } |
||
922 | else if (ps[2] == endP) //좌단 |
||
923 | { |
||
924 | testP = new Point(endP.X - 50, endP.Y); |
||
925 | } |
||
926 | else if (ps[3] == endP) //우단 |
||
927 | { |
||
928 | testP = new Point(endP.X + 50, endP.Y); |
||
929 | } |
||
930 | list[count] = testP; |
||
931 | } |
||
932 | else |
||
933 | { |
||
934 | var endP = MathSet.getNearPoint(ps, instance.MidPoint); |
||
935 | list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP); |
||
936 | } |
||
937 | } |
||
938 | } |
||
939 | } |
||
940 | if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last()) |
||
941 | { |
||
942 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"]; |
||
943 | tm.Width = (member as ArrowTextControl).BoxWidth; |
||
944 | tm.Height = (member as ArrowTextControl).BoxHeight; |
||
945 | fa48eb85 | taeseongkim | var angle = (member as ArrowTextControl).PageAngle; |
946 | 787a4489 | KangIngu | if (Math.Abs(angle).ToString() == "90") |
947 | { |
||
948 | tm.RenderTransformOrigin = new Point(0, 0); |
||
949 | tm.RenderTransform = new RotateTransform { Angle = 270 }; |
||
950 | } |
||
951 | else if (Math.Abs(angle).ToString() == "270") |
||
952 | { |
||
953 | tm.RenderTransformOrigin = new Point(0, 0); |
||
954 | tm.RenderTransform = new RotateTransform { Angle = 90 }; |
||
955 | } |
||
956 | else |
||
957 | { |
||
958 | tm.RenderTransformOrigin = new Point(0.5, 0.5); |
||
959 | tm.RenderTransform = new RotateTransform() |
||
960 | { |
||
961 | fa48eb85 | taeseongkim | Angle = angle |
962 | 787a4489 | KangIngu | }; |
963 | } |
||
964 | } |
||
965 | 29010418 | ljiyeon | |
966 | 787a4489 | KangIngu | if (member.GetType().Name == "CloudControl") |
967 | { |
||
968 | if (i == list.Count() - 1) |
||
969 | { |
||
970 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
971 | } |
||
972 | } |
||
973 | if (member.GetType().Name == "PolygonControl") |
||
974 | { |
||
975 | if (i == list.Count() - 1) |
||
976 | { |
||
977 | if ((member as PolygonControl).ControlType == ControlType.ChainLine) |
||
978 | { |
||
979 | |||
980 | } |
||
981 | else |
||
982 | { |
||
983 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
984 | } |
||
985 | } |
||
986 | if ((member as PolygonControl).ControlType == ControlType.Ink) |
||
987 | { |
||
988 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
989 | } |
||
990 | } |
||
991 | 29010418 | ljiyeon | |
992 | 787a4489 | KangIngu | this.ContainerContent.Children.Add(tm); |
993 | Canvas.SetLeft(tm, list[count].X); |
||
994 | Canvas.SetTop(tm, list[count].Y); |
||
995 | if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint) |
||
996 | { |
||
997 | Canvas.SetZIndex(tm, 95); |
||
998 | } |
||
999 | else |
||
1000 | { |
||
1001 | Canvas.SetZIndex(tm, 99); |
||
1002 | } |
||
1003 | |||
1004 | tm.DragStarted += new DragStartedEventHandler(tm_DragStarted); |
||
1005 | tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted); |
||
1006 | tm.DragDelta += ResizeTm_DragDelta; |
||
1007 | tm.MouseMove += new MouseEventHandler(resize_MouseMove); |
||
1008 | count++; |
||
1009 | } |
||
1010 | } |
||
1011 | |||
1012 | private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e) |
||
1013 | { |
||
1014 | d2114d3b | humkyung | if (this.Members.Count > 1) return; |
1015 | 787a4489 | KangIngu | if (reSizePoint != new Point(0, 0)) |
1016 | { |
||
1017 | d2114d3b | humkyung | MyThumb thumb = sender as MyThumb; |
1018 | 15bbef90 | taeseongkim | |
1019 | //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas); |
||
1020 | |||
1021 | 787a4489 | KangIngu | Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb)); |
1022 | 15bbef90 | taeseongkim | |
1023 | System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}"); |
||
1024 | |||
1025 | 0d00f9c8 | humkyung | thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue); |
1026 | 29010418 | ljiyeon | |
1027 | 4913851c | humkyung | AdornerMember control = (from userThumb in this.Members |
1028 | 787a4489 | KangIngu | where userThumb.ThumbList.Contains(thumb) |
1029 | select userThumb).FirstOrDefault(); |
||
1030 | |||
1031 | d2114d3b | humkyung | IPath AllControl = control.DrawingData as IPath; |
1032 | 15bbef90 | taeseongkim | |
1033 | System.Diagnostics.Debug.WriteLine($"2. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}"); |
||
1034 | |||
1035 | //System.Diagnostics.Debug.WriteLine($"ResizeTm_DragDelta setPoint : {setPoint.X},{setPoint.Y} - {e.HorizontalChange},{e.VerticalChange}"); |
||
1036 | d2114d3b | humkyung | ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange); |
1037 | 15bbef90 | taeseongkim | System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}"); |
1038 | 508c3ac5 | humkyung | control.UpdateThumb(); |
1039 | 15bbef90 | taeseongkim | |
1040 | System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}"); |
||
1041 | 508c3ac5 | humkyung | this.BorderUpdate(); |
1042 | 15bbef90 | taeseongkim | |
1043 | System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}"); |
||
1044 | 787a4489 | KangIngu | } |
1045 | } |
||
1046 | |||
1047 | 15bbef90 | taeseongkim | private Point GetPosition(Thumb thumb) |
1048 | { |
||
1049 | return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb)); |
||
1050 | } |
||
1051 | |||
1052 | 787a4489 | KangIngu | #endregion |
1053 | #region 이벤트 |
||
1054 | |||
1055 | void tm_DragCompleted(object sender, DragCompletedEventArgs e) |
||
1056 | { |
||
1057 | this.isDragging = false; |
||
1058 | DraggerThumb = null; |
||
1059 | |||
1060 | 4913851c | humkyung | var comments = (from drawing in this.Members |
1061 | d128ceb2 | humkyung | select drawing.DrawingData as CommentUserInfo).ToList(); |
1062 | f816dd63 | humkyung | UndoCommand.Instance.Push(comments, this.AngleValue); |
1063 | 787a4489 | KangIngu | } |
1064 | |||
1065 | ec052e41 | humkyung | /// <summary> |
1066 | /// start drag |
||
1067 | /// </summary> |
||
1068 | /// <param name="sender"></param> |
||
1069 | /// <param name="e"></param> |
||
1070 | 787a4489 | KangIngu | void tm_DragStarted(object sender, DragStartedEventArgs e) |
1071 | { |
||
1072 | this.DraggerThumb = sender as Thumb; |
||
1073 | this.isDragging = true; |
||
1074 | |||
1075 | if (ViewerDataModel.Instance.UndoDataList == null) |
||
1076 | { |
||
1077 | return; |
||
1078 | } |
||
1079 | |||
1080 | ec052e41 | humkyung | if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)) |
1081 | 787a4489 | KangIngu | { |
1082 | return; |
||
1083 | } |
||
1084 | |||
1085 | ec052e41 | humkyung | if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)) |
1086 | 787a4489 | KangIngu | { |
1087 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
1088 | { |
||
1089 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
1090 | { |
||
1091 | return; |
||
1092 | } |
||
1093 | } |
||
1094 | } |
||
1095 | |||
1096 | 4913851c | humkyung | var comments = (from drawing in this.Members |
1097 | d128ceb2 | humkyung | select drawing.DrawingData as CommentUserInfo).ToList(); |
1098 | f816dd63 | humkyung | UndoCommand.Instance.Push(comments, this.AngleValue); |
1099 | 787a4489 | KangIngu | } |
1100 | |||
1101 | private void rotate_MouseMove(object sender, MouseEventArgs e) |
||
1102 | { |
||
1103 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1104 | 787a4489 | KangIngu | { |
1105 | if (LastRotateVerticalValue < e.GetPosition(this).X) |
||
1106 | IsTextAngle = true; |
||
1107 | else |
||
1108 | IsTextAngle = false; |
||
1109 | LastRotateVerticalValue = e.GetPosition(this).X; |
||
1110 | } |
||
1111 | 9f473fb7 | KangIngu | else |
1112 | 53880c83 | ljiyeon | { |
1113 | 9f473fb7 | KangIngu | if (e.GetPosition(this).X > LastRotateHorizontalValue) |
1114 | { |
||
1115 | RotateFlag = true; |
||
1116 | } |
||
1117 | else |
||
1118 | { |
||
1119 | RotateFlag = false; |
||
1120 | } |
||
1121 | LastRotateHorizontalValue = e.GetPosition(this).X; |
||
1122 | } |
||
1123 | 787a4489 | KangIngu | } |
1124 | |||
1125 | 8771edc4 | humkyung | private void drag_DragStarted(object sender, DragStartedEventArgs e) |
1126 | { |
||
1127 | /// save mouse down and current mouse point |
||
1128 | this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
||
1129 | this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
||
1130 | /// up to here |
||
1131 | |||
1132 | if (ViewerDataModel.Instance.UndoDataList == null) |
||
1133 | { |
||
1134 | return; |
||
1135 | } |
||
1136 | if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)) |
||
1137 | { |
||
1138 | return; |
||
1139 | } |
||
1140 | if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)) |
||
1141 | { |
||
1142 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
1143 | { |
||
1144 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
1145 | { |
||
1146 | return; |
||
1147 | } |
||
1148 | } |
||
1149 | } |
||
1150 | |||
1151 | var comments = (from drawing in this.Members |
||
1152 | select drawing.DrawingData as CommentUserInfo).ToList(); |
||
1153 | UndoCommand.Instance.Push(comments, this.AngleValue); |
||
1154 | } |
||
1155 | |||
1156 | private void drag_DragCompleted(object sender, DragCompletedEventArgs e) |
||
1157 | { |
||
1158 | DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource); |
||
1159 | |||
1160 | var comments = (from drawing in this.Members |
||
1161 | select drawing.DrawingData as CommentUserInfo).ToList(); |
||
1162 | UndoCommand.Instance.Push(comments, this.AngleValue); |
||
1163 | } |
||
1164 | |||
1165 | 6b6e937c | taeseongkim | private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e) |
1166 | 787a4489 | KangIngu | { |
1167 | 508c3ac5 | humkyung | double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale; |
1168 | 8771edc4 | humkyung | var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
1169 | 025ebf74 | humkyung | |
1170 | var horzChange = (tmp.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale; |
||
1171 | var vertChange = (tmp.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale; |
||
1172 | 0d00f9c8 | humkyung | try |
1173 | { |
||
1174 | DragThumb.Cursor = Cursors.SizeAll; |
||
1175 | 8e5a4a6a | taeseongkim | //System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}"); |
1176 | //System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}"); |
||
1177 | |||
1178 | 6b6e937c | taeseongkim | this.TranslateItems(horzChange, vertChange); |
1179 | 8e5a4a6a | taeseongkim | |
1180 | var rect = this.AdornerBorder.Bounds(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel); |
||
1181 | var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect(); |
||
1182 | |||
1183 | var moveDirection = mainRect.Movement(rect); |
||
1184 | |||
1185 | System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}"); |
||
1186 | System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : Top:{rect.Top}, Left:{rect.Left}, Right:{rect.Right}, Bottom:{rect.Bottom} ,BottomLeft : {rect.BottomLeft} BottomRight : {rect.BottomRight}"); |
||
1187 | |||
1188 | if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right)) |
||
1189 | { |
||
1190 | 6b6e937c | taeseongkim | this.TranslateItems(horzChange * -1, 0); |
1191 | 8e5a4a6a | taeseongkim | e.Handled = true; |
1192 | } |
||
1193 | |||
1194 | if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down)) |
||
1195 | { |
||
1196 | 6b6e937c | taeseongkim | this.TranslateItems( 0, vertChange * -1); |
1197 | 8e5a4a6a | taeseongkim | e.Handled = true; |
1198 | } |
||
1199 | 0d00f9c8 | humkyung | } |
1200 | finally |
||
1201 | { |
||
1202 | /// update CurrentMousePoint |
||
1203 | 8771edc4 | humkyung | this.CurrentMousePoint = tmp; |
1204 | 0d00f9c8 | humkyung | } |
1205 | 787a4489 | KangIngu | } |
1206 | eb2b9248 | KangIngu | |
1207 | 0d00f9c8 | humkyung | /// <summary> |
1208 | /// translate all members |
||
1209 | /// </summary> |
||
1210 | /// <param name="e"></param> |
||
1211 | public void TranslateItems(double dx, double dy) |
||
1212 | 787a4489 | KangIngu | { |
1213 | Dispatcher.BeginInvoke((Action)(() => |
||
1214 | { |
||
1215 | 4913851c | humkyung | foreach (var item in this.Members) |
1216 | 787a4489 | KangIngu | { |
1217 | 0d00f9c8 | humkyung | this.TranslateItem(dx, dy, item); |
1218 | 787a4489 | KangIngu | } |
1219 | c7fde400 | taeseongkim | |
1220 | this.BorderUpdate(); |
||
1221 | 787a4489 | KangIngu | })); |
1222 | } |
||
1223 | eb2b9248 | KangIngu | |
1224 | 0d00f9c8 | humkyung | /// <summary> |
1225 | /// translate a item |
||
1226 | /// </summary> |
||
1227 | /// <param name="e"></param> |
||
1228 | /// <param name="item"></param> |
||
1229 | private void TranslateItem(double dx, double dy, AdornerMember item) |
||
1230 | 787a4489 | KangIngu | { |
1231 | 554aae3b | humkyung | /// rotate point with page rotation |
1232 | var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle; |
||
1233 | Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation); |
||
1234 | /// up to here |
||
1235 | 0d00f9c8 | humkyung | (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y); |
1236 | 105359ce | ljiyeon | |
1237 | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
||
1238 | MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null); |
||
1239 | |||
1240 | 508c3ac5 | humkyung | item.UpdateThumb(); |
1241 | 787a4489 | KangIngu | } |
1242 | |||
1243 | private void resize_MouseMove(object sender, MouseEventArgs e) |
||
1244 | { |
||
1245 | 53880c83 | ljiyeon | reSizePoint = e.GetPosition(this); |
1246 | 787a4489 | KangIngu | } |
1247 | 0d00f9c8 | humkyung | |
1248 | 787a4489 | KangIngu | /// <summary> |
1249 | /// 회전 |
||
1250 | /// </summary> |
||
1251 | /// <param name="sender"></param> |
||
1252 | /// <param name="e"></param> |
||
1253 | public void rotate_DragDelta(object sender, DragDeltaEventArgs e) |
||
1254 | { |
||
1255 | MoveRotate(e); |
||
1256 | } |
||
1257 | |||
1258 | double LastRotateHorizontalValue = 0; |
||
1259 | double LastRotateVerticalValue = 0; |
||
1260 | 9f473fb7 | KangIngu | bool RotateFlag = false; |
1261 | |||
1262 | 992a98b4 | KangIngu | /// <summary> |
1263 | /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history> |
||
1264 | /// </summary> |
||
1265 | /// <param name="e"></param> |
||
1266 | 787a4489 | KangIngu | public void MoveRotate(DragDeltaEventArgs e) |
1267 | { |
||
1268 | 62b6bcde | humkyung | Point CenterPoint = this.Centeroid; |
1269 | 992a98b4 | KangIngu | Point pt = Mouse.GetPosition(this); |
1270 | |||
1271 | Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y); |
||
1272 | Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y); |
||
1273 | 62b6bcde | humkyung | double dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2)); |
1274 | 992a98b4 | KangIngu | |
1275 | AngleValue += dDeltaAngle; |
||
1276 | if (AngleValue > 360) AngleValue -= 360; |
||
1277 | if (AngleValue < 0) AngleValue += 360; |
||
1278 | this.rotatePoint = pt; /// save rotatePoint |
||
1279 | 787a4489 | KangIngu | |
1280 | Dispatcher.BeginInvoke((Action)(() => |
||
1281 | { |
||
1282 | 554aae3b | humkyung | foreach (var member in this.Members) |
1283 | 787a4489 | KangIngu | { |
1284 | 554aae3b | humkyung | member.RotateAbout(CenterPoint, dDeltaAngle); |
1285 | #region 보더 업데이트 |
||
1286 | switch (member.Drawingtype) |
||
1287 | 787a4489 | KangIngu | { |
1288 | case ControlType.TextControl: |
||
1289 | fa48eb85 | taeseongkim | (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue; |
1290 | 53880c83 | ljiyeon | |
1291 | 9b7cda70 | KangIngu | DragThumb.RenderTransformOrigin = new Point(0, 0); |
1292 | 787a4489 | KangIngu | DragThumb.RenderTransform = new RotateTransform() |
1293 | { |
||
1294 | 6e035f10 | 송근호 | |
1295 | fa48eb85 | taeseongkim | Angle = (member.DrawingData as CommentUserInfo).CommentAngle |
1296 | 787a4489 | KangIngu | }; |
1297 | |||
1298 | 9b7cda70 | KangIngu | AdornerBorder.RenderTransformOrigin = new Point(0, 0); |
1299 | 787a4489 | KangIngu | AdornerBorder.RenderTransform = new RotateTransform() |
1300 | { |
||
1301 | fa48eb85 | taeseongkim | Angle = (member.DrawingData as CommentUserInfo).CommentAngle |
1302 | 54e35b39 | 송근호 | }; |
1303 | 6e035f10 | 송근호 | |
1304 | 54e35b39 | 송근호 | //(member.DrawingData as TextControl).Angle = AngleValue; |
1305 | 787a4489 | KangIngu | |
1306 | 62b6bcde | humkyung | (member.DrawingData as CommentUserInfo).UpdateControl(); |
1307 | 787a4489 | KangIngu | BorderUpdate(); |
1308 | break; |
||
1309 | 53880c83 | ljiyeon | |
1310 | 787a4489 | KangIngu | case ControlType.ArrowMultiLine: |
1311 | case ControlType.ArcLine: |
||
1312 | 40b3ce25 | ljiyeon | case ControlType.ArcArrow: |
1313 | 787a4489 | KangIngu | case ControlType.SingleLine: |
1314 | case ControlType.Triangle: |
||
1315 | case ControlType.ArrowTextControl: |
||
1316 | 554aae3b | humkyung | case ControlType.PolygonControl: |
1317 | case ControlType.Ink: |
||
1318 | 787a4489 | KangIngu | BorderUpdate(); |
1319 | break; |
||
1320 | 554aae3b | humkyung | case ControlType.Date: |
1321 | 787a4489 | KangIngu | case ControlType.RectCloud: |
1322 | case ControlType.Rectangle: |
||
1323 | case ControlType.ImgControl: |
||
1324 | case ControlType.Sign: |
||
1325 | case ControlType.Symbol: |
||
1326 | case ControlType.Stamp: |
||
1327 | fa48eb85 | taeseongkim | (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue; |
1328 | 787a4489 | KangIngu | BorderUpdate(); |
1329 | break; |
||
1330 | case ControlType.PolygonCloud: |
||
1331 | 554aae3b | humkyung | ((ICloudControl)member.DrawingData).DrawingCloud(); |
1332 | 787a4489 | KangIngu | BorderUpdate(); |
1333 | break; |
||
1334 | case ControlType.Circle: |
||
1335 | fa48eb85 | taeseongkim | (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue; |
1336 | 554aae3b | humkyung | ((CircleControl)member.DrawingData).SetCenterXY(); |
1337 | 787a4489 | KangIngu | BorderUpdate(); |
1338 | break; |
||
1339 | default: |
||
1340 | break; |
||
1341 | } |
||
1342 | } |
||
1343 | #endregion |
||
1344 | })); |
||
1345 | } |
||
1346 | eb2b9248 | KangIngu | |
1347 | 787a4489 | KangIngu | private void rotate_DragStarted(object sender, DragStartedEventArgs e) |
1348 | 29010418 | ljiyeon | { |
1349 | 992a98b4 | KangIngu | this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung |
1350 | eb2b9248 | KangIngu | rotateTop.Cursor = Cursors.SizeAll; |
1351 | |||
1352 | 992a98b4 | KangIngu | /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung |
1353 | 4913851c | humkyung | if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1354 | 992a98b4 | KangIngu | { |
1355 | fa48eb85 | taeseongkim | this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle; |
1356 | 992a98b4 | KangIngu | } |
1357 | /// up to here |
||
1358 | |||
1359 | 01cbc243 | KangIngu | if (ViewerDataModel.Instance.UndoDataList == null) |
1360 | 787a4489 | KangIngu | { |
1361 | return; |
||
1362 | } |
||
1363 | |||
1364 | d128ceb2 | humkyung | if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb) |
1365 | 787a4489 | KangIngu | { |
1366 | return; |
||
1367 | } |
||
1368 | d128ceb2 | humkyung | |
1369 | if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null) |
||
1370 | 787a4489 | KangIngu | { |
1371 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
1372 | { |
||
1373 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
1374 | { |
||
1375 | return; |
||
1376 | } |
||
1377 | } |
||
1378 | } |
||
1379 | |||
1380 | 4913851c | humkyung | var comments = (from drawing in this.Members |
1381 | d128ceb2 | humkyung | select drawing.DrawingData as CommentUserInfo).ToList(); |
1382 | f816dd63 | humkyung | UndoCommand.Instance.Push(comments, this.AngleValue); |
1383 | 787a4489 | KangIngu | } |
1384 | 29010418 | ljiyeon | |
1385 | 787a4489 | KangIngu | private void rotate_DragCompleted(object sender, DragCompletedEventArgs e) |
1386 | { |
||
1387 | ca16abb2 | ljiyeon | rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource); |
1388 | d128ceb2 | humkyung | |
1389 | 4913851c | humkyung | var comments = (from drawing in this.Members |
1390 | d128ceb2 | humkyung | select drawing.DrawingData as CommentUserInfo).ToList(); |
1391 | f816dd63 | humkyung | UndoCommand.Instance.Push(comments, this.AngleValue); |
1392 | 787a4489 | KangIngu | } |
1393 | |||
1394 | public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
1395 | { |
||
1396 | 4913851c | humkyung | AdornerMember control = this.Members.FirstOrDefault(); |
1397 | 787a4489 | KangIngu | |
1398 | if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null) |
||
1399 | { |
||
1400 | if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false) |
||
1401 | { |
||
1402 | (control.DrawingData as ArrowTextControl).isTrans = true; |
||
1403 | } |
||
1404 | } |
||
1405 | |||
1406 | } |
||
1407 | eb2b9248 | KangIngu | |
1408 | 787a4489 | KangIngu | public void TextControlChanger() |
1409 | { |
||
1410 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1411 | 787a4489 | KangIngu | { |
1412 | 4913851c | humkyung | TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl; |
1413 | 787a4489 | KangIngu | AllControl.Base_TextBox.Focus(); |
1414 | AllControl.Base_TextBox.Visibility = Visibility.Visible; |
||
1415 | AllControl.Base_TextBlock.Visibility = Visibility.Collapsed; |
||
1416 | fa48eb85 | taeseongkim | AllControl.Base_TextBox.IsHitTestVisible = true; |
1417 | 787a4489 | KangIngu | AllControl.Base_TextBox.Focus(); |
1418 | fa48eb85 | taeseongkim | |
1419 | 787a4489 | KangIngu | AllControl.SizeChanged += (sen, ea) => |
1420 | { |
||
1421 | if (AllControl.Base_TextBox != null) |
||
1422 | { |
||
1423 | RectangleGeometry Data = new RectangleGeometry |
||
1424 | { |
||
1425 | Rect = new Rect() |
||
1426 | { |
||
1427 | X = AllControl.StartPoint.X, |
||
1428 | Y = AllControl.StartPoint.Y, |
||
1429 | Width = AllControl.Base_TextBox.Width, |
||
1430 | Height = AllControl.Base_TextBox.Height, |
||
1431 | } |
||
1432 | }; |
||
1433 | |||
1434 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
1435 | Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV); |
||
1436 | AllControl.Base_Grid.RenderTransform = new RotateTransform() |
||
1437 | { |
||
1438 | fa48eb85 | taeseongkim | Angle = AllControl.CommentAngle, |
1439 | 787a4489 | KangIngu | CenterX = middle.X, |
1440 | CenterY = middle.Y, |
||
1441 | }; |
||
1442 | } |
||
1443 | BorderUpdate(); |
||
1444 | }; |
||
1445 | } |
||
1446 | } |
||
1447 | eb2b9248 | KangIngu | |
1448 | 787a4489 | KangIngu | private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭 |
1449 | { |
||
1450 | 4913851c | humkyung | if (e.ClickCount == 2 && this.Members.Count == 1) |
1451 | 787a4489 | KangIngu | { |
1452 | |||
1453 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1454 | 787a4489 | KangIngu | { |
1455 | 29010418 | ljiyeon | TextControlChanger(); |
1456 | 787a4489 | KangIngu | } |
1457 | |||
1458 | 4913851c | humkyung | else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
1459 | 787a4489 | KangIngu | { |
1460 | 4913851c | humkyung | ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl; |
1461 | Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last(); |
||
1462 | 787a4489 | KangIngu | ((ArrowTextControl)AllControl).Base_TextBox.Focus(); |
1463 | |||
1464 | 3797ff05 | djkim | //ArrowControl TextBox Thumb없애기 |
1465 | 787a4489 | KangIngu | tm.Visibility = Visibility.Collapsed; |
1466 | |||
1467 | 4913851c | humkyung | ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true; |
1468 | 29010418 | ljiyeon | |
1469 | 787a4489 | KangIngu | ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) => |
1470 | |||
1471 | { |
||
1472 | tm.Width = (AllControl as ArrowTextControl).BoxWidth; |
||
1473 | tm.Height = (AllControl as ArrowTextControl).BoxHeight; |
||
1474 | |||
1475 | List<Point> ps = new List<Point>(); |
||
1476 | 29010418 | ljiyeon | |
1477 | 787a4489 | KangIngu | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단 |
1478 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단 |
||
1479 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단 |
||
1480 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //우단 |
||
1481 | |||
1482 | |||
1483 | |||
1484 | |||
1485 | var endP = MathSet.getNearPoint(ps, AllControl.MidPoint); |
||
1486 | var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP); |
||
1487 | if (AllControl.isTrans) |
||
1488 | { |
||
1489 | 4913851c | humkyung | Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X); |
1490 | Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y); |
||
1491 | 787a4489 | KangIngu | } |
1492 | else |
||
1493 | { |
||
1494 | 4913851c | humkyung | Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X); |
1495 | Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
1496 | 787a4489 | KangIngu | } |
1497 | |||
1498 | 9b7cda70 | KangIngu | |
1499 | 787a4489 | KangIngu | BorderUpdate(); |
1500 | 9b7cda70 | KangIngu | |
1501 | 787a4489 | KangIngu | }; |
1502 | } |
||
1503 | 4913851c | humkyung | else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
1504 | 787a4489 | KangIngu | { |
1505 | 4913851c | humkyung | DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl; |
1506 | 787a4489 | KangIngu | CalendarControl instanceCal = new CalendarControl(data.Text); |
1507 | //dropData.IsOpen = true; |
||
1508 | RadWindow rc = new RadWindow(); |
||
1509 | rc.Width = 300; |
||
1510 | rc.Height = 300; |
||
1511 | rc.Header = "Change Date"; |
||
1512 | rc.Content = instanceCal; |
||
1513 | rc.BorderThickness = new Thickness(3); |
||
1514 | rc.ResizeMode = ResizeMode.NoResize; |
||
1515 | rc.WindowStartupLocation = WindowStartupLocation.CenterScreen; |
||
1516 | rc.ModalBackground = new SolidColorBrush(Colors.Black); |
||
1517 | rc.ModalBackground.Opacity = 0.6; |
||
1518 | Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme()); |
||
1519 | instanceCal.changeDateCal.SelectionChanged += (sen, ea) => |
||
1520 | { |
||
1521 | data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString(); |
||
1522 | rc.Close(); |
||
1523 | }; |
||
1524 | rc.ShowDialog(); |
||
1525 | //CalendarControl.xaml |
||
1526 | } |
||
1527 | 4913851c | humkyung | else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl") |
1528 | 787a4489 | KangIngu | { |
1529 | 4913851c | humkyung | ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl); |
1530 | 787a4489 | KangIngu | if (instance.isTransOn) |
1531 | { |
||
1532 | instance.isTransOn = false; |
||
1533 | } |
||
1534 | else |
||
1535 | { |
||
1536 | instance.isTransOn = true; |
||
1537 | } |
||
1538 | 661b7416 | humkyung | ///instance.SetArcPath(); |
1539 | 787a4489 | KangIngu | BorderUpdate(); |
1540 | } |
||
1541 | 4913851c | humkyung | else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl") |
1542 | 40b3ce25 | ljiyeon | { |
1543 | 4913851c | humkyung | ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl); |
1544 | 40b3ce25 | ljiyeon | if (instance.isTransOn) |
1545 | { |
||
1546 | instance.isTransOn = false; |
||
1547 | } |
||
1548 | else |
||
1549 | { |
||
1550 | instance.isTransOn = true; |
||
1551 | } |
||
1552 | instance.SetArcPath(); |
||
1553 | BorderUpdate(); |
||
1554 | } |
||
1555 | 787a4489 | KangIngu | |
1556 | } |
||
1557 | 29010418 | ljiyeon | |
1558 | 787a4489 | KangIngu | } |
1559 | #endregion |
||
1560 | |||
1561 | private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
||
1562 | { |
||
1563 | 4913851c | humkyung | if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
1564 | 787a4489 | KangIngu | { |
1565 | DragThumb.Visibility = Visibility.Collapsed; |
||
1566 | 9b7cda70 | KangIngu | } |
1567 | 787a4489 | KangIngu | } |
1568 | 6b6e937c | taeseongkim | |
1569 | 787a4489 | KangIngu | } |
1570 | } |