프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 105359ce

이력 | 보기 | 이력해설 | 다운로드 (68.9 KB)

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Cad;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Controls.Etc;
7
using MarkupToPDF.Controls.Line;
8
using MarkupToPDF.Controls.Parsing;
9
using MarkupToPDF.Controls.Polygon;
10
using MarkupToPDF.Controls.Shape;
11
using MarkupToPDF.Controls.Text;
12
using System;
13
using System.Collections.Generic;
14
using System.Diagnostics;
15
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
    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
        /// translate thumb with given delta and angle
38
        /// </summary>
39
        /// <param name="e"></param>
40
        /// <param name="angle"></param>
41
        public void Translate(double dx, double dy, double angle)
42
        {
43
            double radian = angle * Math.PI / 180;
44
            double cos = Math.Cos(radian);
45
            double sin = Math.Sin(radian);
46

    
47
            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
        }
52

    
53
        /// <summary>
54
        /// </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
    /// <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
        public List<MyThumb> ThumbList { get; set; }
82
        public string Symbol_ID { get; set; }
83
        public long Group_ID { get; set; }
84

    
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

    
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
    }
159

    
160
    public partial class AdornerFinal : UserControl
161
    {
162
        public TextBox editTextBox { get; set; }
163
        #region 공용 인스턴스
164
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
165
        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
        private bool disposed;
177

    
178
        public Point reSizePoint { get; set; }
179
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
180
        private Point MouseDownPoint = new Point();
181
        private Point CurrentMousePoint = new Point();
182
        #endregion
183
        #region 생성자
184
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
185
        {
186
            dropData = sender as RadDropDownButton;
187
        }
188

    
189
        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
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
196
                {
197
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
198
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
199
                }
200
            };
201
        }
202

    
203
        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
        }
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
        }
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
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
254
                this.ContainerContent.Children.Add(objectData);
255
            }
256
            catch (Exception ex)
257
            {
258

    
259
            }
260
           
261
            SetAdornerMember(objectData as CommentUserInfo);
262
            this.Focus();
263
        }
264

    
265
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
266
        {
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
                    Canvas.SetZIndex(item, 80);
278
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
279
                    this.ContainerContent.Children.Add(item);
280
                }
281
                catch //(Exception ex)
282
                {
283
                }
284
                finally
285
                {
286
                    
287
                }
288
            }
289
            this.SetAdornerMember(objectData);
290
            this.Focus();
291
        }
292

    
293
        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
        {
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
        {
341
            switch (member.GetType().Name)
342
            {
343
                #region 컨트롤 조건
344
                case "LineControl":
345
                case "PolygonControl":
346
                case "ArrowControl":
347
                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
                    break;
362
                case "ArrowTextControl":
363
                    this.Members.Add(new AdornerMember
364
                    {
365
                        DrawingData = member,
366
                        Drawingtype = ControlType.ArrowTextControl,
367
                        ThumbList = new List<MyThumb>(),
368
                        Symbol_ID = member.SymbolID,
369
                        Group_ID = member.GroupID,
370
                    });
371
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
372
                    AngleValue = (member as ArrowTextControl).Angle;
373
                    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
                case "ImgControl":
385
                    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
                case "DateControl":
389
                    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
                case "SignControl":
393
                    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
                case "SymControl":
397
                    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
                case "SymControlN":
401
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
402
                    AngleValue = (member as SymControlN).Angle;
403
                    break;
404
                case "TextControl":
405
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
406
                    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
                        //CenterX = middle.X,
427
                        //CenterY = middle.Y,
428
                    };
429

    
430
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
431
                    AdornerBorder.RenderTransform = new RotateTransform()
432
                    {
433
                        Angle = (member as TextControl).Angle,
434
                        //CenterX = middle.X,
435
                        //CenterY = middle.Y,
436
                    };
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

    
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
                    });
458
                    break;
459
                default:
460
                    break;
461
                    #endregion
462
            }
463

    
464
            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

    
476
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
477
        }
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

    
487
        public void SetAdornerMember(List<CommentUserInfo> members)
488
        {
489
            foreach (var member in members)
490
            {
491
                switch (member.GetType().Name)
492
                {
493
                    #region 컨트롤 조건
494
                    case "LineControl":
495
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
496
                        break;
497
                    case "ImgControl":
498
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
499
                        break;
500
                    case "ArrowControl":
501
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
502
                        break;
503
                    case "PolygonControl":
504
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
505
                        break;
506
                    case "ArrowTextControl":
507
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
508
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
509
                        break;
510
                    case "ArcControl":
511
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
512
                        break;
513
                    case "ArrowArcControl":
514
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
515
                        break;
516
                    case "DateControl":
517
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
518
                        break;
519
                    case "ArrowControl_Multi":
520
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
521
                        break;
522
                    case "RectangleControl":
523
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
524
                        break;
525
                    case "TriControl":
526
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
527
                        break;
528
                    case "CircleControl":
529
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
530
                        break;
531
                    case "CloudControl":
532
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
533
                        break;
534
                    case "RectCloudControl":
535
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
536
                        break;
537
                    case "SignControl":
538
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
539
                        break;
540
                    case "SymControl":
541
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
542
                        break;
543
                    case "SymControlN":
544
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
545
                        break;
546
                    case "InkControl":
547
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
548
                        break;
549
                    case "TextControl":
550
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
551
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
552
                        {
553
                            BorderUpdate();
554
                            try
555
                            {
556
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
557
                            }
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
                    case "InsideWhiteControl":
570
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
571
                        break;
572
                    case "OverlapWhiteControl":
573
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
574
                        break;
575
                    case "ClipWhiteControl":
576
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
577
                        break;
578
                    case "CoordinateControl":
579
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
580
                        break;
581
                    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

    
596
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
597
            }
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
            double minX = double.MaxValue;
611
            double minY = double.MaxValue;
612
            double maxX = double.MinValue;
613
            double maxY = double.MinValue;
614

    
615
            if (this.Members.Count == 1)
616
            {
617
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
618
                {
619
                    if ((this.Members.First().DrawingData as TextControl).Angle != 0)
620
                    {
621
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle;
622
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle;
623
                    }
624
                    else
625
                    {
626
                        trRotate.Angle = 0;
627
                        trRotateThumb.Angle = 0;
628
                    }
629
                }
630
            }
631
            foreach (var item in this.Members)
632
            {
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
                    
649
                    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
                {                    
707
                    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

    
783
        /// <summary>
784
        /// 각 포인트들을 등록합니다.
785
        /// </summary>
786
        /// <param name="pointset">Drawing Point</param>
787
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
788
        {
789
            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
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
802
            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
                MyThumb tm = new MyThumb
810
                {
811
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
812
                };
813

    
814
                this.Members.Last().ThumbList.Add(tm);
815

    
816
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
817
                {
818
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
819
                }
820
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
821
                {
822
                    //if (this.Members.Count()<=1)
823
                    //{
824
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
825
                    List<Point> ps = new List<Point>();
826

    
827
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
828
                    {
829
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
830

    
831

    
832
                        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
                
942
                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
                
968
                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
            if (this.Members.Count > 1) return;
991
            if (reSizePoint != new Point(0, 0))
992
            {
993
                MyThumb thumb = sender as MyThumb;
994
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
995
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
996
                
997
                AdornerMember control = (from userThumb in this.Members
998
                                         where userThumb.ThumbList.Contains(thumb)
999
                                         select userThumb).FirstOrDefault();
1000

    
1001
                IPath AllControl = control.DrawingData as IPath;
1002
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
1003
                control.UpdateThumb();
1004
                this.BorderUpdate();
1005
            }
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
            var comments = (from drawing in this.Members
1017
                            select drawing.DrawingData as CommentUserInfo).ToList();
1018
            UndoCommand.Instance.Push(comments, this.AngleValue);
1019
        }
1020

    
1021
        /// <summary>
1022
        /// start drag
1023
        /// </summary>
1024
        /// <param name="sender"></param>
1025
        /// <param name="e"></param>
1026
        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
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1037
            {
1038
                return;
1039
            }
1040

    
1041
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1042
            {
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
            var comments = (from drawing in this.Members
1053
                            select drawing.DrawingData as CommentUserInfo).ToList();
1054
            UndoCommand.Instance.Push(comments, this.AngleValue);
1055
        }
1056

    
1057
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1058
        {
1059
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1060
            {
1061
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1062
                    IsTextAngle = true;
1063
                else
1064
                    IsTextAngle = false;
1065
                LastRotateVerticalValue = e.GetPosition(this).X;
1066
            }
1067
            else
1068
            {
1069
                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
        }
1080

    
1081
        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
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1122
        {
1123
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1124
            var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1125

    
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
            try
1129
            {
1130
                DragThumb.Cursor = Cursors.SizeAll;
1131
                this.TranslateItems(horzChange, vertChange);
1132
            }
1133
            finally
1134
            {
1135
                /// update CurrentMousePoint
1136
                this.CurrentMousePoint = tmp;
1137
            }
1138
        }
1139

    
1140
        /// <summary>
1141
        /// translate all members
1142
        /// </summary>
1143
        /// <param name="e"></param>
1144
        public void TranslateItems(double dx, double dy)
1145
        {
1146
            Dispatcher.BeginInvoke((Action)(() =>
1147
            {
1148
                foreach (var item in this.Members)
1149
                {
1150
                    this.TranslateItem(dx, dy, item);
1151
                }
1152
            }));
1153
            this.BorderUpdate();
1154
        }
1155

    
1156
        /// <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
        {
1163
            /// 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
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1168

    
1169
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1170
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1171

    
1172
            item.UpdateThumb();
1173
        }
1174

    
1175
        private void resize_MouseMove(object sender, MouseEventArgs e)
1176
        {
1177
            reSizePoint = e.GetPosition(this);
1178
        }
1179

    
1180
        /// <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
        bool RotateFlag = false;
1193

    
1194
        /// <summary>
1195
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1196
        /// </summary>
1197
        /// <param name="e"></param>
1198
        public void MoveRotate(DragDeltaEventArgs e)
1199
        {
1200
            Point CenterPoint = this.Centeroid;
1201
            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
            double dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1206

    
1207
            AngleValue += dDeltaAngle;
1208
            if (AngleValue > 360) AngleValue -= 360;
1209
            if (AngleValue < 0) AngleValue += 360;
1210
            this.rotatePoint = pt;  /// save rotatePoint
1211

    
1212
            Dispatcher.BeginInvoke((Action)(() =>
1213
            {
1214
                foreach (var member in this.Members)
1215
                {
1216
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1217
                    #region 보더 업데이트
1218
                    switch (member.Drawingtype)
1219
                    {
1220
                        case ControlType.TextControl:
1221
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1222

    
1223
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1224
                            DragThumb.RenderTransform = new RotateTransform()
1225
                            {
1226

    
1227
                                Angle = (member.DrawingData as CommentUserInfo).Angle
1228
                            };
1229

    
1230
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1231
                            AdornerBorder.RenderTransform = new RotateTransform()
1232
                            {
1233
                                Angle = (member.DrawingData as CommentUserInfo).Angle
1234
                            };
1235

    
1236
                            //(member.DrawingData as TextControl).Angle = AngleValue;
1237

    
1238
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1239
                            BorderUpdate();
1240
                            break;
1241

    
1242
                        case ControlType.ArrowMultiLine:
1243
                        case ControlType.ArcLine:
1244
                        case ControlType.ArcArrow:
1245
                        case ControlType.SingleLine:
1246
                        case ControlType.Triangle:
1247
                        case ControlType.ArrowTextControl:
1248
                        case ControlType.PolygonControl:
1249
                        case ControlType.Ink:
1250
                            BorderUpdate();
1251
                            break;
1252
                        case ControlType.Date:
1253
                        case ControlType.RectCloud:
1254
                        case ControlType.Rectangle:
1255
                        case ControlType.ImgControl:
1256
                        case ControlType.Sign:
1257
                        case ControlType.Symbol:
1258
                        case ControlType.Stamp:
1259
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1260
                            BorderUpdate();
1261
                            break;
1262
                        case ControlType.PolygonCloud:
1263
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1264
                            BorderUpdate();
1265
                            break;
1266
                        case ControlType.Circle:
1267
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1268
                            ((CircleControl)member.DrawingData).SetCenterXY();
1269
                            BorderUpdate();
1270
                            break;
1271
                        default:
1272
                            break;
1273
                    }
1274
                }
1275
                #endregion
1276
            }));
1277
        }
1278

    
1279
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1280
        {            
1281
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1282
            rotateTop.Cursor = Cursors.SizeAll;
1283

    
1284
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1285
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1286
            {
1287
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1288
            }
1289
            /// up to here
1290

    
1291
            if (ViewerDataModel.Instance.UndoDataList == null)
1292
            {
1293
                return;
1294
            }
1295

    
1296
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1297
            {
1298
                return;
1299
            }
1300

    
1301
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1302
            {
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
            var comments = (from drawing in this.Members
1313
                            select drawing.DrawingData as CommentUserInfo).ToList();
1314
            UndoCommand.Instance.Push(comments, this.AngleValue);
1315
        }
1316
        
1317
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1318
        {
1319
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1320

    
1321
            var comments = (from drawing in this.Members
1322
                            select drawing.DrawingData as CommentUserInfo).ToList();
1323
            UndoCommand.Instance.Push(comments, this.AngleValue);
1324
        }
1325

    
1326
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1327
        {
1328
            AdornerMember control = this.Members.FirstOrDefault();
1329

    
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

    
1340
        public void TextControlChanger()
1341
        {
1342
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1343
            {
1344
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1345
                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

    
1378
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1379
        {
1380
            if (e.ClickCount == 2 && this.Members.Count == 1)
1381
            {
1382

    
1383
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1384
                {
1385
                    TextControlChanger();                    
1386
                }
1387

    
1388
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1389
                {
1390
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1391
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1392
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1393

    
1394
                    //ArrowControl TextBox Thumb없애기
1395
                    tm.Visibility = Visibility.Collapsed;
1396

    
1397
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1398
                    
1399
                    ((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
                        
1407
                        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
                            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
                        }
1422
                        else
1423
                        {
1424
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1425
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1426
                        }
1427

    
1428

    
1429
                        BorderUpdate();
1430

    
1431
                    };
1432
                }
1433
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1434
                {
1435
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1436
                    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
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1458
                {
1459
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1460
                    if (instance.isTransOn)
1461
                    {
1462
                        instance.isTransOn = false;
1463
                    }
1464
                    else
1465
                    {
1466
                        instance.isTransOn = true;
1467
                    }
1468
                    ///instance.SetArcPath();
1469
                    BorderUpdate();
1470
                }
1471
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1472
                {
1473
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1474
                    if (instance.isTransOn)
1475
                    {
1476
                        instance.isTransOn = false;
1477
                    }
1478
                    else
1479
                    {
1480
                        instance.isTransOn = true;
1481
                    }
1482
                    instance.SetArcPath();
1483
                    BorderUpdate();
1484
                }
1485

    
1486
            }
1487
            
1488
        }
1489
        #endregion
1490

    
1491
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1492
        {
1493
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1494
            {
1495
                DragThumb.Visibility = Visibility.Collapsed;
1496
            }
1497
        }
1498
    }
1499
}
클립보드 이미지 추가 (최대 크기: 500 MB)