프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 54e35b39

이력 | 보기 | 이력해설 | 다운로드 (69.8 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.Polygon;
9
using MarkupToPDF.Controls.Shape;
10
using MarkupToPDF.Controls.Text;
11
using System;
12
using System.Collections.Generic;
13
using System.Diagnostics;
14
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
    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
        /// translate thumb with given delta and angle
37
        /// </summary>
38
        /// <param name="e"></param>
39
        /// <param name="angle"></param>
40
        public void Translate(double dx, double dy, double angle)
41
        {
42
            double radian = angle * Math.PI / 180;
43
            double cos = Math.Cos(radian);
44
            double sin = Math.Sin(radian);
45

    
46
            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
        }
51

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

    
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

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

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

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

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

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

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

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

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

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

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

    
463
            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

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

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

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

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

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

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

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

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

    
830

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

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

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

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

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

    
1080
        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
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1121
        {
1122
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1123
            var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1124
            
1125
            var horzChange = Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1126
            var vertChange = Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1127
            try
1128
            {
1129
                DragThumb.Cursor = Cursors.SizeAll;
1130
                this.TranslateItems(horzChange, vertChange);
1131
            }
1132
            finally
1133
            {
1134
                /// update CurrentMousePoint
1135
                this.CurrentMousePoint = tmp;
1136
            }
1137
        }
1138

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

    
1155
        /// <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
        {
1162
            /// 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
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1167
            item.UpdateThumb();
1168
        }
1169

    
1170
        private void resize_MouseMove(object sender, MouseEventArgs e)
1171
        {
1172
            reSizePoint = e.GetPosition(this);
1173
        }
1174

    
1175
        /// <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
        bool RotateFlag = false;
1188

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

    
1202
            AngleValue += dDeltaAngle;
1203
            if (AngleValue > 360) AngleValue -= 360;
1204
            if (AngleValue < 0) AngleValue += 360;
1205
            this.rotatePoint = pt;  /// save rotatePoint
1206

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

    
1218
                            //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

    
1232
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1233
                            DragThumb.RenderTransform = new RotateTransform()
1234
                            {
1235

    
1236
                                Angle = (member.DrawingData as CommentUserInfo).Angle
1237
                            };
1238

    
1239
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1240
                            AdornerBorder.RenderTransform = new RotateTransform()
1241
                            {
1242
                                //Angle = (member.DrawingData as TextControl).Angle,
1243
                                Angle = (member.DrawingData as CommentUserInfo).Angle
1244
                            };
1245

    
1246
                            (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

    
1254
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1255
                            BorderUpdate();
1256
                            break;
1257

    
1258
                        case ControlType.ArrowMultiLine:
1259
                        case ControlType.ArcLine:
1260
                        case ControlType.ArcArrow:
1261
                        case ControlType.SingleLine:
1262
                        case ControlType.Triangle:
1263
                        case ControlType.ArrowTextControl:
1264
                        case ControlType.PolygonControl:
1265
                        case ControlType.Ink:
1266
                            BorderUpdate();
1267
                            break;
1268
                        case ControlType.Date:
1269
                        case ControlType.RectCloud:
1270
                        case ControlType.Rectangle:
1271
                        case ControlType.ImgControl:
1272
                        case ControlType.Sign:
1273
                        case ControlType.Symbol:
1274
                        case ControlType.Stamp:
1275
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1276
                            BorderUpdate();
1277
                            break;
1278
                        case ControlType.PolygonCloud:
1279
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1280
                            BorderUpdate();
1281
                            break;
1282
                        case ControlType.Circle:
1283
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1284
                            ((CircleControl)member.DrawingData).SetCenterXY();
1285
                            BorderUpdate();
1286
                            break;
1287
                        default:
1288
                            break;
1289
                    }
1290
                }
1291
                #endregion
1292
            }));
1293
        }
1294

    
1295
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1296
        {            
1297
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1298
            rotateTop.Cursor = Cursors.SizeAll;
1299

    
1300
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1301
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1302
            {
1303
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1304
            }
1305
            /// up to here
1306

    
1307
            if (ViewerDataModel.Instance.UndoDataList == null)
1308
            {
1309
                return;
1310
            }
1311

    
1312
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1313
            {
1314
                return;
1315
            }
1316

    
1317
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1318
            {
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
            var comments = (from drawing in this.Members
1329
                            select drawing.DrawingData as CommentUserInfo).ToList();
1330
            UndoCommand.Instance.Push(comments, this.AngleValue);
1331
        }
1332
        
1333
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1334
        {
1335
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1336

    
1337
            var comments = (from drawing in this.Members
1338
                            select drawing.DrawingData as CommentUserInfo).ToList();
1339
            UndoCommand.Instance.Push(comments, this.AngleValue);
1340
        }
1341

    
1342
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1343
        {
1344
            AdornerMember control = this.Members.FirstOrDefault();
1345

    
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

    
1356
        public void TextControlChanger()
1357
        {
1358
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1359
            {
1360
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1361
                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

    
1394
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1395
        {
1396
            if (e.ClickCount == 2 && this.Members.Count == 1)
1397
            {
1398

    
1399
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1400
                {
1401
                    TextControlChanger();                    
1402
                }
1403

    
1404
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1405
                {
1406
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1407
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1408
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1409

    
1410
                    //ArrowControl TextBox Thumb없애기
1411
                    tm.Visibility = Visibility.Collapsed;
1412

    
1413
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1414
                    
1415
                    ((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
                        
1423
                        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
                            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
                        }
1438
                        else
1439
                        {
1440
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1441
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1442
                        }
1443

    
1444

    
1445
                        BorderUpdate();
1446

    
1447
                    };
1448
                }
1449
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1450
                {
1451
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1452
                    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
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1474
                {
1475
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1476
                    if (instance.isTransOn)
1477
                    {
1478
                        instance.isTransOn = false;
1479
                    }
1480
                    else
1481
                    {
1482
                        instance.isTransOn = true;
1483
                    }
1484
                    ///instance.SetArcPath();
1485
                    BorderUpdate();
1486
                }
1487
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1488
                {
1489
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1490
                    if (instance.isTransOn)
1491
                    {
1492
                        instance.isTransOn = false;
1493
                    }
1494
                    else
1495
                    {
1496
                        instance.isTransOn = true;
1497
                    }
1498
                    instance.SetArcPath();
1499
                    BorderUpdate();
1500
                }
1501

    
1502
            }
1503
            
1504
        }
1505
        #endregion
1506

    
1507
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1508
        {
1509
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1510
            {
1511
                DragThumb.Visibility = Visibility.Collapsed;
1512
            }
1513
        }
1514
    }
1515
}
클립보드 이미지 추가 (최대 크기: 500 MB)