프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 01cbc243

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

1 787a4489 KangIngu

2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Line;
4
using MarkupToPDF.Controls.Polygon;
5
using MarkupToPDF.Controls.Shape;
6
using MarkupToPDF.Controls.Text;
7
using MarkupToPDF.Controls.Etc;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Data;
15
using System.Windows.Documents;
16
using System.Windows.Input;
17
using System.Windows.Media;
18
using System.Windows.Media.Imaging;
19
using System.Windows.Navigation;
20
using System.Windows.Shapes;
21
using KCOM.Common;
22
using IKCOM;
23
using System.Windows.Ink;
24
using System.Collections.ObjectModel;
25
using Telerik.Windows.Controls;
26
using KCOM.Events;
27
using System.Reflection;
28
using MarkupToPDF.Common;
29
using KCOM.Controls;
30
31
namespace KCOM.Views
32
{
33
    public static class ControlExtensions
34
    {
35
        public static T Clone<T>(this T controlToClone)
36
            where T : System.Windows.Controls.Control
37
        {
38
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
39
40
            T instance = Activator.CreateInstance<T>();
41
42
            foreach (PropertyInfo propInfo in controlProperties)
43
            {
44
                if (propInfo.CanWrite)
45
                {
46
                    if (propInfo.Name != "WindowTarget")
47
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
48
                }
49
            }
50
            return instance;
51
        }
52
    }
53
54 a0bab669 KangIngu
    public class MyConsole
55
    {
56
        private readonly System.Threading.ManualResetEvent _readLineSignal;
57
        private string _lastLine;
58
        public MyConsole()
59
        {
60
            _readLineSignal = new System.Threading.ManualResetEvent(false);
61
            Gui = new TextBox();
62
            Gui.AcceptsReturn = true;
63
            Gui.KeyUp += OnKeyUp;
64
        }
65
66
        private void OnKeyUp(object sender, KeyEventArgs e)
67
        {
68
            // this is always fired on UI thread
69
            if (e.Key == Key.Enter)
70
            {
71
                // quick and dirty, but that is not relevant to your question
72
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
73
                // now, when you detected that user typed a line, set signal
74
                _readLineSignal.Set();
75
            }
76
        }
77
78
        public TextBox Gui { get; private set; }
79
80
        public string ReadLine()
81
        {
82
            // that should always be called from non-ui thread
83
            if (Gui.Dispatcher.CheckAccess())
84
                throw new Exception("Cannot be called on UI thread");
85
            // reset signal
86
            _readLineSignal.Reset();
87
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
88
            _readLineSignal.WaitOne();
89
            // we got signalled - return line user typed.
90
            return _lastLine;
91
        }
92
93
        public void WriteLine(string line)
94
        {
95
            if (!Gui.Dispatcher.CheckAccess())
96
            {
97
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
98
                return;
99
            }
100
101
            Gui.Text += line + Environment.NewLine;
102
        }
103
    }
104
105 787a4489 KangIngu
    /// <summary>
106
    /// MainMenu.xaml에 대한 상호 작용 논리
107
    /// </summary>
108
    public partial class MainMenu : UserControl
109
    {
110
        #region 프로퍼티
111
        public Undo_data UndoData { get; set; }
112
        public CommentUserInfo currentControl { get; set; }
113
        public ControlType controlType { get; set; }
114
        private Move move;
115
        private double[] rotateValue = { 0, 90, 180, 270 };
116
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
117
        public MouseButton mouseButtonDown { get; set; }
118
        private static readonly double DragThreshold = 5;
119
        private Cursor cursor { get; set; }
120
        private Point canvasDrawingMouseDownPoint;
121
        public string filename { get; set; }
122
        private Point canvasZoomPanningMouseDownPoint;
123
        public Point getCurrentPoint;
124
        private Point canvasZoommovingMouseDownPoint;
125
        private int rotateOffSet = 0;
126
        List<object> ControlList = new List<object>();
127
        private ListBox listBox = new ListBox();
128
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
129
        private bool isDraggingSelectionRect = false;
130
        DrawingAttributes inkDA = new DrawingAttributes();
131
        private VPRevision CurrentRev { get; set; }
132
        public RadRibbonButton btnConsolidate { get; set; }
133
        public RadRibbonButton btnFinalPDF { get; set; }
134
        public RadRibbonButton btnTeamConsolidate { get; set; }
135
        public string Filename_ { get; set; }
136
        public double L_Size = 0;
137
        public AdornerFinal adorner_;
138
        public Multi_Undo_data multi_Undo_Data;
139 5ce56a3a KangIngu
        public string Symbol_ID = "";
140 787a4489 KangIngu
        /// <summary>
141
        /// Set to 'true' when the left mouse-button is down.
142
        /// </summary>
143 9f473fb7 KangIngu
        public bool isLeftMouseButtonDownOnWindow = false;
144 787a4489 KangIngu
145
        public InkPresenter _InkBoard = null;
146
        Stroke stroke;
147
        Boolean IsDrawing = false;
148
        StylusPointCollection strokePoints;
149
        StylusPointCollection erasePoints;
150
        RenderTargetBitmap canvasImage;
151
        Point Sync_Offset_Point;
152
153
        //강인구 테스트
154
        private Path _SelectionPath { get; set; }
155
        public Path SelectionPath
156
        {
157
            get
158
            {
159
                return _SelectionPath;
160
            }
161
            set
162
            {
163
                if (_SelectionPath != value)
164
                {
165
                    _SelectionPath = value;
166
                    RaisePropertyChanged("SelectionPath");
167
168
                }
169
            }
170
        }
171
172
        private System.Windows.Controls.Image _imageViewer { get; set; }
173
        public System.Windows.Controls.Image imageViewer
174
        {
175
            get
176
            {
177
                if (_imageViewer == null)
178
                {
179
                    _imageViewer = new System.Windows.Controls.Image();
180
                    return _imageViewer;
181
                }
182
                else
183
                {
184
                    return _imageViewer;
185
                }
186
            }
187
            set
188
            {
189
                if (_imageViewer != value)
190
                {
191
                    _imageViewer = value;
192
                }
193
            }
194
        }
195
196
        public bool IsSyncPDFMode { get; set; }
197
198
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
199
        public System.Windows.Controls.Image imageViewer_Compare
200
        {
201
            get
202
            {
203
                if (_imageViewer_Compare == null)
204
                {
205
                    _imageViewer_Compare = new System.Windows.Controls.Image();
206
                    return _imageViewer_Compare;
207
                }
208
                else
209
                {
210
                    return _imageViewer_Compare;
211
                }
212
            }
213
            set
214
            {
215
                if (_imageViewer_Compare != value)
216
                {
217
                    _imageViewer_Compare = value;
218
                }
219
            }
220
        }
221
222
        #endregion
223
224
225
        public MainMenu()
226
        {
227
            InitializeComponent();
228
            this.Loaded += MainMenu_Loaded;
229
        }
230
        private void SetCursor()
231
        {
232
            this.Cursor = cursor;
233
        }
234
235
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
236
        {
237
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
238
                             zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
239
                             (_canvasZoomPanningMouseDownPoint.Y > 0 &&
240
                             zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
241
            {
242
                return true;
243
            }
244
245
            return false;
246
        }
247
248
        public void DeleteItem(MarkupInfoItem item)
249
        {
250
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
251
            {
252
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
253
            }
254
255
            ViewerDataModel.Instance._markupInfoList.Remove(item);
256
257
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
258
            {
259
                ViewerDataModel.Instance.MarkupControls.Remove(a);
260
            });
261
262
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
263
            {
264
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
265
            });
266
267
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
268
            {
269
                ComingNewBieEnd = false;
270
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
271
            });
272
273
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
274
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
275
            {
276
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
277
                {
278
                    var infoId = Events.Save.shortGuid();
279
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
280
                    {
281
                        CreateTime = DateTime.Now,
282
                        Depatment = userData.DEPARTMENT,
283
                        DisplayColor = "#FFFF0000",
284
                        UserID = userData.ID,
285
                        UserName = userData.NAME,
286
                        PageCount = 1,
287
                        Description = "",
288
                        MarkupInfoID = infoId,
289
                        MarkupList = null,
290
                        MarkupVersionID = Events.Save.shortGuid(),
291
                        Consolidate = 0,
292
                        PartConsolidate = 0,
293
                        userDelete = true,
294
                        AvoidConsolidate = 0,
295
                        IsPreviewUser = true
296
                    };
297
                    App.Custom_ViewInfoId = infoId;
298
                }
299
            }
300
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
301
        }
302
303
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
304
        {
305
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
306
            this.ReleaseAdorner();
307
308
            Button content = (sender as Button);
309
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
310
311
            DeleteItem(item);
312
        }
313
314
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
315
316
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
317
        {
318
            if (App.ParameterMode)
319
            {
320
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
321
                imageViewer_Compare = new Image();
322 ae56d52d KangIngu
                
323 787a4489 KangIngu
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
324
                ViewerDataModel.Instance.Capture_Opacity = 0;
325
326
                da.From = 0.8;
327
                da.To = 0;
328
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
329
                da.AutoReverse = true;
330
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
331
            }
332
333
334
        }
335
336
        public void ReleaseAdorner()
337
        {
338
            if (SelectLayer.Children.Count > 0)
339
            {
340
                foreach (var item in SelectLayer.Children)
341
                {
342
                    if (item.GetType().Name == "AdornerFinal")
343
                    {
344
                        (item as AdornerFinal).unRegister();
345
346
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
347
                        {
348
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
349
                            {
350
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
351
                                {
352
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
353
                                    {
354
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
355
                                    }
356
                                }
357
358
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
359
                            }
360
                        }
361
                    }
362
                }
363
                SelectLayer.Children.Clear();
364
            }
365
        }
366
367
        public List<CommentUserInfo> AddAdorner()
368
        {
369
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
370
371
            if (SelectLayer.Children.Count > 0)
372
            {
373
                foreach (var item in SelectLayer.Children)
374
                {
375
                    if (item.GetType().Name == "AdornerFinal")
376
                    {
377
                        (item as AdornerFinal).unRegister();
378
379
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
380
                        {
381
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
382
                            {
383
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
384
                            }
385
386
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
387
388
                            UndoData.Markup_List.Add(multi_Undo_Data);
389
                            multi_Undo_Data = new Multi_Undo_data();
390
                        }
391
                    }
392
                }
393
                SelectLayer.Children.Clear();
394
            }
395
            return adornerSet;
396
        }
397
398
        public void ChangeCommentReact()
399
        {
400
            bool isComingNewBie = false;
401
402
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
403
            {
404
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
405
                {
406
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
407
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
408
                    if (existItem != null) //신규 추가 된 코멘트
409
                    {
410
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
411
                        {
412
                            existItem.Data = root.ConvertData;
413
                            existItem.IsUpdate = true;
414
                        }
415
                    }
416
                    else
417
                    {
418
                        if (root.CommentID != null)
419
                        {
420
                            isComingNewBie = true;
421
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
422
                            if (currentCommentCheck != null)
423
                            {
424
                                currentCommentCheck.Data = root.ConvertData;
425
                            }
426
                            else
427
                            {
428
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
429
                                {
430
                                    ID = control.CommentID,
431
                                    Data = root.ConvertData,
432
                                    Data_Type = root.DATA_TYPE,
433
                                    MarkupInfoID = App.Custom_ViewInfoId,
434
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
435
                                });
436
                            }
437
                        }
438
                    }
439
                }
440
            }
441
442
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
443
            {
444
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
445
                {
446
                    ComingNewBieEnd = true;
447
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
448
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
449
                    gridViewMarkup.ItemsSource = null;
450
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
451
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
452
                }
453
            }
454
455
        }
456
457
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
458
        bool ComingNewBieEnd = false;
459
460
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
461
        {
462
            ViewerDataModel.Instance.UndoDataList.Clear();
463
464
            InkControl_Convert();
465
466
            ReleaseAdorner();
467
            ChangeCommentReact();
468
            CompareMode.IsChecked = false;
469
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
470
471
472
            #region 페이지가 벗어난 경우
473
474
            if (BalancePoint < 1)
475
            {
476
                BalancePoint = 1;
477
                ViewerDataModel.Instance.PageBalanceNumber = 0;
478
            }
479
480
            if (pageNavigator.PageCount < BalancePoint)
481
            {
482
                BalancePoint = pageNavigator.PageCount;
483
                ViewerDataModel.Instance.PageBalanceNumber = 0;
484
            }
485
486
            #endregion
487
488
            ViewerDataModel.Instance.PageNumber = BalancePoint;
489
490
            var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
491
492
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
493
494
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
495
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
496
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
497
498
            if (defaultBitmapImage.IsDownloading)
499
            {
500
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
501
                {
502
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
503
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
504
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
505
                };
506
            }
507
508
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
509
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
510
511
512
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
513
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
514
            inkBoard.Width = zoomAndPanCanvas.Width;
515
            inkBoard.Height = zoomAndPanCanvas.Height;
516
517
518
            if (!testPanel2.IsHidden)
519
            {
520
                //PDF모드일때 잠시 대기(강인구)
521
                if (IsSyncPDFMode)
522
                {
523
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
524
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
525
526
                    if (pdfpath.IsDownloading)
527
                    {
528
                        pdfpath.DownloadCompleted += (ex, arg) =>
529
                        {
530
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
531
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
532
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
533
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
534
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
535
                        };
536
                    }
537
                    else
538
                    {
539
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
540
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
541
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
542
543
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
544
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
545
                    }
546
                }
547
                else
548
                {
549
                    var uri2 = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
550
551
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
552
553
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
554
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
555
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
556
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
557
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
558
559
                    zoomAndPanControl.ZoomTo(new Rect
560
                    {
561
                        X = 0,
562
                        Y = 0,
563
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
564
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
565
                    });
566
567
                    if (defaultBitmapImage_Compare.IsDownloading)
568
                    {
569
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
570
                        {
571
572
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
573
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
574
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
575
576
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
577
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
578
579
                            zoomAndPanControl.ZoomTo(new Rect
580
                            {
581
                                X = 0,
582
                                Y = 0,
583
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
584
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
585
                            });
586
                        };
587
                    }
588
                }
589
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
590
            }
591
592
            this.pageNavigator.SetNextPage();
593
594
            if (zoomAndPanCanvas2.Width.IsNaN())
595
            {
596
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
597
            }
598
599
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
600
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
601
602
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
603
            foreach (var item in gridSelectionItem)
604
            {
605
                if (item.UserID == App.ViewInfo.UserID)
606
                {
607
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
608
                    {
609
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
610
                    });
611
                }
612
                else
613
                {
614
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
615
                    {
616
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
617
                    });
618
                }
619
            }
620
621
622
            if (!testPanel2.IsHidden)
623
            {
624
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
625
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
626
627
628
                foreach (var item in gridSelectionRevItem)
629
                {
630
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
631
                    {
632
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
633
                    });
634
                }
635
636
            }
637
638
639
640
            var instanceMain = this.ParentOfType<MainWindow>();
641
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
642
643
            //강인구 추가
644
            instanceMain.dzTopMenu.rotateOffSet = 0;
645
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
646
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
647
648
            //}
649
            SetCommentPages(true);
650
        }
651
652
        private void SetCommentPages(bool onlyMe = false)
653
        {
654
655
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
656
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
657
            {
658
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
659
                instance.UserName = item.UserName;
660
                instance.Depart = item.Depatment;
661
                instance.MarkupInfoID = item.MarkupInfoID;
662
                instance.IsSelected = true;
663
                instance.isConSolidation = item.Consolidate;
664
                instance.SetColor = item.DisplayColor;
665
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
666
                {
667
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
668
                }
669
                else
670
                {
671
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
672
                }
673
                _pages.Add(instance);
674
            }
675
            this.pageNavigator.SetCommentList(_pages.ToList());
676
        }
677
678
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
679
        {
680
            if (e.MiddleButton == MouseButtonState.Pressed)
681
            {
682
683
            }
684
            e.Handled = true;
685
            if (e.Delta > 0)
686
            {
687
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
688
                ZoomIn(currentContentMousePoint);
689
            }
690
            else
691
            {
692
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
693
                ZoomOut(currentContentMousePoint);
694
            }
695
        }
696
697
        #region ZoomIn & ZoomOut
698
699
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
700
        {
701
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
702
                zoomAndPanControl.ContentZoomFocusY));
703
        }
704
705
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
706
        {
707
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
708
                zoomAndPanControl.ContentZoomFocusY));
709
        }
710
711
712
        //강인구 추가 (줌 인아웃 수치 변경)
713
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
714
        private void ZoomOut(Point contentZoomCenter)
715
        {
716
            if (zoomAndPanControl.ContentScale > 0.39)
717
            {
718
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
719
            }
720
            else
721
            {
722
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
723
            }
724
725
            if (zoomAndPanControl2 != null)
726
            {
727
                if (zoomAndPanControl2.ContentScale > 0.39)
728
                {
729
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
730
                }
731
                else
732
                {
733
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
734
                }
735
            }
736
        }
737
738
        private void ZoomIn(Point contentZoomCenter)
739
        {
740
            if (zoomAndPanControl.ContentScale > 0.19)
741
            {
742
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
743
            }
744
            else
745
            {
746
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
747
            }
748
749
            if (zoomAndPanControl2 != null)
750
            {
751
                if (zoomAndPanControl2.ContentScale > 0.19)
752
                {
753
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
754
                }
755
                else
756
                {
757
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
758
                }
759
            }
760
        }
761
762
        private void ZoomOut()
763
        {
764
            zoomAndPanControl.ContentScale -= 0.1;
765
            //if (zoomAndPanControl2 != null)
766
            //{
767
            //    zoomAndPanControl2.ContentScale -= 0.1;
768
            //}
769
        }
770
771
        private void ZoomIn()
772
        {
773
            zoomAndPanControl.ContentScale += 0.1;
774
            //if (zoomAndPanControl2 != null)
775
            //{
776
            //    zoomAndPanControl2.ContentScale += 0.1;
777
            //}
778
        }
779
780
        #endregion
781
782
        private void init()
783
        {
784
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
785
            {
786
787
                ControlList.Clear();
788
                listBox.Items.Clear();
789
                selected_item.Clear();
790
791
                (item as IMarkupCommonData).IsSelected = false;
792
            }
793
794
        }
795
796
        private HitTestResultBehavior MyCallback(HitTestResult result)
797
        {
798
            //this.cursor = Cursors.UpArrow;
799
            var element = result.VisualHit;
800
            while (element != null && !(element is CommentUserInfo))
801
                element = VisualTreeHelper.GetParent(element);
802
803
            if (element == null)
804
            {
805
                return HitTestResultBehavior.Stop;
806
            }
807
            else
808
            {
809
                if (element is CommentUserInfo)
810
                {
811
                    if (!hitList.Contains(element))
812
                    {
813
                        hitList.Add((CommentUserInfo)element);
814
                    }
815
                    else
816
                    {
817
                        return HitTestResultBehavior.Stop;
818
                    }
819
                    //IntersectionDetail intersectionDetail =
820
                    //((GeometryHitTestResult)result).IntersectionDetail;
821
                    //switch (intersectionDetail)
822
                    //{
823
                    //    case IntersectionDetail.FullyContains:
824
                    //        // Add the hit test result to the list:
825
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
826
                    //        return HitTestResultBehavior.Continue;
827
                    //    case IntersectionDetail.Intersects:
828
                    //        // Set the behavior to return visuals at all z-order levels:
829
                    //        return HitTestResultBehavior.Continue;
830
                    //    case IntersectionDetail.FullyInside:
831
                    //        // Set the behavior to return visuals at all z-order levels:
832
                    //        return HitTestResultBehavior.Continue;
833
                    //    default:
834
                    //        return HitTestResultBehavior.Stop;
835
                    //}
836
                }
837
            }
838
            return HitTestResultBehavior.Continue;
839
        }
840
841
        public void ReleaseSelectPath()
842
        {
843
            if (SelectionPath == null)
844
            {
845
                SelectionPath = new Path();
846
                SelectionPath.Name = "";
847
            }
848
            if (SelectionPath.Name != "")
849
            {
850
                SelectionPath.Name = "None";
851
            }
852
            SelectionPath.Opacity = 0.01;
853
            SelectionPath.RenderTransform = null;
854
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
855
        }
856
857
        #region 컨트롤 초기화 
858
        public void Control_Init(object control)
859
        {
860
            if (L_Size != 0 && (control as IPath) != null)
861
            {
862
                (control as IPath).LineSize = L_Size;
863
                L_Size = 0;
864
            }
865
866
            switch (control.GetType().Name)
867
            {
868
                case "RectangleControl":
869
                    {
870
                        (control as RectangleControl).StrokeColor = Brushes.Red;
871
                    }
872
                    break;
873
                case "CircleControl":
874
                    {
875
                        (control as CircleControl).StrokeColor = Brushes.Red;
876
                    }
877
                    break;
878
                case "TriControl":
879
                    {
880
                        (control as TriControl).StrokeColor = Brushes.Red;
881
                    }
882
                    break;
883
                case "RectCloudControl":
884
                    {
885
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
886
                    }
887
                    break;
888
                case "CloudControl":
889
                    {
890
                        (control as CloudControl).StrokeColor = Brushes.Red;
891
                    }
892
                    break;
893
                case "PolygonControl":
894
                    {
895
                        (control as PolygonControl).StrokeColor = Brushes.Red;
896
                    }
897
                    break;
898
                case "ArcControl":
899
                    {
900
                        (control as ArcControl).StrokeColor = Brushes.Red;
901
                    }
902
                    break;
903
                case "LineControl":
904
                    {
905
                        (control as LineControl).StrokeColor = Brushes.Red;
906
                    }
907
                    break;
908
                case "ArrowControl_Multi":
909
                    {
910
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
911
                    }
912
                    break;
913
                case "TextControl":
914
                    {
915
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
916
                    }
917
                    break;
918
                case "ArrowTextControl":
919
                    {
920
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
921
                    }
922
                    break;
923
            }
924
        }
925
        #endregion
926
927
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
928
        {
929
            //Control_Init(e.Source);
930
        }
931
932
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
933
        {
934
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
935
            {
936
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
937
938
                Point currentPos = e.GetPosition(rect);
939
940
                floatingTip.HorizontalOffset = currentPos.X + 20;
941
                floatingTip.VerticalOffset = currentPos.Y;
942
943
944
                //ToolTip tool = new System.Windows.Controls.ToolTip();
945
                //tool.Content = "ToolTip";
946
                //panel.ToolTip = tool;
947
            }
948
949
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
950
            {
951
                #region 마우스 오버 시 색상 변경
952
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
953
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
954
955
                //if (firstCondition != null)
956
                //{
957
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
958
959
                //    if (firstCondition.GetType().Name == "TextControl")
960
                //    {
961
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
962
                //        return;
963
                //    }
964
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
965
                //    {
966
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
967
                //        return;
968
                //    }
969
970
                //    if (L_Size == 0)
971
                //    {
972
                //        L_Size = (firstCondition as IPath).LineSize;
973
                //        (firstCondition as IPath).LineSize *= 4;
974
                //    }
975
                //    switch (firstCondition.GetType().Name)
976
                //    {
977
                //        case "RectangleControl":
978
                //            {
979
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
980
                //            }
981
                //            break;
982
                //        case "CircleControl":
983
                //            {
984
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
985
                //            }
986
                //            break;
987
                //        case "TriControl":
988
                //            {
989
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
990
                //            }
991
                //            break;
992
                //        case "RectCloudControl":
993
                //            {
994
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
995
                //            }
996
                //            break;
997
                //        case "CloudControl":
998
                //            {
999
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1000
                //            }
1001
                //            break;
1002
                //        case "PolygonControl":
1003
                //            {
1004
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1005
                //            }
1006
                //            break;
1007
                //        case "ArcControl":
1008
                //            {
1009
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1010
                //            }
1011
                //            break;
1012
                //        case "LineControl":
1013
                //            {
1014
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1015
                //            }
1016
                //            break;
1017
                //        case "ArrowControl_Multi":
1018
                //            {
1019
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1020
                //            }
1021
                //            break;
1022
1023
                //        default:
1024
                //            {
1025
1026
                //            }
1027
                //            break;
1028
                //    }
1029
                //} 
1030
                #endregion
1031
            }
1032
1033
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1034
1035
            if (mouseButtonDown == MouseButton.Middle)
1036
            {
1037
                SetCursor();
1038
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1039
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1040
1041
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1042 9f473fb7 KangIngu
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1043
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1044
1045
                //SetCursor();
1046
                //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1047
                //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1048
1049
                //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1050 787a4489 KangIngu
1051 9f473fb7 KangIngu
                //zoomAndPanControl.ContentOffsetX += 1;
1052
                //zoomAndPanControl.ContentOffsetY += 1;
1053 787a4489 KangIngu
1054
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1055
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1056
            }
1057
1058
            if (mouseButtonDown == MouseButton.Right)
1059
            {
1060
                SetCursor();
1061
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1062
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1063
1064
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1065
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1066
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1067
            }
1068
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1069
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1070
            {
1071
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1072
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1073
                SetCursor();
1074
1075
                if (IsDrawing)
1076
                {
1077
                    if (currentControl == null)
1078
                    {
1079
                        switch (controlType)
1080
                        {
1081
                            case ControlType.PenControl:
1082
                                {
1083
                                    if (inkBoard.Tag.ToString() == "Ink")
1084
                                    {
1085
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1086
                                    }
1087
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1088
                                    {
1089
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1090
                                    }
1091
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1092
                                    {
1093
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1094
                                    }
1095
1096
                                    //inkBoard.Strokes.Add(stroke);
1097
                                }
1098
                                break;
1099
                        }
1100
                        return;
1101
                    }
1102
                }
1103
1104
                if (currentControl != null)
1105
                {
1106
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1107
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1108
                    //강인구 추가
1109
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1110
1111
                    if ((currentControl as IPath) != null)
1112
                    {
1113
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1114
                    }
1115 5ce56a3a KangIngu
                    if ((currentControl as LineControl) != null)
1116
                    {
1117
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1118
                    }
1119
1120 787a4489 KangIngu
                    if ((currentControl as IShapeControl) != null)
1121
                    {
1122
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1123
                    }
1124
                    if ((currentControl as TextControl) != null)
1125
                    {
1126
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1127
                        {
1128
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1129
                        }
1130
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1131
                        {
1132 d4b0c723 KangIngu
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1133 787a4489 KangIngu
                        }
1134
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1135
                        {
1136
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1137
                        }
1138
                    }
1139
                    else if ((currentControl as ArrowTextControl) != null)
1140
                    {
1141
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1142
                        {
1143
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1144
                        }
1145
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1146
                        {
1147 d4b0c723 KangIngu
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1148 787a4489 KangIngu
                        }
1149
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1150
                        {
1151
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1152
                        }
1153
                    }
1154 9f473fb7 KangIngu
                    else if ((currentControl as RectCloudControl) != null)
1155
                    {
1156
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1157
                    }
1158
                    else if ((currentControl as CloudControl) != null)
1159
                    {
1160
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1161
                    }
1162 787a4489 KangIngu
1163
                    switch (controlType)
1164
                    {
1165
                        case ControlType.Rectangle:
1166
                            {
1167
                                var control = currentControl as RectangleControl;
1168
1169
                                if (control != null)
1170
                                {
1171
                                    if (move.mousemode == MouseMode.Drawing)
1172
                                    {
1173
                                        //move.control_Move(ControlList, true, moveX, moveY);
1174
                                    }
1175
                                    else
1176
                                    {
1177 17a22987 KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1178
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1179
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1180
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1181 787a4489 KangIngu
1182
1183 17a22987 KangIngu
                                        if (ViewerDataModel.Instance.IsPressShift)
1184
                                        {
1185 4318fdeb KangIngu
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1186 17a22987 KangIngu
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1187
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1188
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1189
                                        }
1190 4318fdeb KangIngu
                                        
1191 787a4489 KangIngu
                                        control.PointSet = new List<Point>
1192
                                        {
1193 17a22987 KangIngu
                                            control.StartPoint,
1194
                                            control.LeftBottomPoint,
1195
                                            control.EndPoint,
1196
                                            control.TopRightPoint,
1197 787a4489 KangIngu
                                        };
1198
                                        control.updateControl();
1199
                                    }
1200
1201
                                    //강인구 추가
1202
                                    control.ControlType = controlType;
1203
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1204
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1205
                                }
1206
                            }
1207
                            break;
1208
1209
                        case ControlType.RectCloud:
1210
                            {
1211
                                var control = currentControl as RectCloudControl;
1212
1213
                                if (control != null)
1214
                                {
1215
                                    if (move.mousemode == MouseMode.Drawing)
1216
                                    {
1217
                                        //move.control_Move(ControlList, true, moveX, moveY);
1218
                                    }
1219
                                    else
1220
                                    {
1221
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1222
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1223
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1224
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1225
1226 17a22987 KangIngu
                                        if (ViewerDataModel.Instance.IsPressShift)
1227
                                        {
1228 4318fdeb KangIngu
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1229 17a22987 KangIngu
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1230
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1231
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1232
                                        }
1233
1234 787a4489 KangIngu
                                        control.PointSet = new List<Point>
1235
                                        {
1236
                                            control.StartPoint,
1237
                                            control.LeftBottomPoint,
1238
                                            control.EndPoint,
1239
                                            control.TopRightPoint,
1240
                                        };
1241
                                    }
1242
                                    //강인구 추가
1243
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1244
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1245
                                }
1246
                            }
1247
                            break;
1248
1249
                        case ControlType.SingleLine:
1250
                            {
1251
                                if (currentControl != null)
1252
                                {
1253
                                    var control = currentControl as LineControl;
1254
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1255
                                    control.ControlType = controlType;
1256
                                    if (control != null)
1257
                                    {
1258 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1259
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1260
                                        Point tempPoint = control.EndPoint;
1261
1262
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1263 787a4489 KangIngu
                                        {
1264 5ce56a3a KangIngu
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1265
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1266
                                            control.EndPoint = tempPoint;
1267 787a4489 KangIngu
                                        }
1268
                                        else
1269
                                        {
1270 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1271 787a4489 KangIngu
                                        }
1272 5ce56a3a KangIngu
1273
                                       control.PointSet = new List<Point>
1274
                                        {
1275
                                            control.StartPoint,
1276
                                            control.EndPoint,
1277
                                        };
1278 787a4489 KangIngu
                                        //강인구 추가
1279
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1280
                                    }
1281
                                }
1282
1283
                            }
1284
                            break;
1285
1286
                        case ControlType.CancelLine:
1287
                            {
1288
                                if (currentControl != null)
1289
                                {
1290
                                    var control = currentControl as LineControl;
1291
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1292
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1293
                                    control.ControlType = controlType;
1294
                                    if (control != null)
1295
                                    {
1296 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1297
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1298
                                        Point tempPoint = control.EndPoint;
1299 787a4489 KangIngu
1300
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1301
                                        {
1302 5ce56a3a KangIngu
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1303
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1304 787a4489 KangIngu
                                            control.EndPoint = tempPoint;
1305
                                        }
1306
                                        else
1307
                                        {
1308 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1309 787a4489 KangIngu
                                        }
1310
1311
1312
                                        control.PointSet = new List<Point>
1313
                                            {
1314
                                                control.StartPoint,
1315
                                                control.EndPoint,
1316
                                            };
1317
                                    }
1318
                                    //강인구 추가
1319
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1320
                                }
1321
                            }
1322
                            break;
1323
1324
                        case ControlType.ArrowLine:
1325
                            {
1326
                                if (currentControl != null)
1327
                                {
1328
                                    var control = currentControl as LineControl;
1329
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1330
                                    control.ControlType = controlType;
1331
                                    if (control != null)
1332
                                    {
1333 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1334
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1335
                                        Point tempPoint = control.EndPoint;
1336 787a4489 KangIngu
1337
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1338
                                        {
1339 5ce56a3a KangIngu
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1340
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1341 787a4489 KangIngu
                                            control.EndPoint = tempPoint;
1342
                                        }
1343
                                        else
1344
                                        {
1345 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1346 787a4489 KangIngu
                                        }
1347
1348
1349
                                        control.PointSet = new List<Point>
1350
                                            {
1351
                                                control.StartPoint,
1352
                                                control.EndPoint,
1353
                                            };
1354
                                    }
1355
                                    //강인구 추가
1356
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1357
                                }
1358
1359
                            }
1360
                            break;
1361
1362
                        case ControlType.TwinLine:
1363
                            {
1364
                                if (currentControl != null)
1365
                                {
1366
                                    var control = currentControl as LineControl;
1367
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1368
                                    control.ControlType = controlType;
1369
                                    if (control != null)
1370
                                    {
1371 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1372
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1373
                                        Point tempPoint = control.EndPoint;
1374 787a4489 KangIngu
1375
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1376
                                        {
1377 5ce56a3a KangIngu
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1378
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1379 787a4489 KangIngu
                                            control.EndPoint = tempPoint;
1380
                                        }
1381
                                        else
1382
                                        {
1383 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1384 787a4489 KangIngu
                                        }
1385
1386
1387
                                        control.PointSet = new List<Point>
1388
                                            {
1389
                                                control.StartPoint,
1390
                                                control.EndPoint,
1391
                                            };
1392
                                    }
1393
                                    //강인구 추가
1394
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1395
                                }
1396
1397
                            }
1398
                            break;
1399
1400
                        case ControlType.DimLine:
1401
                            {
1402
                                if (currentControl != null)
1403
                                {
1404
                                    var control = currentControl as LineControl;
1405
                                    control.LineStyleSet = LineStyleSet.DimLine;
1406
                                    control.ControlType = controlType;
1407
                                    if (control != null)
1408
                                    {
1409 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1410
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1411
                                        Point tempPoint = control.EndPoint;
1412 787a4489 KangIngu
1413
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1414
                                        {
1415 5ce56a3a KangIngu
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1416
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1417 787a4489 KangIngu
                                            control.EndPoint = tempPoint;
1418
                                        }
1419
                                        else
1420
                                        {
1421 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1422 787a4489 KangIngu
                                        }
1423
1424
                                        control.PointSet = new List<Point>
1425
                                            {
1426
                                                control.StartPoint,
1427
                                                control.EndPoint,
1428
                                            };
1429
                                    }
1430
                                    //강인구 추가
1431
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1432
                                }
1433
1434
                            }
1435
                            break;
1436
1437
                        case ControlType.ChainLine:
1438
                            {
1439
                                var control = currentControl as PolygonControl;
1440
1441
                                if (control != null)
1442
                                {
1443 2eac4f76 KangIngu
1444 787a4489 KangIngu
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1445
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1446 2eac4f76 KangIngu
1447
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1448
1449
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1450
                                    {
1451
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1452
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count-2], ref tempPoint, true);
1453
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1454
                                        //control.EndPoint = tempPoint;
1455
                                    }
1456
                                    else
1457
                                    {
1458
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1459
                                    }
1460
1461 787a4489 KangIngu
                                    control.SetPolyPath();
1462
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1463
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1464
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1465
1466
                                    //강인구 추가
1467
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1468
                                }
1469
                            }
1470
                            break;
1471
1472
                        case ControlType.ArcLine:
1473
                            {
1474
                                if (currentControl != null)
1475
                                {
1476
                                    var control = currentControl as ArcControl;
1477
                                    control.isTransOn = false;
1478
                                    control.ControlType = controlType;
1479
1480
                                    if (control != null)
1481
                                    {
1482 5ce56a3a KangIngu
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1483
                                        control.MidPoint = new Point(0, 0);
1484
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1485
                                        Point tempPoint = control.EndPoint;
1486
1487
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1488 787a4489 KangIngu
                                        {
1489 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1490
                                            control.EndPoint = tempPoint;
1491 787a4489 KangIngu
                                        }
1492
                                        else
1493
                                        {
1494 5ce56a3a KangIngu
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1495 787a4489 KangIngu
                                        }
1496
1497
1498
                                        control.PointSet = new List<Point>
1499
                                            {
1500
                                                control.StartPoint,
1501
                                                control.MidPoint,
1502
                                                control.EndPoint,
1503
                                            };
1504
                                    }
1505
                                    //강인구 추가
1506
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1507
                                }
1508
1509
                            }
1510
                            break;
1511
1512
                        case ControlType.ArcArrow:
1513
                            {
1514
                                if (currentControl != null)
1515
                                {
1516
                                    var control = currentControl as ArcControl;
1517
                                    control.isTransOn = true;
1518
                                    control.ControlType = controlType;
1519
1520
                                    if (control != null)
1521
                                    {
1522
                                        if (move.mousemode == MouseMode.Drawing)
1523
                                        {
1524
                                            //move.control_Move(ControlList, true, moveX, moveY);
1525
                                        }
1526
                                        else
1527
                                        {
1528
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1529
                                            control.MidPoint = new Point(0, 0);
1530
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1531
                                        }
1532
1533
                                        control.PointSet = new List<Point>
1534
                                            {
1535
                                                control.StartPoint,
1536
                                                control.MidPoint,
1537
                                                control.EndPoint,
1538
                                            };
1539
                                    }
1540
                                    //강인구 추가
1541
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1542
                                }
1543
                            }
1544
                            break;
1545
1546
                        case ControlType.ArrowMultiLine:
1547
                            {
1548
                                if (currentControl != null)
1549
                                {
1550
                                    var control = currentControl as ArrowControl_Multi;
1551
1552
                                    if (control != null)
1553
                                    {
1554 5ce56a3a KangIngu
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1555
                                        Point tempPoint = control.EndPoint;
1556 787a4489 KangIngu
                                        if (control.MiddlePoint == new Point(0, 0))
1557
                                        {
1558
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1559
                                            {
1560 5ce56a3a KangIngu
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1561
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1562 787a4489 KangIngu
                                                control.EndPoint = tempPoint;
1563
                                            }
1564
                                            else
1565
                                            {
1566 5ce56a3a KangIngu
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1567 787a4489 KangIngu
                                            }
1568
                                        }
1569
                                        else
1570
                                        {
1571
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1572
                                            {
1573 5ce56a3a KangIngu
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1574 2eac4f76 KangIngu
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1575 787a4489 KangIngu
                                                control.EndPoint = tempPoint;
1576
                                            }
1577
                                            else
1578
                                            {
1579 2eac4f76 KangIngu
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1580 787a4489 KangIngu
                                            }
1581
1582
                                        }
1583
1584
                                        control.PointSet = new List<Point>
1585
                                            {
1586
                                                control.StartPoint,
1587
                                                control.MiddlePoint,
1588
                                                control.EndPoint,
1589
                                            };
1590
1591
                                    }
1592
                                    //강인구 추가
1593
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1594
                                }
1595
1596
                            }
1597
                            break;
1598
1599
                        case ControlType.Circle:
1600
                            {
1601
                                var control = currentControl as CircleControl;
1602
1603
                                if (control != null)
1604
                                {
1605
                                    if (move.mousemode == MouseMode.Drawing)
1606
                                    {
1607
                                        //move.control_Move(ControlList, true, moveX, moveY);
1608
                                    }
1609
                                    else
1610
                                    {
1611
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1612
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1613
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1614
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1615
1616 17a22987 KangIngu
                                        if (ViewerDataModel.Instance.IsPressShift)
1617
                                        {
1618 4318fdeb KangIngu
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1619 17a22987 KangIngu
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1620
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1621
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1622
                                        }
1623
1624 787a4489 KangIngu
                                        control.PointSet = new List<Point>
1625
                                        {
1626
                                            control.StartPoint,
1627
                                            control.LeftBottomPoint,
1628
                                            control.EndPoint,
1629
                                            control.TopRightPoint,
1630
                                        };
1631
                                    }
1632
                                    //강인구 추가
1633
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1634
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1635
1636
                                }
1637
                            }
1638
                            break;
1639
1640
                        case ControlType.PolygonCloud:
1641
                            {
1642
                                var control = currentControl as CloudControl;
1643
1644
                                if (control != null)
1645
                                {
1646
                                    control.isTransOn = true;
1647
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1648
1649
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1650
1651
                                    control.SetCloud();
1652
                                    //강인구 추가
1653
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1654
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1655
                                }
1656
                            }
1657
                            break;
1658
1659
                        case ControlType.Triangle:
1660
                            {
1661
                                var control = currentControl as TriControl;
1662
1663
                                if (control != null)
1664
                                {
1665
                                    if (move.mousemode == MouseMode.Drawing)
1666
                                    {
1667
                                        //move.control_Move(ControlList, true, moveX, moveY);
1668
                                    }
1669
                                    else
1670
                                    {
1671
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1672
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1673
1674 4318fdeb KangIngu
1675
                                        if (ViewerDataModel.Instance.IsPressShift)
1676
                                        {
1677 e753423e humkyung
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1678
                                            if (2 == Points.Count())
1679
                                            {
1680
                                                control.MidPoint = Points[0];
1681
                                                control.EndPoint = Points[1];
1682
                                            }
1683 4318fdeb KangIngu
                                        }
1684
1685 787a4489 KangIngu
                                        control.PointSet = new List<Point>
1686
                                            {
1687
                                                control.StartPoint,
1688
                                                control.MidPoint,
1689
                                                control.EndPoint,
1690
                                            };
1691
                                    }
1692
                                    //강인구 추가
1693
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1694
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1695
                                }
1696
                            }
1697
                            break;
1698
1699
                        case ControlType.ImgControl:
1700
                            {
1701
                                var control = currentControl as ImgControl;
1702
1703
                                if (control != null)
1704
                                {
1705
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1706
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1707
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1708
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1709
1710
                                    control.PointSet = new List<Point>
1711
                                        {
1712
                                            control.StartPoint,
1713
                                            control.LeftBottomPoint,
1714
                                            control.EndPoint,
1715
                                            control.TopRightPoint,
1716
                                        };
1717
                                }
1718
                            }
1719
                            break;
1720
1721
                        case ControlType.Date:
1722
                            {
1723
                                var control = currentControl as DateControl;
1724
1725
                                if (control != null)
1726
                                {
1727
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1728
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1729
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1730
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1731
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1732
1733
                                    control.PointSet = new List<Point>
1734
                                        {
1735
                                            control.StartPoint,
1736
                                            control.LeftBottomPoint,
1737
                                            control.EndPoint,
1738
                                            control.TopRightPoint,
1739
                                        };
1740
                                }
1741
                            }
1742
                            break;
1743
1744
                        case ControlType.ArrowTextControl:
1745
                            {
1746
                                var control = currentControl as ArrowTextControl;
1747
1748
                                if (control != null)
1749
                                {
1750
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1751 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1752 9f473fb7 KangIngu
1753
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1754
1755 5ce56a3a KangIngu
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1756
                                    {
1757
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1758
                                        control.EndPoint = tempPoint;
1759
                                    }
1760
                                    else
1761
                                    {
1762
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1763
                                    }
1764 787a4489 KangIngu
1765
                                    control.PointSet = new List<Point>
1766
                                            {
1767
                                                control.StartPoint,
1768
                                                control.MidPoint,
1769
                                                control.EndPoint,
1770
                                            };
1771
                                }
1772
                            }
1773
                            break;
1774
1775
                        case ControlType.ArrowTransTextControl:
1776
                            {
1777
                                var control = currentControl as ArrowTextControl;
1778
1779
                                if (control != null)
1780
                                {
1781
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1782 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1783 01cbc243 KangIngu
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1784 9f473fb7 KangIngu
1785 5ce56a3a KangIngu
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1786
                                    {
1787
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1788
                                        control.EndPoint = tempPoint;
1789
                                    }
1790
                                    else
1791
                                    {
1792
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1793
                                    }
1794 01cbc243 KangIngu
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1795 787a4489 KangIngu
                                    control.isFixed = true;
1796
1797
                                    control.PointSet = new List<Point>
1798
                                            {
1799
                                                control.StartPoint,
1800
                                                control.MidPoint,
1801
                                                control.EndPoint,
1802
                                            };
1803
                                }
1804
                            }
1805
                            break;
1806
1807
                        case ControlType.ArrowTextBorderControl:
1808
                            {
1809
                                var control = currentControl as ArrowTextControl;
1810
1811
                                if (control != null)
1812
                                {
1813
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1814 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1815
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1816
                                    {
1817
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1818
                                        control.EndPoint = tempPoint;
1819
                                    }
1820
                                    else
1821
                                    {
1822
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1823
                                    }
1824 787a4489 KangIngu
                                    control.PointSet = new List<Point>
1825
                                            {
1826
                                                control.StartPoint,
1827
                                                control.MidPoint,
1828
                                                control.EndPoint,
1829
                                            };
1830
                                }
1831
1832
                            }
1833
                            break;
1834
                        case ControlType.ArrowTransTextBorderControl:
1835
                            {
1836
                                var control = currentControl as ArrowTextControl;
1837
1838
                                if (control != null)
1839
                                {
1840
                                    control.isFixed = true;
1841
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1842 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1843
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1844
                                    {
1845
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1846
                                        control.EndPoint = tempPoint;
1847
                                    }
1848
                                    else
1849
                                    {
1850
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1851
                                    }
1852 01cbc243 KangIngu
1853
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1854 787a4489 KangIngu
                                    control.PointSet = new List<Point>
1855
                                            {
1856
                                                control.StartPoint,
1857
                                                control.MidPoint,
1858
                                                control.EndPoint,
1859
                                            };
1860
                                }
1861
1862
                            }
1863
                            break;
1864
                        case ControlType.ArrowTextCloudControl:
1865
                            {
1866
                                var control = currentControl as ArrowTextControl;
1867
1868
                                if (control != null)
1869
                                {
1870
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1871 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1872
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1873
                                    {
1874
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1875
                                        control.EndPoint = tempPoint;
1876
                                    }
1877
                                    else
1878
                                    {
1879
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1880
                                    }
1881 787a4489 KangIngu
                                    control.PointSet = new List<Point>
1882
                                            {
1883
                                                control.StartPoint,
1884
                                                control.MidPoint,
1885
                                                control.EndPoint,
1886
                                            };
1887
                                }
1888
1889
                            }
1890
                            break;
1891
                        case ControlType.ArrowTransTextCloudControl:
1892
                            {
1893
                                var control = currentControl as ArrowTextControl;
1894
1895
                                if (control != null)
1896
                                {
1897
                                    control.isFixed = true;
1898
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1899 5ce56a3a KangIngu
                                    Point tempPoint = control.EndPoint;
1900
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1901
                                    {
1902
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1903
                                        control.EndPoint = tempPoint;
1904
                                    }
1905
                                    else
1906
                                    {
1907
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1908
                                    }
1909 01cbc243 KangIngu
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1910 787a4489 KangIngu
                                    control.PointSet = new List<Point>
1911
                                            {
1912
                                                control.StartPoint,
1913
                                                control.MidPoint,
1914
                                                control.EndPoint,
1915
                                            };
1916
                                }
1917
1918
                            }
1919
                            break;
1920
                        case ControlType.PolygonControl:
1921
                            {
1922
                                var control = currentControl as PolygonControl;
1923
1924
                                if (control != null)
1925
                                {
1926
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1927
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1928
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1929
                                    control.SetPolyPath();
1930
                                    //강인구 추가
1931
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1932
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1933
                                }
1934
                            }
1935
                            break;
1936
                        //강인구 추가
1937
                        case ControlType.Sign:
1938
                            {
1939
                                var control = currentControl as SignControl;
1940
1941
                                if (control != null)
1942
                                {
1943
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1944
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1945
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1946
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1947
1948
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
1949
                                    {
1950
                                        GetUserSign getUser = new GetUserSign();
1951
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
1952
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
1953
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1954
                                        stream.Write(imageBytes, 0, imageBytes.Length);
1955
                                        stream.Position = 0;
1956
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
1957
                                        BitmapImage returnImage = new BitmapImage();
1958
                                        returnImage.BeginInit();
1959
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
1960
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
1961
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
1962
                                        returnImage.StreamSource = ms;
1963
                                        returnImage.EndInit();
1964
                                        stream.Close();
1965
1966
                                        control.SignImage = returnImage;
1967
                                    }
1968
                                    control.PointSet = new List<Point>
1969
                                        {
1970
                                            control.StartPoint,
1971
                                            control.LeftBottomPoint,
1972
                                            control.EndPoint,
1973
                                            control.TopRightPoint,
1974
                                        };
1975
                                }
1976
                            }
1977
                            break;
1978
                        //강인구 추가
1979
                        case ControlType.Symbol:
1980
                            {
1981
                                var control = currentControl as SymControl;
1982
1983
                                if (control != null)
1984
                                {
1985
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1986
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1987
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1988
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1989
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1990
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1991
1992
                                    if (control.StartPoint != control.EndPoint)
1993
                                    {
1994
                                        if (control.PathData == null)
1995
                                        {
1996
                                            using (StringToPathConverter Convert = new StringToPathConverter())
1997
                                            {
1998
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
1999
                                            }
2000
                                        }
2001
                                    }
2002
2003
                                    control.PointSet = new List<Point>
2004
                                        {
2005
                                            control.StartPoint,
2006
                                            control.LeftBottomPoint,
2007
                                            control.EndPoint,
2008
                                            control.TopRightPoint,
2009
                                        };
2010
                                }
2011
                            }
2012
                            break;
2013
                        case ControlType.Stamp:
2014
                            {
2015
                                var control = currentControl as SymControlN;
2016
2017
                                if (control != null)
2018
                                {
2019
2020
                                    if (control.StartPoint == control.EndPoint)
2021
                                    {
2022
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2023
2024
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2025
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2026
2027 a0bab669 KangIngu
2028 787a4489 KangIngu
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2029
2030
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2031
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2032
                                        writer.Write(xamlData);
2033
                                        writer.Flush();
2034
                                        stream.Position = 0;
2035
2036
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2037
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2038
                                        UIElement ob = obj as UIElement;
2039
2040
                                        //control.ApplyTemplate();
2041
2042
                                        control.SetViewBox();
2043
                                        control.PathXathData = appovalData;
2044
                                        control.Base_ViewBox.Child = ob;
2045
                                    }
2046
2047
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2048
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2049
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2050
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2051
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2052
2053
2054
                                    control.PointSet = new List<Point>
2055
                                    {
2056
                                        control.StartPoint,
2057
                                        control.LeftBottomPoint,
2058
                                        control.EndPoint,
2059
                                        control.TopRightPoint,
2060
                                    };
2061
                                }
2062
                            }
2063
                            break;
2064
                        case ControlType.Mark:
2065
                            {
2066
                                var control = currentControl as RectangleControl;
2067
2068
                                if (control != null)
2069
                                {
2070
                                    if (move.mousemode == MouseMode.Drawing)
2071
                                    {
2072
                                        //move.control_Move(ControlList, true, moveX, moveY);
2073
                                    }
2074
                                    else
2075
                                    {
2076
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2077
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2078
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2079
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2080
2081
2082
                                        control.PointSet = new List<Point>
2083
                                    {
2084
                                        control.StartPoint,
2085
                                        control.LeftBottomPoint,
2086
                                        control.EndPoint,
2087
                                        control.TopRightPoint,
2088
                                    };
2089
                                    }
2090
2091
                                    //강인구 추가
2092
                                    control.Paint = PaintSet.Fill;
2093
                                }
2094
                            }
2095
                            break;
2096
                        case ControlType.PenControl:
2097
                            {
2098
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2099
                                //inkBoard.Strokes.Add(stroke);
2100
                            }
2101
                            break;
2102
                        default:
2103
                            break;
2104
                    }
2105
                }
2106
            }
2107 9f473fb7 KangIngu
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2108 787a4489 KangIngu
            {
2109
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2110
2111
                if (isDraggingSelectionRect)
2112
                {
2113
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2114
2115
                    e.Handled = true;
2116
                }
2117
                else if (isLeftMouseButtonDownOnWindow)
2118
                {
2119
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2120
                    double dragDistance = Math.Abs(dragDelta.Length);
2121
2122
                    if (dragDistance > DragThreshold)
2123
                    {
2124
                        isDraggingSelectionRect = true;
2125
2126
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2127
                    }
2128
2129
                    e.Handled = true;
2130
                }
2131
2132
2133
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2134
                {
2135
                    //SelectionPath = new Path();
2136
                    //PathFigure pathFigure = new PathFigure();
2137
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2138
                    //SelectionPath.Opacity = 0.5;
2139
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2140
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2141
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2142
                }
2143
                else
2144
                {
2145
                    //List<Stroke> removingStroke = new List<Stroke>();
2146
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2147
                    //StrokeCollection stC = new StrokeCollection();
2148
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2149
                    //{
2150
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2151
                    //    p1.Intersect(p2);
2152
                    //    if (p1.IsEmpty)
2153
                    //    {
2154
2155
2156
                    //        p1 = SelectionPath.Data.Bounds;
2157
                    //        bool intersectCheck = false;
2158
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2159
                    //        {
2160
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2161
                    //            p1.Intersect(p3);
2162
                    //            if (!p1.IsEmpty)
2163
                    //            {
2164
                    //                intersectCheck = true;
2165
                    //            }
2166
                    //        }
2167
                    //        if (intersectCheck)
2168
                    //        {
2169
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2170
                    //        }
2171
2172
                    //    }
2173
                    //    else
2174
                    //    {
2175
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2176
                    //    }
2177
                    //}
2178
2179
                    e.Handled = true;
2180
                }
2181
            }
2182
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2183
            {
2184
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2185
                if (control != null)
2186
                {
2187
                    this.cursor = Cursors.Hand;
2188
                    SetCursor();
2189
                }
2190
                else
2191
                {
2192
                    this.cursor = Cursors.Arrow;
2193
                    SetCursor();
2194
                }
2195
            }
2196
            else
2197
            {
2198
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2199
2200
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2201
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2202
2203
                //if (hitList.Count > 0)
2204
                //{
2205
2206
                //}
2207
2208
                #region 조건 설정 : firstCondition
2209
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2210
                //pnts = generalTransform.Transform(pnts);
2211
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2212
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2213
                //                               this.DeepLayer._BaseLayer).ToObservable()
2214
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2215
                //                      select kkk).FirstOrDefault();
2216
2217
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2218
                //if (canvas !=null)
2219
                //{
2220
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2221
                //    {
2222
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2223
                //        if (uiElement!=null)
2224
                //        {
2225
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2226
                //        }
2227
                //    }
2228
                //}
2229
2230
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2231
                //hitResultsList.Clear();
2232
2233
                #endregion
2234
            }
2235
        }
2236
2237
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2238
2239
        private EllipseGeometry hitArea = new EllipseGeometry();
2240
2241
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2242
        {
2243
            IsDrawing = false;
2244
2245
            if (mouseHandlingMode != MouseHandlingMode.None)
2246
            {
2247
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2248
                {
2249
                    this.cursor = Cursors.Arrow;
2250
2251
                    SetCursor();
2252
2253
                    switch (controlType)
2254
                    {
2255
                        case ControlType.None:
2256
                            break;
2257
                        case ControlType.Rectangle:
2258
                            {
2259
2260
                            }
2261
                            break;
2262
                        case ControlType.PenControl:
2263
                            {
2264
2265
                            }
2266
                            break;
2267
                        default:
2268
                            break;
2269
                    }
2270
                }
2271 9f473fb7 KangIngu
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2272 787a4489 KangIngu
                {
2273
                    if (isLeftMouseButtonDownOnWindow)
2274
                    {
2275
                        bool wasDragSelectionApplied = false;
2276
2277
                        if (isDraggingSelectionRect)
2278
                        {
2279
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2280
                            {
2281
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2282
                                mouseHandlingMode = MouseHandlingMode.None;
2283
                                Set_Capture();
2284
2285
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2286
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2287
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2288
                            }
2289 9f473fb7 KangIngu
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2290 787a4489 KangIngu
                            {
2291
                                ApplyDragSelectionRect();
2292
                            }
2293 9f473fb7 KangIngu
                            else
2294
                            {
2295
                                double x = Canvas.GetLeft(dragZoomBorder);
2296
                                double y = Canvas.GetTop(dragZoomBorder);
2297
                                double width = dragZoomBorder.Width;
2298
                                double height = dragZoomBorder.Height;
2299
                                Rect dragRect = new Rect(x, y, width, height);
2300
2301
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2302
2303
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2304
                            }
2305 787a4489 KangIngu
2306 9f473fb7 KangIngu
                            isDraggingSelectionRect = false;
2307 787a4489 KangIngu
                            e.Handled = true;
2308
                            wasDragSelectionApplied = true;
2309
                        }
2310
2311
                        if (isLeftMouseButtonDownOnWindow)
2312
                        {
2313
                            isLeftMouseButtonDownOnWindow = false;
2314
                            this.ReleaseMouseCapture();
2315
                            e.Handled = true;
2316
                        }
2317
2318
                        if (!wasDragSelectionApplied)
2319
                        {
2320
                            init();
2321
                        }
2322
                    }
2323
                }
2324
                else if (mouseButtonDown == MouseButton.Right)
2325
                {
2326
                    this.cursor = Cursors.Arrow;
2327
                    SetCursor();
2328
                }
2329
2330
                zoomAndPanControl.ReleaseMouseCapture();
2331
2332
2333
                e.Handled = true;
2334
            }
2335
            else
2336
            {
2337
                this.cursor = Cursors.Arrow;
2338
                SetCursor();
2339
            }
2340
            mouseButtonDown = MouseButton.Left;
2341
2342
            //controlType = ControlType.SingleLine;
2343
        }
2344
2345
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2346
        {
2347
            mouseButtonDown = MouseButton.Left;
2348
            this.Cursor = Cursors.Arrow;
2349
        }
2350
2351
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2352
        {
2353
2354
        }
2355
2356
        private void ApplyDragSelectionRect()
2357
        {
2358
            multi_Undo_Data = new Multi_Undo_data();
2359
2360
            UndoData = new Undo_data()
2361
            {
2362
                IsUndo = false,
2363
                Event = Event_Type.Select,
2364
                EventTime = DateTime.Now,
2365
                Markup_List = new List<Multi_Undo_data>()
2366
            };
2367
2368
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2369
2370
            double x = Canvas.GetLeft(dragSelectionBorder);
2371
            double y = Canvas.GetTop(dragSelectionBorder);
2372
            double width = dragSelectionBorder.Width;
2373
            double height = dragSelectionBorder.Height;
2374
            Rect dragRect = new Rect(x, y, width, height);
2375
            Boolean Flag = false;
2376
            dragRect.Inflate(width / 10, height / 10);
2377
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2378
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2379
2380
            dragRect = new Rect(x, y, width, height);
2381
            dragRect.Inflate(width / 10, height / 10);
2382
2383
            foreach (var item in Items)
2384
            {
2385
                Flag = move.control_Select(item, dragRect);
2386
2387
                if (Flag)
2388
                {
2389
                    adornerSet.Add(item);
2390
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2391
2392
                    Control_Style(item);
2393
                    UndoData.Markup_List.Add(multi_Undo_Data);
2394
                    multi_Undo_Data = new Multi_Undo_data();
2395
                }
2396
            }
2397
            if (adornerSet.Count > 0)
2398
            {
2399
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2400
                {
2401
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2402
                });
2403
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2404
2405
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2406
                SelectLayer.Children.Add(final);
2407
            }
2408
        }
2409
2410
        private void InitDragSelectionRect(Point pt1, Point pt2)
2411
        {
2412 9f473fb7 KangIngu
            //캡쳐 중
2413
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2414
            {
2415
                dragCaptureBorder.Visibility = Visibility.Visible;
2416
            }
2417 787a4489 KangIngu
            //선택 중
2418 9f473fb7 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2419 787a4489 KangIngu
            {
2420 9f473fb7 KangIngu
                
2421 787a4489 KangIngu
                dragSelectionBorder.Visibility = Visibility.Visible;
2422
            }
2423
            else
2424
            {
2425 9f473fb7 KangIngu
                dragZoomBorder.Visibility = Visibility.Visible;
2426 787a4489 KangIngu
            }
2427
            UpdateDragSelectionRect(pt1, pt2);
2428
        }
2429
2430
        /// <summary>
2431
        /// Update the position and size of the rectangle used for drag selection.
2432
        /// </summary>
2433
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2434
        {
2435
            double x, y, width, height;
2436
2437
            //
2438
            // Determine x,y,width and height of the rect inverting the points if necessary.
2439
            // 
2440
2441
            if (pt2.X < pt1.X)
2442
            {
2443
                x = pt2.X;
2444
                width = pt1.X - pt2.X;
2445
            }
2446
            else
2447
            {
2448
                x = pt1.X;
2449
                width = pt2.X - pt1.X;
2450
            }
2451
2452
            if (pt2.Y < pt1.Y)
2453
            {
2454
                y = pt2.Y;
2455
                height = pt1.Y - pt2.Y;
2456
            }
2457
            else
2458
            {
2459
                y = pt1.Y;
2460
                height = pt2.Y - pt1.Y;
2461
            }
2462
2463
            //
2464
            // Update the coordinates of the rectangle used for drag selection.
2465
            //
2466 9f473fb7 KangIngu
            //캡쳐 중
2467
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2468
            {
2469
                Canvas.SetLeft(dragCaptureBorder, x);
2470
                Canvas.SetTop(dragCaptureBorder, y);
2471
                dragCaptureBorder.Width = width;
2472
                dragCaptureBorder.Height = height;
2473
            }
2474 787a4489 KangIngu
            //선택 중
2475 9f473fb7 KangIngu
            else if(mouseHandlingMode == MouseHandlingMode.Selecting)
2476 787a4489 KangIngu
            {
2477
                Canvas.SetLeft(dragSelectionBorder, x);
2478
                Canvas.SetTop(dragSelectionBorder, y);
2479
                dragSelectionBorder.Width = width;
2480
                dragSelectionBorder.Height = height;
2481
            }
2482
            else
2483
            {
2484 9f473fb7 KangIngu
                Canvas.SetLeft(dragZoomBorder, x);
2485
                Canvas.SetTop(dragZoomBorder, y);
2486
                dragZoomBorder.Width = width;
2487
                dragZoomBorder.Height = height;
2488 787a4489 KangIngu
            }
2489 9f473fb7 KangIngu
2490
2491 787a4489 KangIngu
        }
2492
2493
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2494
        {
2495
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2496
2497
            bool result = false;
2498
            if (dragRect.Contains(controlRect))
2499
            {
2500
                result = true;
2501
                //잡은 객체들을 담은 리스트
2502
                try
2503
                {
2504
                    selected_item.Add(OverViewPathData, type.ToString());
2505
                }
2506
                catch (Exception)
2507
                {
2508
2509
                }
2510
            }
2511
            return result;
2512
        }
2513
2514
        private void drawingPannelRotate(double angle)
2515
        {
2516
            rotate.Angle = angle;
2517
            var rotationNum = Math.Abs((rotate.Angle / 90));
2518
2519
            if (angle == 90 || angle == 270)
2520
            {
2521
                double emptySize = zoomAndPanCanvas.Width;
2522
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2523
                zoomAndPanCanvas.Height = emptySize;
2524
            }
2525
            if (angle == 0)
2526
            {
2527
                translate.X = 0;
2528
                translate.Y = 0;
2529
            }
2530
            else if (angle == 90)
2531
            {
2532
                translate.X = zoomAndPanCanvas.Width;
2533
                translate.Y = 0;
2534
            }
2535
            else if (angle == 180)
2536
            {
2537
                translate.X = zoomAndPanCanvas.Width;
2538
                translate.Y = zoomAndPanCanvas.Height;
2539
            }
2540
            else
2541
            {
2542
                translate.X = 0;
2543
                translate.Y = zoomAndPanCanvas.Height;
2544
            }
2545
2546
            zoomAndPanControl.RotationAngle = rotate.Angle;
2547
2548
2549
            if (!testPanel2.IsHidden)
2550
            {
2551
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2552
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2553
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2554
            }
2555
2556
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2557
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2558
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2559
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2560
            ViewerDataModel.Instance.Angle = rotate.Angle;
2561
2562
2563
        }
2564
2565
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2566
        {
2567
            InkControl_Convert();
2568
2569
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2570
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2571
2572
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2573
            {
2574
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2575
            }
2576
2577
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2578
            {
2579
                if (arrow_text as ArrowTextControl != null)
2580
                {
2581
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2582
                }
2583
            }
2584
2585
            if(currentControl == null)
2586
            {
2587
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2588
                if (text_item_ != null)
2589
                {
2590
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2591
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2592
                    (text_item_ as TextControl).IsEditing = false;
2593
                    (text_item_ as TextControl).EnableEditing = false;
2594
                }
2595
2596
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2597
                if (Arrowtext_item_ != null)
2598
                {
2599
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2600
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2601
                }
2602
            }
2603
2604
            double Ang = 0;
2605
            if (rotate.Angle != 0)
2606
            {
2607
                Ang = 360 - rotate.Angle;
2608
            }
2609
            move = new Move();
2610
2611
            if (e.OriginalSource is System.Windows.Controls.Image)
2612
            {
2613
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2614
            }
2615
2616
            mouseButtonDown = e.ChangedButton;
2617
            if (mouseButtonDown == MouseButton.Left)
2618
            {
2619
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2620
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2621
2622
                this.cursor = Cursors.Arrow;
2623
                SetCursor();
2624
2625
                if (!ViewerDataModel.Instance.IsPressCtrl)
2626
                {
2627
                    ReleaseAdorner();
2628
                }
2629
            }
2630
            if (mouseButtonDown == MouseButton.Middle)
2631
            {
2632
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2633
                cursor = Cursors.SizeAll;
2634
                SetCursor();
2635
            }
2636
            if (mouseButtonDown == MouseButton.Right)
2637
            {
2638
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2639
                cursor = Cursors.SizeAll;
2640
                SetCursor();
2641
            }
2642
            else if (mouseButtonDown == MouseButton.XButton1)
2643
            {
2644
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2645
                {
2646
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2647
                }
2648
2649
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2650
2651
            }
2652
            else if (mouseButtonDown == MouseButton.XButton2)
2653
            {
2654
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2655
                {
2656
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2657
                }
2658
            }
2659
2660 9f473fb7 KangIngu
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2661
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2662 787a4489 KangIngu
            {
2663
2664
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2665
                {
2666
                    if (SelectLayer.Children.Count == 0)
2667
                    {
2668
                        isLeftMouseButtonDownOnWindow = true;
2669
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2670
                    }
2671
2672
                    if (controlType == ControlType.None)
2673
                    {
2674
                        isLeftMouseButtonDownOnWindow = true;
2675
                    }
2676
                }
2677
2678 9f473fb7 KangIngu
                //캡쳐 모드 설정
2679
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2680
                {
2681
                    dragCaptureBorder.Visibility = Visibility.Visible;
2682
                    isLeftMouseButtonDownOnWindow = true;
2683
                }
2684
2685
                //줌 모드 설정
2686
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2687
                {
2688
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2689
                    isLeftMouseButtonDownOnWindow = true;
2690
                }
2691
2692 787a4489 KangIngu
2693
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2694
                if (control != null)
2695
                {
2696
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2697
                    AdornerFinal final;
2698
                    List<Point> p_set = new List<Point>();
2699
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2700
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2701
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2702
                    multi_Undo_Data = new Multi_Undo_data();
2703
2704
                    //강인구 Undo/Redo 보류
2705
                    UndoData = new Undo_data()
2706
                    {
2707
                        IsUndo = false,
2708
                        Event = Event_Type.Select,
2709
                        EventTime = DateTime.Now,
2710
                        Markup_List = new List<Multi_Undo_data>()
2711
                    };
2712
2713
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2714
                    {
2715
                        ReleaseAdorner();
2716
                        final = new AdornerFinal(control);
2717
                        //단일 컨트롤 언두 저장
2718
2719
                        Control_Style(control);
2720
                        UndoData.Markup_List.Add(multi_Undo_Data);
2721
2722
                        if ((control as IPath) != null)
2723
                        {
2724
                            if ((control as IPath).LineSize != 0)
2725
                            {
2726
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2727
                            }
2728
                        }
2729
                        if ((control as IShapeControl) != null)
2730
                        {
2731
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2732
                            {
2733
                                ViewerDataModel.Instance.checkHatchShape = true;
2734
                            }
2735
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2736
                            {
2737
                                ViewerDataModel.Instance.checkFillShape = true;
2738
                            }
2739
                            else
2740
                            {
2741
                                ViewerDataModel.Instance.checkHatchShape = false;
2742
                                ViewerDataModel.Instance.checkFillShape = false;
2743
                            }
2744
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2745
                        }
2746 9f473fb7 KangIngu
2747 787a4489 KangIngu
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2748 d4b0c723 KangIngu
2749
                        if ((control as TextControl) != null)
2750
                        {
2751
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2752
                            {
2753
                                ViewerDataModel.Instance.checkTextStyle = true;
2754
                            }
2755
                            else
2756
                            {
2757
                                ViewerDataModel.Instance.checkTextStyle = false;
2758
                            }
2759
2760
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2761
                            {
2762
                                ViewerDataModel.Instance.checkTextStyle = true;
2763
                            }
2764
                            else
2765
                            {
2766
                                ViewerDataModel.Instance.checkTextStyle = false;
2767
                            }
2768
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2769
                            {
2770
                                ViewerDataModel.Instance.checkTextWeight = true;
2771
                            }
2772
                            else
2773
                            {
2774
                                ViewerDataModel.Instance.checkTextWeight = false;
2775
                            }
2776
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2777
                            {
2778
                                ViewerDataModel.Instance.checkUnderLine = true;
2779
                            }
2780
                            else
2781
                            {
2782
                                ViewerDataModel.Instance.checkUnderLine = false;
2783
                            }
2784
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2785
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2786
                            
2787
                        }
2788
                        else if ((control as ArrowTextControl) != null)
2789
                        {
2790 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2791 d4b0c723 KangIngu
                            {
2792 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = true;
2793
                            }
2794
                            else
2795
                            {
2796
                                ViewerDataModel.Instance.checkTextStyle = false;
2797
                            }
2798
2799
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2800
                            {
2801
                                ViewerDataModel.Instance.checkTextStyle = true;
2802 d4b0c723 KangIngu
                            }
2803 e17af42b KangIngu
                            else
2804 d4b0c723 KangIngu
                            {
2805 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = false;
2806 d4b0c723 KangIngu
                            }
2807 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2808 d4b0c723 KangIngu
                            {
2809 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextWeight = true;
2810
                            }
2811
                            else
2812
                            {
2813
                                ViewerDataModel.Instance.checkTextWeight = false;
2814
                            }
2815
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2816
                            {
2817
                                ViewerDataModel.Instance.checkUnderLine = true;
2818
                            }
2819
                            else
2820
                            {
2821
                                ViewerDataModel.Instance.checkUnderLine = false;
2822 d4b0c723 KangIngu
                            }
2823
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2824
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2825
                        }
2826 9f473fb7 KangIngu
                        else if ((control as RectCloudControl) != null)
2827
                        {
2828
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2829
                        }
2830
                        else if ((control as CloudControl) != null)
2831
                        {
2832
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2833
                        }
2834 d4b0c723 KangIngu
2835 787a4489 KangIngu
                    }
2836
                    else
2837
                    {
2838
                        comment = AddAdorner();
2839
                        comment.Add(control);
2840
2841
                        Control_Style(control);
2842
                        UndoData.Markup_List.Add(multi_Undo_Data);
2843
2844
                        final = new AdornerFinal(comment);
2845
                        //다중 컨트롤 언두 저장
2846
                    }
2847
2848
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2849
                    {
2850
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2851
                    });
2852
2853
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2854
2855
                    SelectLayer.Children.Add(final);
2856
2857
                    //Control_Init(control);
2858
2859
2860 5ce56a3a KangIngu
                    
2861
2862 787a4489 KangIngu
2863
                    //강인구 폰트 변경 보류
2864
2865
                    //if ((currentControl as TextControl) != null)
2866
                    //{
2867
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2868
                    //    {
2869
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2870
                    //    }
2871
                    //    else
2872
                    //    {
2873
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2874
                    //    }
2875
2876
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2877
                    //    {
2878
2879
                    //    }
2880 d4b0c723 KangIngu
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2881 787a4489 KangIngu
                    //    {
2882
2883
                    //    }
2884
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2885
                    //    {
2886
2887
                    //    }
2888
                    //}
2889
                    //else if ((currentControl as ArrowTextControl) != null)
2890
                    //{
2891
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2892
                    //    {
2893
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2894
                    //    }
2895
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2896
                    //    {
2897 d4b0c723 KangIngu
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
2898 787a4489 KangIngu
                    //    }
2899
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2900
                    //    {
2901
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2902
                    //    }
2903
                    //}
2904
2905 8bb375a7 KangIngu
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
2906 787a4489 KangIngu
                }
2907
            }
2908
2909
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2910
            {
2911
                init();
2912
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2913
                if (cursor != Cursors.SizeAll)
2914
                {
2915
                    cursor = Cursors.Cross;
2916
                    SetCursor();
2917
                }
2918
                bool init_user = false;
2919
                foreach (var user in gridViewMarkup.Items)
2920
                {
2921
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2922
                    {
2923
                        init_user = true;
2924
                    }
2925
                }
2926
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2927
                {
2928
                    RadWindow.Alert(new DialogParameters
2929
                    {
2930
                        Theme = new VisualStudio2013Theme(),
2931
                        Header = "안내",
2932
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2933
                    });
2934
                    return;
2935
                }
2936
                else
2937
                {
2938
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2939
                    if (item != null)
2940
                    {
2941
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2942
                    }
2943
                }
2944
2945
                multi_Undo_Data = new Multi_Undo_data();
2946
                //강인구 Undo/Redo 보류
2947
                UndoData = new Undo_data()
2948
                {
2949
                    IsUndo = false,
2950
                    Event = Event_Type.Create,
2951
                    EventTime = DateTime.Now,
2952
                    Markup_List = new List<Multi_Undo_data>()
2953
                };
2954
2955
                switch (controlType)
2956
                {
2957
                    case ControlType.Rectangle:
2958
                        {
2959
                            if (mouseButtonDown == MouseButton.Left)
2960
                            {
2961
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2962
                                {
2963
                                    if (currentControl is RectangleControl)
2964
                                    {
2965
                                        CreateControl();
2966
2967
                                        (currentControl as RectangleControl).ApplyOverViewData();
2968
                                        currentControl = null;
2969
                                        this.cursor = Cursors.Arrow;
2970
                                    }
2971
                                    else
2972
                                    {
2973
                                        currentControl = new RectangleControl
2974
                                        {
2975
                                            Background = new SolidColorBrush(Colors.Black),
2976
                                            ControlType = ControlType.Rectangle
2977
                                        };
2978
2979
                                        currentControl.CommentID = Save.shortGuid();
2980
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2981
                                        currentControl.IsNew = true;
2982
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2983
2984
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2985
                                    }
2986
                                }
2987
                            }
2988
                        }
2989
                        break;
2990
                    case ControlType.RectCloud:
2991
                        {
2992
                            if (mouseButtonDown == MouseButton.Left)
2993
                            {
2994
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2995
                                {
2996
                                    if (currentControl is RectCloudControl)
2997
                                    {
2998
                                        CreateControl();
2999
3000
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3001
                                        currentControl = null;
3002
                                        this.cursor = Cursors.Arrow;
3003
                                    }
3004
                                    else
3005
                                    {
3006
                                        currentControl = new RectCloudControl
3007
                                        {
3008
                                            Background = new SolidColorBrush(Colors.Black)
3009
                                        };
3010
3011
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3012
                                        currentControl.CommentID = Save.shortGuid();
3013
                                        currentControl.IsNew = true;
3014
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3015
                                    }
3016
                                }
3017
                            }
3018
                        }
3019
                        break;
3020
                    case ControlType.Circle:
3021
                        {
3022
                            if (mouseButtonDown == MouseButton.Left)
3023
                            {
3024
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3025
                                {
3026
                                    if (currentControl is CircleControl)
3027
                                    {
3028
                                        CreateControl();
3029
3030
                                        (currentControl as CircleControl).ApplyOverViewData();
3031
                                        currentControl = null;
3032
                                    }
3033
                                    else
3034
                                    {
3035
                                        currentControl = new CircleControl
3036
                                        {
3037
                                            Background = new SolidColorBrush(Colors.Black)
3038
                                        };
3039
3040
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3041
                                        currentControl.CommentID = Save.shortGuid();
3042
                                        currentControl.IsNew = true;
3043
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3044
                                    }
3045
                                }
3046
                            }
3047
                        }
3048
                        break;
3049
                    case ControlType.Triangle:
3050
                        {
3051
                            if (mouseButtonDown == MouseButton.Left)
3052
                            {
3053
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3054
                                {
3055
                                    if (currentControl is TriControl)
3056
                                    {
3057
                                        var content = currentControl as TriControl;
3058
                                        if (content.MidPoint == new Point(0, 0))
3059
                                        {
3060
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3061
                                        }
3062
                                        else
3063
                                        {
3064
                                            CreateControl();
3065
3066
                                            (currentControl as TriControl).ApplyOverViewData();
3067
                                            currentControl = null;
3068
                                        }
3069
                                    }
3070
                                    else
3071
                                    {
3072
                                        currentControl = new TriControl
3073
                                        {
3074
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3075
                                            Background = new SolidColorBrush(Colors.Black),
3076
                                        };
3077
3078
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3079
                                        currentControl.CommentID = Save.shortGuid();
3080
                                        currentControl.IsNew = true;
3081
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3082
                                    }
3083
                                }
3084
                            }
3085
                        }
3086
                        break;
3087
                    case ControlType.SingleLine:
3088
                        {
3089
                            if (mouseButtonDown == MouseButton.Left)
3090
                            {
3091
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3092
                                {
3093
                                    if (currentControl is LineControl)
3094
                                    {
3095
                                        CreateControl();
3096
3097
                                        (currentControl as LineControl).ApplyOverViewData();
3098
                                        currentControl = null;
3099 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3100 787a4489 KangIngu
                                    }
3101
                                    else
3102
                                    {
3103
                                        currentControl = new LineControl
3104
                                        {
3105
                                            Background = new SolidColorBrush(Colors.Black)
3106
                                        };
3107
3108
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3109
                                        currentControl.CommentID = Save.shortGuid();
3110
                                        currentControl.IsNew = true;
3111
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3112 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3113 787a4489 KangIngu
                                    }
3114
                                }
3115
                            }
3116
                        }
3117
                        break;
3118
                    case ControlType.CancelLine:
3119
                        {
3120
                            if (mouseButtonDown == MouseButton.Left)
3121
                            {
3122
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3123
                                {
3124
                                    if (currentControl is LineControl)
3125
                                    {
3126
                                        CreateControl();
3127
3128
                                        (currentControl as LineControl).ApplyOverViewData();
3129
                                        currentControl = null;
3130 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3131 787a4489 KangIngu
                                    }
3132
                                    else
3133
                                    {
3134
                                        currentControl = new LineControl
3135
                                        {
3136
                                            Background = new SolidColorBrush(Colors.Black)
3137
                                        };
3138
3139
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3140
                                        currentControl.CommentID = Save.shortGuid();
3141
                                        currentControl.IsNew = true;
3142
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3143 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3144 787a4489 KangIngu
                                    }
3145
                                }
3146
                            }
3147
                        }
3148
                        break;
3149
                    case ControlType.ArrowLine:
3150
                        {
3151
                            if (mouseButtonDown == MouseButton.Left)
3152
                            {
3153
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3154
                                {
3155
                                    if (currentControl is LineControl)
3156
                                    {
3157
                                        CreateControl();
3158
3159
                                        (currentControl as LineControl).ApplyOverViewData();
3160
                                        currentControl = null;
3161 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3162 787a4489 KangIngu
                                    }
3163
                                    else
3164
                                    {
3165
                                        currentControl = new LineControl
3166
                                        {
3167
                                            Background = new SolidColorBrush(Colors.Black)
3168
                                        };
3169
3170
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3171
                                        currentControl.CommentID = Save.shortGuid();
3172
                                        currentControl.IsNew = true;
3173
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3174 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3175 787a4489 KangIngu
                                    }
3176
                                }
3177
                            }
3178
                        }
3179
                        break;
3180
                    case ControlType.TwinLine:
3181
                        {
3182
                            if (mouseButtonDown == MouseButton.Left)
3183
                            {
3184
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3185
                                {
3186
                                    if (currentControl is LineControl)
3187
                                    {
3188
                                        CreateControl();
3189
3190
                                        (currentControl as LineControl).ApplyOverViewData();
3191
                                        currentControl = null;
3192 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3193 787a4489 KangIngu
                                    }
3194
                                    else
3195
                                    {
3196
                                        currentControl = new LineControl
3197
                                        {
3198
                                            Background = new SolidColorBrush(Colors.Black)
3199
                                        };
3200
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3201
                                        currentControl.CommentID = Save.shortGuid();
3202
                                        currentControl.IsNew = true;
3203
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3204 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3205 787a4489 KangIngu
                                    }
3206
                                }
3207
                            }
3208
                        }
3209
                        break;
3210
                    case ControlType.DimLine:
3211
                        {
3212
                            if (mouseButtonDown == MouseButton.Left)
3213
                            {
3214
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3215
                                {
3216
                                    if (currentControl is LineControl)
3217
                                    {
3218
                                        CreateControl();
3219
3220
                                        (currentControl as LineControl).ApplyOverViewData();
3221
                                        currentControl = null;
3222 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3223 787a4489 KangIngu
                                    }
3224
                                    else
3225
                                    {
3226
                                        currentControl = new LineControl
3227
                                        {
3228
                                            Background = new SolidColorBrush(Colors.Black)
3229
                                        };
3230
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3231
                                        currentControl.CommentID = Save.shortGuid();
3232
                                        currentControl.IsNew = true;
3233
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3234 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3235 787a4489 KangIngu
                                    }
3236
                                }
3237
                            }
3238
                        }
3239
                        break;
3240
                    case ControlType.ChainLine:
3241
                        {
3242
                            if (currentControl is PolygonControl)
3243
                            {
3244
                                var control = currentControl as PolygonControl;
3245
3246
                                if (mouseButtonDown == MouseButton.Right)
3247
                                {
3248
                                    CreateControl();
3249
3250
                                    (currentControl as PolygonControl).ApplyOverViewData();
3251
                                    currentControl = null;
3252 2eac4f76 KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3253 787a4489 KangIngu
                                    return;
3254
                                }
3255
3256
                                if (!control.IsCompleted)
3257
                                {
3258
                                    control.PointSet.Add(control.EndPoint);
3259 2eac4f76 KangIngu
                                    this.MainAngle.Visibility = Visibility.Visible;
3260 787a4489 KangIngu
                                }
3261
                            }
3262
                            else
3263
                            {
3264
                                if (mouseButtonDown == MouseButton.Left)
3265
                                {
3266 2eac4f76 KangIngu
                                    MainAngle.Visibility = Visibility.Visible;
3267 787a4489 KangIngu
                                    currentControl = new PolygonControl
3268
                                    {
3269
                                        PointSet = new List<Point>(),
3270
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3271
                                        ControlType = ControlType.ChainLine,
3272
                                        DashSize = ViewerDataModel.Instance.DashSize,
3273
                                        LineSize = ViewerDataModel.Instance.LineSize,
3274
                                        //PointC = new StylusPointSet()
3275
                                    };
3276
3277
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3278
                                    {
3279
                                        var polygonControl = (currentControl as PolygonControl);
3280
                                        currentControl.CommentID = Save.shortGuid();
3281
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3282
                                        currentControl.IsNew = true;
3283
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3284
                                        //currentControl.OnApplyTemplate();
3285
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3286
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3287
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3288
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3289
                                    }
3290
                                }
3291
                            }
3292
                        }
3293
                        break;
3294
                    case ControlType.ArcLine:
3295
                        {
3296
                            if (mouseButtonDown == MouseButton.Left)
3297
                            {
3298
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3299
                                {
3300
                                    if (currentControl is ArcControl)
3301
                                    {
3302
                                        CreateControl();
3303
3304
                                        (currentControl as ArcControl).ApplyOverViewData();
3305
                                        currentControl = null;
3306 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3307 787a4489 KangIngu
                                    }
3308
                                    else
3309
                                    {
3310
                                        currentControl = new ArcControl
3311
                                        {
3312
                                            Background = new SolidColorBrush(Colors.Black)
3313
                                        };
3314
                                        currentControl.CommentID = Save.shortGuid();
3315
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3316
                                        currentControl.IsNew = true;
3317
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3318 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3319 787a4489 KangIngu
                                    }
3320
                                }
3321
                            }
3322
                            else if (mouseButtonDown == MouseButton.Right)
3323
                            {
3324
                                if (currentControl != null)
3325
                                {
3326
                                    (currentControl as ArcControl).setClock();
3327
                                }
3328
3329
                            }
3330
3331
                        }
3332
                        break;
3333
                    case ControlType.ArcArrow:
3334
                        {
3335
                            if (mouseButtonDown == MouseButton.Left)
3336
                            {
3337
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3338
                                {
3339
                                    if (currentControl is ArcControl)
3340
                                    {
3341
                                        CreateControl();
3342
3343
                                        (currentControl as ArcControl).ApplyOverViewData();
3344
                                        currentControl = null;
3345 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3346 787a4489 KangIngu
                                    }
3347
                                    else
3348
                                    {
3349
                                        currentControl = new ArcControl
3350
                                        {
3351
                                            Background = new SolidColorBrush(Colors.Red),
3352
                                        };
3353
                                        currentControl.CommentID = Save.shortGuid();
3354
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3355
                                        currentControl.IsNew = true;
3356
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3357
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3358 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3359 787a4489 KangIngu
                                    }
3360
                                }
3361
                            }
3362
                            else if (mouseButtonDown == MouseButton.Right)
3363
                            {
3364
                                (currentControl as ArcControl).setClock();
3365
                            }
3366
                        }
3367
                        break;
3368
                    case ControlType.ArrowMultiLine:
3369
                        {
3370
                            if (mouseButtonDown == MouseButton.Left)
3371
                            {
3372
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3373
                                {
3374
3375
                                    if (currentControl is ArrowControl_Multi)
3376
                                    {
3377
                                        var content = currentControl as ArrowControl_Multi;
3378
                                        if (content.MiddlePoint == new Point(0, 0))
3379
                                        {
3380 2eac4f76 KangIngu
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3381
                                            {
3382
                                                content.MiddlePoint = content.EndPoint;
3383
                                            }
3384
                                            else
3385
                                            {
3386
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3387
                                            }
3388 787a4489 KangIngu
                                        }
3389
                                        else
3390
                                        {
3391
                                            CreateControl();
3392
3393
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3394
                                            currentControl = null;
3395 5ce56a3a KangIngu
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3396 787a4489 KangIngu
                                        }
3397
                                    }
3398
                                    else
3399
                                    {
3400
                                        currentControl = new ArrowControl_Multi
3401
                                        {
3402
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3403
                                            Background = new SolidColorBrush(Colors.Black)
3404
                                        };
3405
                                        currentControl.CommentID = Save.shortGuid();
3406
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3407
                                        currentControl.IsNew = true;
3408
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3409 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3410 787a4489 KangIngu
                                    }
3411
                                }
3412
                            }
3413
                        }
3414
                        break;
3415
                    case ControlType.PolygonCloud:
3416
                        {
3417
                            if (currentControl is CloudControl)
3418
                            {
3419
                                var control = currentControl as CloudControl;
3420
                                if (mouseButtonDown == MouseButton.Right)
3421
                                {
3422
                                    control.IsCompleted = true;
3423
                                }
3424
3425
                                if (!control.IsCompleted)
3426
                                {
3427
                                    control.PointSet.Add(control.EndPoint);
3428
                                }
3429
                                else
3430
                                {
3431
                                    CreateControl();
3432
3433
                                    control.isTransOn = true;
3434
                                    var firstPoint = control.PointSet.First();
3435
3436
                                    control.PointSet.Add(firstPoint);
3437
                                    control.DrawingCloud();
3438
                                    control.ApplyOverViewData();
3439
3440
                                    currentControl = null;
3441
                                }
3442
                            }
3443
                            else
3444
                            {
3445
                                if (mouseButtonDown == MouseButton.Left)
3446
                                {
3447
                                    currentControl = new CloudControl
3448
                                    {
3449
                                        PointSet = new List<Point>(),
3450
                                        PointC = new StylusPointSet()
3451
                                    };
3452
3453
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3454
                                    {
3455
                                        var polygonControl = (currentControl as CloudControl);
3456
                                        currentControl.CommentID = Save.shortGuid();
3457
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3458
                                        currentControl.IsNew = true;
3459
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3460
3461
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3462
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3463
                                    }
3464
                                }
3465
                            }
3466
                        }
3467
                        break;
3468
                    case ControlType.ImgControl:
3469
                        {
3470
                            if (mouseButtonDown == MouseButton.Left)
3471
                            {
3472
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3473
                                {
3474
                                    if (currentControl is ImgControl)
3475
                                    {
3476
                                        CreateControl();
3477
                                        (currentControl as ImgControl).ApplyOverViewData();
3478
3479
                                        currentControl = null;
3480
                                    }
3481
                                    else
3482
                                    {
3483
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3484
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3485
                                        {
3486
                                            Image img = new Image();
3487
                                            img.Source = new BitmapImage(new Uri(filename));
3488
3489
                                            currentControl = new ImgControl
3490
                                            {
3491
                                                Background = new SolidColorBrush(Colors.Black),
3492
                                                PointSet = new List<Point>(),
3493
                                                FilePath = filename,
3494
                                                ImageData = img.Source,
3495
                                                StartPoint = canvasDrawingMouseDownPoint,
3496
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3497
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3498
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3499
                                            };
3500
3501
                                            currentControl.CommentID = Save.shortGuid();
3502
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3503
                                            currentControl.IsNew = true;
3504
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3505
                                        }
3506
                                    }
3507
                                }
3508
                            }
3509
                        }
3510
                        break;
3511
                    case ControlType.Date:
3512
                        {
3513
                            if (mouseButtonDown == MouseButton.Left)
3514
                            {
3515
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3516
                                {
3517
                                    if (currentControl is DateControl)
3518
                                    {
3519
                                        CreateControl();
3520
                                        (currentControl as DateControl).ApplyOverViewData();
3521
                                        currentControl = null;
3522
3523
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3524
                                        {
3525
                                            controlType = ControlType.None;
3526
                                            IsSwingMode = false;
3527
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3528
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3529
                                            mouseHandlingMode = MouseHandlingMode.None;
3530
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3531
                                            txtBatch.Visibility = Visibility.Collapsed;
3532
3533
                                        }
3534
                                    }
3535
                                    else
3536
                                    {
3537
                                        currentControl = new DateControl
3538
                                        {
3539
                                            Background = new SolidColorBrush(Colors.Black)
3540
                                        };
3541
                                        currentControl.CommentID = Save.shortGuid();
3542
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3543
                                        currentControl.IsNew = true;
3544
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3545
                                    }
3546
                                }
3547
                            }
3548
                        }
3549
                        break;
3550
                    case ControlType.TextControl:
3551
                        {
3552
                            if (mouseButtonDown == MouseButton.Left)
3553
                            {
3554
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3555
                                {
3556
3557
                                    currentControl = new TextControl
3558
                                    {
3559
                                        ControlType = controlType
3560
                                    };
3561
                                        currentControl.CommentID = Save.shortGuid();
3562
                                        currentControl.IsNew = true;
3563
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3564
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3565
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3566
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3567
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3568
                                        currentControl.Focus();
3569
                                        (currentControl as TextControl).ApplyOverViewData();
3570
                                        (currentControl as TextControl).ControlType_No = 0;
3571
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3572
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3573
3574
                                        CreateControl();
3575
3576
                                        currentControl = null;
3577
                                }
3578
                            }
3579
                        }
3580
                        break;
3581
                    case ControlType.TextBorder:
3582
                        {
3583
                            if (mouseButtonDown == MouseButton.Left)
3584
                            {
3585
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3586
                                {
3587
                                    currentControl = new TextControl
3588
                                    {
3589
                                        ControlType = controlType
3590
                                    };
3591
3592
3593
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3594
                                    currentControl.CommentID = Save.shortGuid();
3595
                                    currentControl.IsNew = true;
3596
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3597
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3598
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3599
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3600
                                    currentControl.Focus();
3601
                                    (currentControl as TextControl).ControlType_No = 1;
3602
                                    (currentControl as TextControl).Angle = Ang;
3603
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3604
                                    CreateControl();
3605
3606
                                    currentControl = null;
3607
                                }
3608
                            }
3609
                        }
3610
                        break;
3611
                    case ControlType.TextCloud:
3612
                        {
3613
                            if (mouseButtonDown == MouseButton.Left)
3614
                            {
3615
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3616
                                {
3617
                                    currentControl = new TextControl
3618
                                    {
3619
                                        ControlType = controlType
3620
                                    };
3621
                                    currentControl.CommentID = Save.shortGuid();
3622
                                    currentControl.IsNew = true;
3623
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3624
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3625
3626
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3627
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3628
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3629
                                    currentControl.Focus();
3630
3631
                                    (currentControl as TextControl).Angle = Ang;
3632
                                    (currentControl as TextControl).ControlType_No = 2;
3633
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3634
3635
                                    CreateControl();
3636
                                    currentControl = null;
3637
                                }
3638
                            }
3639
                        }
3640
                        break;
3641
                    case ControlType.ArrowTextControl:
3642
                        {
3643
                            if (mouseButtonDown == MouseButton.Left)
3644
                            {
3645
                                if (currentControl is ArrowTextControl)
3646
                                {
3647
                                    CreateControl();
3648
3649
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3650
                                    (currentControl as ArrowTextControl).IsEditing = false;
3651
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3652
                                    currentControl = null;
3653 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3654 787a4489 KangIngu
3655
                                }
3656
                                else
3657
                                {
3658
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3659
                                    {
3660
                                        currentControl = new ArrowTextControl();
3661
                                        currentControl.CommentID = Save.shortGuid();
3662
                                        currentControl.IsNew = true;
3663
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3664
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3665
3666
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3667
3668
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3669
3670
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3671
3672
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3673
3674
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3675
3676
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3677 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3678 787a4489 KangIngu
                                    }
3679
                                }
3680
                            }
3681
                        }
3682
                        break;
3683
                    case ControlType.ArrowTransTextControl:
3684
                        {
3685
                            if (mouseButtonDown == MouseButton.Left)
3686
                            {
3687
                                if (currentControl is ArrowTextControl)
3688
                                {
3689
                                    CreateControl();
3690
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3691
                                    currentControl = null;
3692 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3693 787a4489 KangIngu
                                }
3694
                                else
3695
                                {
3696
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3697
                                    {
3698
                                        currentControl = new ArrowTextControl();
3699
                                        currentControl.CommentID = Save.shortGuid();
3700
                                        currentControl.IsNew = true;
3701
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3702
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3703
3704
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3705
3706
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3707
3708
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3709
3710 2eac4f76 KangIngu
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3711
3712 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3713
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3714
3715
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3716 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3717 787a4489 KangIngu
                                    }
3718
                                }
3719
                            }
3720
                        }
3721
                        break;
3722
                    case ControlType.ArrowTextBorderControl:
3723
                        {
3724
                            if (mouseButtonDown == MouseButton.Left)
3725
                            {
3726
                                if (currentControl is ArrowTextControl)
3727
                                {
3728
                                    CreateControl();
3729
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3730
                                    currentControl = null;
3731 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3732 787a4489 KangIngu
                                }
3733
                                else
3734
                                {
3735
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3736
                                    {
3737
                                        currentControl = new ArrowTextControl()
3738
                                        {
3739
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3740
                                        };
3741
                                        currentControl.CommentID = Save.shortGuid();
3742
                                        currentControl.IsNew = true;
3743
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3744
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3745
3746
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3747
3748
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3749
3750
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3751
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3752
3753
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3754
3755
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3756 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3757 787a4489 KangIngu
                                    }
3758
                                }
3759
                            }
3760
                        }
3761
                        break;
3762
                    case ControlType.ArrowTransTextBorderControl:
3763
                        {
3764
                            if (mouseButtonDown == MouseButton.Left)
3765
                            {
3766
                                if (currentControl is ArrowTextControl)
3767
                                {
3768
                                    CreateControl();
3769
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3770
                                    currentControl = null;
3771 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3772 787a4489 KangIngu
                                }
3773
                                else
3774
                                {
3775
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3776
                                    {
3777
                                        currentControl = new ArrowTextControl()
3778
                                        {
3779
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3780
                                        };
3781
                                        currentControl.CommentID = Save.shortGuid();
3782
                                        currentControl.IsNew = true;
3783
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3784
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3785
3786
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3787
3788
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3789
3790
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3791
3792
                                        (currentControl as ArrowTextControl).isFixed = true;
3793
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3794
3795
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3796
3797
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3798 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3799 787a4489 KangIngu
                                    }
3800
                                }
3801
                            }
3802
                        }
3803
                        break;
3804
                    case ControlType.ArrowTextCloudControl:
3805
                        {
3806
                            if (mouseButtonDown == MouseButton.Left)
3807
                            {
3808
                                if (currentControl is ArrowTextControl)
3809
                                {
3810
                                    CreateControl();
3811
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3812
                                    currentControl = null;
3813 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3814 787a4489 KangIngu
                                }
3815
                                else
3816
                                {
3817
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3818
                                    {
3819
                                        currentControl = new ArrowTextControl()
3820
                                        {
3821
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3822
                                        };
3823
                                        currentControl.CommentID = Save.shortGuid();
3824
                                        currentControl.IsNew = true;
3825
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3826
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3827
3828
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3829
3830
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3831
3832
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3833
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3834
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3835
3836
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3837 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3838 787a4489 KangIngu
                                    }
3839
                                }
3840
                            }
3841
                        }
3842
                        break;
3843
                    case ControlType.ArrowTransTextCloudControl:
3844
                        {
3845
                            if (mouseButtonDown == MouseButton.Left)
3846
                            {
3847
                                if (currentControl is ArrowTextControl)
3848
                                {
3849
                                    CreateControl();
3850
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3851
                                    currentControl = null;
3852 5ce56a3a KangIngu
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3853 787a4489 KangIngu
                                }
3854
                                else
3855
                                {
3856
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3857
                                    {
3858
                                        currentControl = new ArrowTextControl()
3859
                                        {
3860
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3861
                                        };
3862
                                        currentControl.CommentID = Save.shortGuid();
3863
                                        currentControl.IsNew = true;
3864
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3865
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3866
3867
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3868
3869
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3870
3871
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3872
3873
                                        (currentControl as ArrowTextControl).isFixed = true;
3874
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3875
3876
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3877
3878
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3879 5ce56a3a KangIngu
                                        this.MainAngle.Visibility = Visibility.Visible;
3880 787a4489 KangIngu
                                    }
3881
                                }
3882
                            }
3883
                        }
3884
                        break;
3885
                    case ControlType.PolygonControl:
3886
                        {
3887
                            if (currentControl is PolygonControl)
3888
                            {
3889
                                var control = currentControl as PolygonControl;
3890
3891
                                if (mouseButtonDown == MouseButton.Right)
3892
                                {
3893
                                    control.IsCompleted = true;
3894
                                }
3895
3896
                                if (!control.IsCompleted)
3897
                                {
3898
                                    control.PointSet.Add(control.EndPoint);
3899
                                }
3900
                                else
3901
                                {
3902
                                    var firstPoint = control.PointSet.First();
3903
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3904
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3905
                                    control.PointSet.Add(firstPoint);
3906
3907
                                    control.SetPolyPath();
3908
3909
                                    control.ApplyOverViewData();
3910
3911
                                    CreateControl();
3912
3913
                                    currentControl = null;
3914
                                }
3915
                            }
3916
                            else
3917
                            {
3918
                                if (mouseButtonDown == MouseButton.Left)
3919
                                {
3920
                                    currentControl = new PolygonControl
3921
                                    {
3922
                                        PointSet = new List<Point>(),
3923
                                        //PointC = new StylusPointSet()
3924
                                    };
3925
3926
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3927
                                    {
3928
                                        var polygonControl = (currentControl as PolygonControl);
3929
                                        currentControl.CommentID = Save.shortGuid();
3930
                                        currentControl.IsNew = true;
3931
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3932
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3933
                                        //currentControl.OnApplyTemplate();
3934
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3935
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3936
                                    }
3937
                                }
3938
                            }
3939
                        }
3940
                        break;
3941
                    //강인구 추가
3942
                    case ControlType.Sign:
3943
                        {
3944
                            if (mouseButtonDown == MouseButton.Left)
3945
                            {
3946
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3947
                                {
3948
                                    if (currentControl is SignControl)
3949
                                    {
3950
                                        CreateControl();
3951
                                        currentControl = null;
3952
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3953
                                        {
3954
                                            txtBatch.Text = "Date Control을 그립니다.";
3955
                                            controlType = ControlType.Date;
3956
                                        }
3957
                                    }
3958
                                    else
3959
                                    {
3960
                                        currentControl = new SignControl
3961
                                        {
3962
                                            Background = new SolidColorBrush(Colors.Black),
3963
                                            UserNumber = App.ViewInfo.UserID,
3964
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3965
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3966
                                            ControlType = ControlType.Sign
3967
                                        };
3968
3969
                                        currentControl.CommentID = Save.shortGuid();
3970
                                        currentControl.IsNew = true;
3971
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3972
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3973
                                    }
3974
                                }
3975
                            }
3976
                        }
3977
                        break;
3978
                    case ControlType.Mark:
3979
                        {
3980
                            if (mouseButtonDown == MouseButton.Left)
3981
                            {
3982
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3983
                                {
3984
                                    if (currentControl is RectangleControl)
3985
                                    {
3986
                                        CreateControl();
3987
                                        (currentControl as RectangleControl).ApplyOverViewData();
3988
                                        currentControl = null;
3989
                                        this.cursor = Cursors.Arrow;
3990
3991
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3992
                                        {
3993
                                            txtBatch.Text = "Sign Control을 그립니다.";
3994
                                            controlType = ControlType.Sign;
3995
                                        }
3996
                                    }
3997
                                    else
3998
                                    {
3999
                                        currentControl = new RectangleControl
4000
                                        {
4001
                                            Background = new SolidColorBrush(Colors.Black),
4002
                                            Paint = PaintSet.Fill
4003
                                        };
4004
4005
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4006
                                        currentControl.CommentID = Save.shortGuid();
4007
                                        currentControl.IsNew = true;
4008
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4009
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4010
                                    }
4011
                                }
4012
                            }
4013
                        }
4014
                        break;
4015
                    case ControlType.Symbol:
4016
                        {
4017
                            if (mouseButtonDown == MouseButton.Left)
4018
                            {
4019
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4020
                                {
4021
                                    if (currentControl is SymControl)
4022
                                    {
4023
                                        CreateControl();
4024
                                        currentControl = null;
4025
                                        this.cursor = Cursors.Arrow;
4026
                                    }
4027
                                    else
4028
                                    {
4029
                                        currentControl = new SymControl
4030
                                        {
4031
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4032
                                            Background = new SolidColorBrush(Colors.Black),
4033
                                            ControlType = ControlType.Symbol
4034
                                        };
4035
4036
                                        currentControl.IsNew = true;
4037
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4038
                                        currentControl.CommentID = Save.shortGuid();
4039
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4040
                                    }
4041
                                }
4042
                            }
4043
                        }
4044
                        break;
4045
                    case ControlType.Stamp:
4046
                        {
4047
                            if (mouseButtonDown == MouseButton.Left)
4048
                            {
4049
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4050
                                {
4051
                                    if (currentControl is SymControlN)
4052
                                    {
4053
                                        CreateControl();
4054
                                        currentControl = null;
4055
                                        this.cursor = Cursors.Arrow;
4056
                                    }
4057
                                    else
4058
                                    {
4059
                                        currentControl = new SymControlN
4060
                                        {
4061
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4062
                                            Background = new SolidColorBrush(Colors.Black),
4063
                                            ControlType = ControlType.Stamp
4064
                                        };
4065
4066
                                        currentControl.IsNew = true;
4067
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4068
                                        currentControl.CommentID = Save.shortGuid();
4069
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4070
                                    }
4071
                                }
4072
                            }
4073
                        }
4074
                        break;
4075
                    case ControlType.PenControl:
4076
                        {
4077
                            if (inkBoard.Tag.ToString() == "Ink")
4078
                            {
4079
                                inkBoard.IsEnabled = true;
4080
                                StartNewStroke(canvasDrawingMouseDownPoint);
4081
                            }
4082
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4083
                            {
4084
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4085
                            }
4086
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4087
                            {
4088
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4089
                            }
4090
                            IsDrawing = true;
4091
                            return;
4092
                        }
4093
                    default:
4094
                        if (currentControl != null)
4095
                        {
4096
                            currentControl.CommentID = null;
4097
                            currentControl.IsNew = false;
4098
                        }
4099
                        break;
4100
                }
4101
4102
            }
4103
4104 4318fdeb KangIngu
            //else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4105
            //{
4106
            //    if (controlType == ControlType.None)
4107
            //    {
4108
            //        mouseHandlingMode = MouseHandlingMode.Selecting;
4109
            //        this.cursor = Cursors.Arrow;
4110
            //        inkDrawingCanvas.IsEnabled = false;
4111
            //        isLeftMouseButtonDownOnWindow = true;
4112
            //    }
4113
            //}
4114 787a4489 KangIngu
4115
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4116
            {
4117
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4118
                {
4119
                    bool mouseOff = false;
4120
                    foreach (var item in SelectLayer.Children)
4121
                    {
4122
                        if (item is AdornerFinal)
4123
                        {
4124
4125
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4126
                            if (over != null)
4127
                            {
4128
                                mouseOff = true;
4129
                            }
4130
                        }
4131
                    }
4132
4133
                    if (!mouseOff)
4134
                    {
4135
                        ReleaseAdorner();
4136
                    }
4137
                }
4138
                zoomAndPanControl.CaptureMouse();
4139
                e.Handled = true;
4140
            }
4141 ae56d52d KangIngu
            
4142 787a4489 KangIngu
        }
4143 ae56d52d KangIngu
        
4144 787a4489 KangIngu
        private void RemoveLineStroke(Point P)
4145
        {
4146
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4147
            if (control != null)
4148
            {
4149
                UndoData = new Undo_data()
4150
                {
4151
                    IsUndo = false,
4152
                    Event = Event_Type.Delete,
4153
                    EventTime = DateTime.Now,
4154
                    Markup_List = new List<Multi_Undo_data>()
4155
                };
4156
4157
4158
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4159
                UndoData.Markup_List.Add(multi_Undo_Data);
4160
                multi_Undo_Data = new Multi_Undo_data();
4161
4162
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4163
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4164
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4165
4166
4167
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4168
                {
4169
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4170
                });
4171
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4172 ae56d52d KangIngu
                
4173 787a4489 KangIngu
            }
4174
        }
4175
4176
        private void RemovePointStroke(Point P)
4177
        {
4178
            foreach (Stroke hits in inkBoard.Strokes)
4179
            {
4180
                foreach (StylusPoint sty in hits.StylusPoints)
4181
                {
4182
4183
                }
4184
                if (hits.HitTest(P))
4185
                {
4186
                    inkBoard.Strokes.Remove(hits);
4187
                    return;
4188
                }
4189
            }
4190
        }
4191
4192
        private void StartNewStroke(Point P)
4193
        {
4194
            strokePoints = new StylusPointCollection();
4195
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4196
            strokePoints.Add(segment1Start);
4197
            stroke = new Stroke(strokePoints);
4198
4199
            stroke.DrawingAttributes.Color = Colors.Red;
4200
            stroke.DrawingAttributes.Width = 4;
4201
            stroke.DrawingAttributes.Height = 4;
4202
4203
            inkBoard.Strokes.Add(stroke);
4204
4205
        }
4206
4207
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4208
        {
4209
            ConsolidationMethod();
4210
        }
4211
4212
        public void ConsolidationMethod()
4213
        {
4214
            ChangeCommentReact();
4215
4216
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4217
            {
4218
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4219
            }
4220
            else
4221
            {
4222
4223
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4224
                {
4225
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4226
                }
4227
4228
                ViewerDataModel.Instance.IsConsolidate = true;
4229
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4230
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4231
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4232
                {
4233
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4234
                    if (markupInfo.CONSOLIDATE == 1)
4235
                    {
4236
                        markupInfo.AVOID_CONSOLIDATE = 1;
4237
                    }
4238
4239
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4240
                    {
4241
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4242
                          {
4243
                              instanceDataSet.Add(d);
4244
                          });
4245
                    }
4246
4247
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4248
                    info.ID = Save.shortGuid();
4249
                    info.CONSOLIDATE = 1;
4250
                    info.CREATE_TIME = DateTime.Now;
4251
                    info.DOCINFO_ID = _DocInfo.ID;
4252
                    info.UPDATE_TIME = DateTime.Now;
4253
                    info.USER_ID = App.ViewInfo.UserID;
4254
                    info.AVOID_CONSOLIDATE = 0;
4255
4256
                    Entity.MARKUP_INFO.AddObject(info);
4257
                    Entity.SaveChanges();
4258
4259
4260
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4261
                    {
4262
                        ID = Save.shortGuid(),
4263
                        CREATE_DATE = DateTime.Now,
4264
                        MARKUP_INFO = info,
4265
                    };
4266
                    Entity.SaveChanges();
4267
4268
                    foreach (var item in instanceDataSet)
4269
                    {
4270
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4271
                        {
4272
                            ID = Save.shortGuid(),
4273
                            DATA = item.DATA,
4274
                            DATA_TYPE = item.DATA_TYPE,
4275
                            PAGENUMBER = item.PAGENUMBER,
4276
                            MARKUP_INFO_VERSION = info2
4277
                        });
4278
                    }
4279
                    Entity.SaveChanges();
4280
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4281
                }
4282
            }
4283
        }
4284
4285
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4286
        {
4287
            if (App.ViewInfo != null)
4288
            {
4289
                btnConsolidate = (sender as RadRibbonButton);
4290
                if (!App.ViewInfo.NewCommentPermission)
4291
                {
4292
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4293
                }
4294
            }
4295
        }
4296
4297
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4298
        {
4299
4300
        }
4301
4302
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4303
        {
4304
            btnTeamConsolidate = sender as RadRibbonButton;
4305
            if (App.ViewInfo != null)
4306
            {
4307
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4308
                {
4309
                    if (btnConsolidate != null)
4310
                    {
4311
                        btnConsolidate.Visibility = Visibility.Collapsed;
4312
                    }
4313
4314
                    if (!App.ViewInfo.NewCommentPermission)
4315
                    {
4316
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4317
                    }
4318
                }
4319
                else
4320
                {
4321
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4322
                }
4323
            }
4324
        }
4325
4326
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4327
        {
4328
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4329
            if (item != null)
4330
            {
4331
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4332
            }
4333
            else
4334
            {
4335
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4336
            }
4337
        }
4338
4339
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4340
        {
4341
            btnFinalPDF = sender as RadRibbonButton;
4342
            if (App.ViewInfo != null)
4343
            {
4344
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4345
                {
4346
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4347
                    if (btnConsolidate != null)
4348
                    {
4349
                        btnConsolidate.Visibility = Visibility.Collapsed;
4350
                    }
4351
                }
4352
            }
4353
        }
4354
4355
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4356
        {
4357
            if (CompareMode.IsChecked)
4358
            {
4359
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4360
                {
4361
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4362
                }
4363
                if (ViewerDataModel.Instance.PageNumber == 0)
4364
                {
4365
                    ViewerDataModel.Instance.PageNumber = 1;
4366
                }
4367
4368
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4369
            }
4370
            else
4371
            {
4372
                da.From = 1;
4373
                da.To = 1;
4374
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4375
                da.AutoReverse = false;
4376
                canvas_compareBorder.Children.Clear();
4377
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4378
            }
4379
        }
4380
4381
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4382
        {
4383
            if (UserList.IsChecked)
4384
            {
4385
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4386
            }
4387
            else
4388
            {
4389
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4390
            }
4391
        }
4392
4393
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4394
        {
4395
4396
            if (BalanceMode.IsChecked)
4397
            {
4398
                ViewerDataModel.Instance.PageBalanceMode = true;
4399
            }
4400
            else
4401
            {
4402
                ViewerDataModel.Instance.PageBalanceMode = false;
4403
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4404
            }
4405
        }
4406
4407
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4408
        {
4409
            //초기화
4410
            testPanel2.IsHidden = true;
4411
            ViewerDataModel.Instance.PageBalanceMode = false;
4412
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4413
            ViewerDataModel.Instance.PageNumber = 0;
4414
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4415
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4416
            UserList.IsChecked = false;
4417
            BalanceMode.IsChecked = false;
4418
        }
4419
4420
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4421
        {
4422
            if ((sender as System.Windows.Controls.Control).Tag != null)
4423
            {
4424
                //Compare 초기화
4425
                CompareMode.IsChecked = false;
4426
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4427
4428
                if (ViewerDataModel.Instance.PageNumber == 0)
4429
                {
4430
                    ViewerDataModel.Instance.PageNumber = 1;
4431
                }
4432
4433
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4434
                {
4435
                }
4436
                else
4437
                {
4438
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4439
                }
4440
4441
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4442
                {
4443
4444
                }
4445
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4446
                {
4447
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4448
                }
4449
4450
                if (!testPanel2.IsHidden)
4451
                {
4452
                    if (IsSyncPDFMode)
4453
                    {
4454
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4455
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4456
4457
                        if (pdfpath.IsDownloading)
4458
                        {
4459
                            pdfpath.DownloadCompleted += (ex, arg) =>
4460
                            {
4461
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4462
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4463
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4464
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4465
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4466
                            };
4467
                        }
4468
                        else
4469
                        {
4470
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4471
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4472
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4473
4474
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4475
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4476
                        }
4477
4478
                    }
4479
                    else
4480
                    {
4481
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4482
4483
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4484
4485
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4486
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4487
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4488
4489
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4490
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4491
4492
                        if (defaultBitmapImage_Compare.IsDownloading)
4493
                        {
4494
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4495
                            {
4496
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4497
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4498
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4499
4500
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4501
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4502
                            };
4503
                        }
4504
                    }
4505
4506
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4507
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4508
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4509
4510
                    foreach (var item in gridSelectionRevItem)
4511
                    {
4512
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4513
                        {
4514
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4515
                        });
4516
                    }
4517 ae56d52d KangIngu
                    
4518 787a4489 KangIngu
                    //강인구 추가
4519
                    zoomAndPanControl2.ZoomTo(new Rect
4520
                    {
4521
                        X = 0,
4522
                        Y = 0,
4523
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4524
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4525
                    });
4526 ae56d52d KangIngu
4527 787a4489 KangIngu
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4528
4529
                }
4530
            }
4531
        }
4532
4533
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4534
        {
4535
            if (MarkupMode.IsChecked)
4536
            {
4537
                IsSyncPDFMode = true;
4538
4539
                var uri = CurrentRev.TO_VENDOR;
4540 ae56d52d KangIngu
4541 787a4489 KangIngu
                if (ViewerDataModel.Instance.PageNumber == 0)
4542
                {
4543
                    ViewerDataModel.Instance.PageNumber = 1;
4544
                }
4545
4546
                //PDF모드 잠시 대기(강인구)
4547
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4548
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4549
4550
                if (pdfpath.IsDownloading)
4551
                {
4552
                    pdfpath.DownloadCompleted += (ex, arg) =>
4553
                    {
4554
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4555
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4556
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4557
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4558
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4559
                    };
4560
                }
4561
                else
4562
                {
4563
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4564
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4565
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4566
4567
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4568
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4569
                }
4570
            }
4571
            else
4572
            {
4573
                IsSyncPDFMode = false;
4574
                var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4575
4576
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4577
4578
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4579
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4580
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4581
4582
                if (defaultBitmapImage_Compare.IsDownloading)
4583
                {
4584
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4585
                    {
4586
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4587
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4588
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4589
                    };
4590
                }
4591
                zoomAndPanControl2.ApplyTemplate();
4592
                zoomAndPanControl2.UpdateLayout();
4593
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4594
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4595
            }
4596
        }
4597
4598
        private void RadButton_Click(object sender, RoutedEventArgs e)
4599
        {
4600
            gridViewHistory_Busy.IsBusy = true;
4601
4602
            RadButton instance = sender as RadButton;
4603
            if (instance.CommandParameter != null)
4604
            {
4605
                CurrentRev = instance.CommandParameter as VPRevision;
4606
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4607
                {
4608
                    if (ea.Error == null && ea.Result != null)
4609
                    {
4610
                        testPanel2.IsHidden = false;
4611
4612
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4613
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4614
4615
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4616
4617
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4618
4619
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4620
4621
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4622
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4623
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4624
4625
                        if (defaultBitmapImage_Compare.IsDownloading)
4626
                        {
4627
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4628
                            {
4629
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4630
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4631
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4632
                            };
4633
                        }
4634
4635
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4636
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4637
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4638
                        zoomAndPanControl2.ApplyTemplate();
4639
                        zoomAndPanControl2.UpdateLayout();
4640
4641
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4642
                        {
4643
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4644
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4645
                        }
4646
4647
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4648
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4649
                        gridViewHistory_Busy.IsBusy = false;
4650
                    }
4651
                };
4652
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4653
            }
4654
        }
4655
4656
        public void Sync_Event(VPRevision Currnet_Rev)
4657
        {
4658
            CurrentRev = Currnet_Rev;
4659
4660
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4661
            {
4662
                if (ea.Error == null && ea.Result != null)
4663
                {
4664
                    testPanel2.IsHidden = false;
4665
4666
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4667
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4668
4669
                    var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4670
4671
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4672
4673
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4674
4675
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4676
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4677
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4678
4679
                    if (defaultBitmapImage_Compare.IsDownloading)
4680
                    {
4681
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4682
                        {
4683
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4684
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4685
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4686
                        };
4687
                    }
4688
4689
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4690
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4691
                    zoomAndPanControl2.ApplyTemplate();
4692
                    zoomAndPanControl2.UpdateLayout();
4693
4694
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4695
                    {
4696
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4697
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4698
                    }
4699
                    //}
4700
4701
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4702
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4703
                    gridViewHistory_Busy.IsBusy = false;
4704
                }
4705
            };
4706
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4707
4708
4709
        }
4710
4711
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4712
        {
4713
            if (sender is Image)
4714
            {
4715
                if ((sender as Image).Tag != null)
4716
                {
4717
                    var pdfUrl = (sender as Image).Tag.ToString();
4718
                    System.Diagnostics.Process.Start(pdfUrl);
4719
                }
4720
                else
4721
                {
4722
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4723
                }
4724
            }
4725
        }
4726
4727
        private void Create_Symbol(object sender, RoutedEventArgs e)
4728
        {
4729
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4730
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4731
4732
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4733
            {
4734
                DialogMessage_Alert("Please Select Controls", "Alert");
4735
            }
4736
            else //선택된 것이 있으면
4737
            {
4738
                string MarkupData = "";
4739
                adorner_ = new AdornerFinal();
4740
4741
                foreach (var item in SelectLayer.Children)
4742
                {
4743
                    if (item.GetType().Name == "AdornerFinal")
4744
                    {
4745
                        adorner_ = (item as Controls.AdornerFinal);
4746
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4747
                        {
4748
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4749
                            {
4750
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4751
                                MarkupData += markupReturn.ConvertData;
4752
                            }
4753
                        }
4754
                    }
4755
                }
4756
                DialogParameters parameters = new DialogParameters()
4757
                {
4758
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4759
                    DefaultPromptResultValue = "Custom State",
4760
                    Content = "Name :",
4761
                    Header = "Insert Custom Symbol Name",
4762
                    Theme = new VisualStudio2013Theme(),
4763
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4764
                };
4765
                RadWindow.Prompt(parameters);
4766
            }
4767
4768
        }
4769
4770
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4771
        {
4772
            Save save = new Save();
4773
4774
            if (args.DialogResult.Value)
4775
            {
4776
                PngBitmapEncoder _Encoder = symImage(data);
4777
4778
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4779
                _Encoder.Save(fs);
4780
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4781
4782
                byte[] Img_byte = fs.ToArray();
4783
4784
                kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4785
                filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
4786
4787
                save.SymbolSave(args.PromptResult, filename, data);
4788
            }
4789
        }
4790
4791
        public PngBitmapEncoder symImage(string data)
4792
        {
4793
4794
            Canvas _canvas = new Canvas();
4795
            _canvas.Background = Brushes.White;
4796
            _canvas.Width = adorner_.BorderSize.Width;
4797
            _canvas.Height = adorner_.BorderSize.Height;
4798
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4799
4800
            BitmapEncoder encoder = new PngBitmapEncoder();
4801
4802
4803
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
4804
4805
            DrawingVisual dv = new DrawingVisual();
4806
4807
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
4808
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X - 20, Y = -adorner_.BorderSize.Y - 20 }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
4809
4810
            using (DrawingContext ctx = dv.RenderOpen())
4811
            {
4812
                VisualBrush vb = new VisualBrush(_canvas);
4813
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
4814
            }
4815
4816
            try
4817
            {
4818
                renderBitmap.Render(dv);
4819
4820
                GC.Collect();
4821
                GC.WaitForPendingFinalizers();
4822
                GC.Collect();
4823
                // encode png data
4824
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4825
                // puch rendered bitmap into it
4826
                pngEncoder.Interlace = PngInterlaceOption.Off;
4827
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4828
                return pngEncoder;
4829
4830
            }
4831
            catch (Exception ex)
4832
            {
4833
                return null;
4834
            }
4835
4836
        }
4837
4838
        public void DialogMessage_Alert(string content, string header)
4839
        {
4840
            var box = new TextBlock();
4841
            box.MinWidth = 400;
4842
            box.FontSize = 11;
4843
            //box.FontSize = 12;
4844
            box.Text = content;
4845
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4846
4847
            DialogParameters parameters = new DialogParameters()
4848
            {
4849
                Content = box,
4850
                Header = header,
4851
                Theme = new VisualStudio2013Theme(),
4852
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4853
            };
4854
            RadWindow.Alert(parameters);
4855
        }
4856
4857
        #region 캡쳐 기능
4858
4859
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4860
        {
4861
            if (x < 0)
4862
            {
4863
                width += x;
4864
                x = 0;
4865
            }
4866
            if (y < 0)
4867
            {
4868
                height += y;
4869
                y = 0;
4870
4871
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4872
            }
4873
            if (x + width > zoomAndPanCanvas.ActualWidth)
4874
            {
4875
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4876
            }
4877
            if (y + height > zoomAndPanCanvas.ActualHeight)
4878
            {
4879
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4880
            }
4881
4882
            byte[] pixels = CopyPixels(x, y, width, height);
4883
4884
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4885
4886
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4887
        }
4888
4889
        public byte[] CopyPixels(int x, int y, int width, int height)
4890
        {
4891
            byte[] pixels = new byte[width * height * 4];
4892
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4893
4894
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
4895
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
4896
4897
            return pixels;
4898
        }
4899
4900
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4901
        {
4902
            DrawingVisual drawingVisual = new DrawingVisual();
4903
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4904
4905
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4906
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4907
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4908
            drawingContext.Close();
4909
4910
            // 비트맵으로 변환합니다.
4911
            RenderTargetBitmap target =
4912
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4913
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4914
4915
            target.Render(drawingVisual);
4916
            return target;
4917
        }
4918
4919
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4920
        {
4921
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4922
            KCOMDataModel.DataModel.CHECK_LIST check_;
4923
            string Result = streamToBase64.ImageToBase64(source);
4924
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4925
4926
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4927
            {
4928
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
4929
4930
                //새로운 데이터 추가
4931
                if (Item == null)
4932
                {
4933
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
4934
                    {
4935
                        ID = Save.shortGuid(),
4936
                        USER_ID = App.ViewInfo.UserID,
4937
                        IMAGE_URL = Result,
4938
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4939
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4940
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4941
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4942
                        PROJECT_NO = App.ViewInfo.ProjectNO,
4943
                        STATUS = "False",
4944
                        CREATE_TIME = DateTime.Now,
4945
                        UPDATE_TIME = DateTime.Now,
4946
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4947
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
4948
                    };
4949
4950
                    Entity.CHECK_LIST.AddObject(check_);
4951
                }
4952
                //기존에 있던 데이터 업데이트
4953
                else
4954
                {
4955
                    Item.IMAGE_URL = Result;
4956
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4957
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4958
                }
4959
4960
                //Item.REV_0 = "Test";
4961
4962
                try
4963
                {
4964
                    Entity.SaveChanges();
4965
                }
4966
                catch (Exception ex)
4967
                {
4968
4969
                }
4970
                //Entity.SaveChanges();
4971
            }
4972
        }
4973
4974
        public void Set_Capture()
4975
        {
4976
            //double x = Canvas.GetLeft(dragCaptureBorder);
4977
            //double y = Canvas.GetTop(dragCaptureBorder);
4978
            double x = canvasDrawingMouseDownPoint.X;
4979
            double y = canvasDrawingMouseDownPoint.Y;
4980
            double width = dragCaptureBorder.Width;
4981
            double height = dragCaptureBorder.Height;
4982
4983
            if (width > 5 || height > 5)
4984
            {
4985
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
4986
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
4987
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
4988
            }
4989
        }
4990
        #endregion
4991
4992
        public void CreateControl()
4993
        {
4994
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4995
            {
4996
                ViewerDataModel.Instance.UndoDataList.Remove(i);
4997
            });
4998
            multi_Undo_Data.Markup = currentControl;
4999
            UndoData.Markup_List.Add(multi_Undo_Data);
5000
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5001
        }
5002
5003
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5004
        {
5005
            multi_Undo_Data = new Multi_Undo_data();
5006
5007
            multi_Undo_Data.Markup = control;
5008
5009
            if ((control as IShapeControl) != null)
5010
            {
5011
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5012
            }
5013
            if ((control as IDashControl) != null)
5014
            {
5015
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5016
            }
5017
            if ((control as IPath) != null)
5018
            {
5019
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5020
            }
5021
            if ((control as UIElement) != null)
5022
            {
5023
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5024
            }
5025
5026
            return multi_Undo_Data;
5027
        }
5028
5029
        public void Undo()
5030
        {
5031
            Undo_data undo = new Undo_data();
5032
            AdornerFinal final;
5033
            ReleaseAdorner();
5034
5035
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5036
            if (undo == null)
5037
                return;
5038
5039
            switch (undo.Event)
5040
            {
5041
                case (Event_Type.Create):
5042
                    {
5043
                        foreach (var item in undo.Markup_List)
5044
                        {
5045
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5046
                        }
5047
                    }
5048
                    break;
5049
                case (Event_Type.Delete):
5050
                    {
5051
                        foreach (var item in undo.Markup_List)
5052
                        {
5053
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5054
                        }
5055
                    }
5056
                    break;
5057
                case (Event_Type.Thumb):
5058
                    {
5059
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5060
5061
                        foreach (var item in undo.Markup_List)
5062
                        {
5063
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5064
5065
                            if ((item.Markup as IViewBox) != null)
5066
                            {
5067
                                (item.Markup as IViewBox).Angle = item.Angle;
5068
                            }
5069
                            if ((item.Markup as TextControl) != null)
5070
                            {
5071
                                (item.Markup as TextControl).Angle = item.Angle;
5072
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5073
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5074
                            }
5075
                            else
5076
                            {
5077
                                (item.Markup as IPath).PointSet = item.PointSet;
5078
                                (item.Markup as IPath).updateControl();
5079
                            }
5080
5081
                            comment.Add(item.Markup);
5082
                        }
5083
                        final = new AdornerFinal(comment);
5084
                        SelectLayer.Children.Add(final);
5085
                        ReleaseAdorner();
5086
                    }
5087
                    break;
5088
                case (Event_Type.Select):
5089
                    {
5090
                        ReleaseAdorner();
5091
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5092
5093
                        foreach (var item in undo.Markup_List)
5094
                        {
5095
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5096
5097
                            if ((item.Markup as IPath) != null)
5098
                            {
5099
                                (item.Markup as IPath).LineSize = item.LineSize;
5100
                            }
5101
                            if ((item.Markup as UIElement) != null)
5102
                            {
5103
                                (item.Markup as UIElement).Opacity = item.Opacity;
5104
                            }
5105
                            if ((item.Markup as IDashControl) != null)
5106
                            {
5107
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5108
                            }
5109
                            if ((item.Markup as IShapeControl) != null)
5110
                            {
5111
                                (item.Markup as IShapeControl).Paint = item.paint;
5112
                            }
5113
5114
                            comment.Add(item.Markup);
5115
                        }
5116
5117
                        final = new AdornerFinal(comment);
5118
                        SelectLayer.Children.Add(final);
5119
                    }
5120
                    break;
5121
                case (Event_Type.Option):
5122
                    {
5123
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5124
5125
                        foreach (var item in undo.Markup_List)
5126
                        {
5127
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5128
5129
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5130
                            {
5131
                                (item.Markup as IPath).LineSize = undo.LineSize;
5132
                            }
5133
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5134
                            {
5135
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5136
                            }
5137
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5138
                            {
5139
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5140
                            }
5141 5ce56a3a KangIngu
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5142
                            {
5143
                                (item.Markup as LineControl).Interval = undo.Interval;
5144
                            }
5145 787a4489 KangIngu
                            else if (item.Markup as IShapeControl != null)
5146
                            {
5147
                                (item.Markup as IShapeControl).Paint = undo.paint;
5148
                            }
5149
                            comment.Add(item.Markup);
5150
                        }
5151
                        final = new AdornerFinal(comment);
5152
                        SelectLayer.Children.Add(final);
5153
                    }
5154
                    break;
5155
            }
5156
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5157
           {
5158
               i.IsUndo = true;
5159
           });
5160
        }
5161
5162
        public void Redo()
5163
        {
5164
            AdornerFinal final;
5165
            Undo_data redo = new Undo_data();
5166
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5167
            ReleaseAdorner();
5168
            if (redo == null)
5169
                return;
5170
5171
            switch (redo.Event)
5172
            {
5173
                case (Event_Type.Create):
5174
                    {
5175
                        foreach (var item in redo.Markup_List)
5176
                        {
5177
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5178
                        }
5179
                    }
5180
                    break;
5181
                case (Event_Type.Delete):
5182
                    {
5183
                        foreach (var item in redo.Markup_List)
5184
                        {
5185
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5186
                        }
5187
                    }
5188
                    break;
5189
                case (Event_Type.Thumb):
5190
                    {
5191
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5192
5193
                        foreach (var item in redo.Markup_List)
5194
                        {
5195
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5196
5197
                            if ((item.Markup as IViewBox) != null)
5198
                            {
5199
                                (item.Markup as IViewBox).Angle = item.Angle;
5200
                            }
5201
                            if ((item.Markup as TextControl) != null)
5202
                            {
5203
                                (item.Markup as TextControl).Angle = item.Angle;
5204
5205
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5206
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5207
                            }
5208
                            else
5209
                            {
5210
                                (item.Markup as IPath).PointSet = item.PointSet;
5211
                                (item.Markup as IPath).updateControl();
5212
                            }
5213
                            comment.Add(item.Markup);
5214
                        }
5215
                        final = new AdornerFinal(comment);
5216
                        SelectLayer.Children.Add(final);
5217
                        ReleaseAdorner();
5218
                    }
5219
                    break;
5220
                case (Event_Type.Select):
5221
                    {
5222
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5223
5224
                        foreach (var item in redo.Markup_List)
5225
                        {
5226
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5227
5228
                            if ((item.Markup as IPath) != null)
5229
                            {
5230
                                (item.Markup as IPath).LineSize = item.LineSize;
5231
                            }
5232
                            if ((item.Markup as UIElement) != null)
5233
                            {
5234
                                (item.Markup as UIElement).Opacity = item.Opacity;
5235
                            }
5236
                            if ((item.Markup as IDashControl) != null)
5237
                            {
5238
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5239
                            }
5240
                            if ((item.Markup as IShapeControl) != null)
5241
                            {
5242
                                (item.Markup as IShapeControl).Paint = item.paint;
5243
                            }
5244
5245
                            comment.Add(item.Markup);
5246
                        }
5247
                        final = new AdornerFinal(comment);
5248
                        SelectLayer.Children.Add(final);
5249
                    }
5250
                    break;
5251
                case (Event_Type.Option):
5252
                    {
5253
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5254
5255
                        foreach (var item in redo.Markup_List)
5256
                        {
5257
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5258
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5259
                            {
5260
                                (item.Markup as IPath).LineSize = redo.LineSize;
5261
                            }
5262
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5263
                            {
5264
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5265
                            }
5266
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5267
                            {
5268
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5269
                            }
5270 5ce56a3a KangIngu
                            else if(redo.Interval != 0 && item.Markup as LineControl != null)
5271
                            {
5272
                                (item.Markup as LineControl).Interval = redo.Interval;
5273
                            }
5274 787a4489 KangIngu
                            else if (item.Markup as IShapeControl != null)
5275
                            {
5276
                                (item.Markup as IShapeControl).Paint = redo.paint;
5277
                            }
5278
                            comment.Add(item.Markup);
5279
                        }
5280
                        final = new AdornerFinal(comment);
5281
                        SelectLayer.Children.Add(final);
5282
                    }
5283
                    break;
5284
            }
5285
5286
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5287
            {
5288
                i.IsUndo = false;
5289
            });
5290
        }
5291
5292
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5293
        {
5294
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5295
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5296
            {
5297
                if (items.UserID == Select_ID)
5298
                {
5299
                    foreach (var item in items.MarkupList)
5300
                    {
5301
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5302
                        {
5303
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5304
                        }
5305
                    }
5306
                }
5307
            }
5308
        }
5309
5310
        public void InkControl_Convert()
5311
        {
5312
            if (inkBoard.Strokes.Count > 0)
5313
            {
5314
                inkBoard.Strokes.ToList().ForEach(stroke =>
5315
                {
5316
                    List<Stroke> removingStroke = new List<Stroke>();
5317
                    StrokeCollection stC = new StrokeCollection();
5318
5319
                    removingStroke.Add(stroke);
5320
5321
                    InkToPath ip = new InkToPath();
5322
                    List<Point> inkPointSet = new List<Point>();
5323
                    PolygonControl pc = null;
5324
                    pc = new PolygonControl()
5325
                    {
5326
                        Angle = 0,
5327
                        PointSet = new List<Point>(),
5328
                        ControlType = ControlType.Ink
5329
                    };
5330
                    foreach (var item in removingStroke)
5331
                    {
5332
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5333
                        inkBoard.Strokes.Remove(item);
5334
                    }
5335
                    if (inkPointSet.Count != 0)
5336
                    {
5337
                        //강인구 추가(PenControl Undo Redo 추가)
5338
                        UndoData = new Undo_data()
5339
                        {
5340
                            IsUndo = false,
5341
                            Event = Event_Type.Create,
5342
                            EventTime = DateTime.Now,
5343
                            Markup_List = new List<Multi_Undo_data>()
5344
                        };
5345
5346
                        pc.StartPoint = inkPointSet[0];
5347
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5348
                        pc.PointSet = inkPointSet;
5349
                        pc.LineSize = 3;
5350
                        pc.CommentID = Save.shortGuid();
5351
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5352
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5353
                        pc.SetPolyPath();
5354
5355
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5356
                        {
5357
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5358
                        });
5359
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5360
                        UndoData.Markup_List.Add(multi_Undo_Data);
5361
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5362
                    }
5363
                });
5364
            }
5365
        }
5366 17a22987 KangIngu
5367 4318fdeb KangIngu
        /// <summary>
5368
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5369
        /// </summary>
5370
        /// <param name="StartP">StartPoint</param>
5371
        /// <param name="EndP">EndPoint</param>
5372
        /// <returns>Return_EndPoint</returns>
5373
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5374 17a22987 KangIngu
        {
5375 ae56d52d KangIngu
            Point Return_Point = new Point();
5376 17a22987 KangIngu
5377 4318fdeb KangIngu
            double dx = EndP.X - StartP.X;
5378
            double dy = EndP.Y - StartP.Y;
5379
            double length;
5380 17a22987 KangIngu
5381 4318fdeb KangIngu
            switch (controlType)
5382
            {
5383
                case ControlType.Triangle:
5384
                    {
5385
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5386
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5387
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5388
                    }
5389
                    break;
5390
                default:
5391
                    {
5392
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5393
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5394
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5395
                    }
5396
                    break;
5397
            }
5398 17a22987 KangIngu
5399
            return Return_Point;
5400
        }
5401 e753423e humkyung
5402
        /// <summary>
5403
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5404
        /// </summary>
5405
        /// <author>humkyung</author>
5406
        /// <date>2018.04.26</date>
5407
        /// <param name="StartP"></param>
5408
        /// <param name="EndP"></param>
5409
        /// <returns></returns>
5410
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP)
5411
        {
5412
            List<Point> res = new List<Point>();
5413
5414
            double dx = EndP.X - StartP.X;
5415
            double dy = EndP.Y - StartP.Y;
5416
            double length = Math.Sqrt(dx * dx + dy * dy);
5417
            double baseLength = length * Math.Tan(30.0* Math.PI / 180.0);
5418
            dx /= length;
5419
            dy /= length;
5420
            double tmp = dx;
5421
            dx = -dy; dy = tmp; /// rotate by 90 degree
5422
5423
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5424
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5425
5426
            return res;
5427
        }
5428 787a4489 KangIngu
    }
5429
}
클립보드 이미지 추가 (최대 크기: 500 MB)