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