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