프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ f67f164e

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

1

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
using KCOMDataModel.DataModel;
31
using System.Xml;
32
using static KCOM.TempFile;
33
using System.Windows.Threading;
34
using System.Diagnostics;
35
using System.Threading;
36
using System.Windows.Resources;
37
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
40
using MarkupToPDF.Controls.Cad;
41
using MarkupToPDF.Controls.Parsing;
42
using Telerik.Windows.Data;
43
using System.ComponentModel;
44

    
45
namespace KCOM.Views
46
{
47
    public static class ControlExtensions
48
    {
49
        public static T Clone<T>(this T controlToClone)
50
            where T : System.Windows.Controls.Control
51
        {
52
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
53

    
54
            T instance = Activator.CreateInstance<T>();
55

    
56
            foreach (PropertyInfo propInfo in controlProperties)
57
            {
58
                if (propInfo.CanWrite)
59
                {
60
                    if (propInfo.Name != "WindowTarget")
61
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
62
                }
63
            }
64
            return instance;
65
        }
66
    }
67

    
68
    public class MyConsole
69
    {
70
        private readonly System.Threading.ManualResetEvent _readLineSignal;
71
        private string _lastLine;
72
        public MyConsole()
73
        {
74
            _readLineSignal = new System.Threading.ManualResetEvent(false);
75
            Gui = new TextBox();
76
            Gui.AcceptsReturn = true;
77
            Gui.KeyUp += OnKeyUp;
78
        }
79

    
80
        private void OnKeyUp(object sender, KeyEventArgs e)
81
        {
82
            // this is always fired on UI thread
83
            if (e.Key == Key.Enter)
84
            {
85
                // quick and dirty, but that is not relevant to your question
86
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
87
                // now, when you detected that user typed a line, set signal
88
                _readLineSignal.Set();
89
            }
90
        }
91

    
92
        public TextBox Gui { get; private set; }
93

    
94
        public string ReadLine()
95
        {
96
            // that should always be called from non-ui thread
97
            if (Gui.Dispatcher.CheckAccess())
98
                throw new Exception("Cannot be called on UI thread");
99
            // reset signal
100
            _readLineSignal.Reset();
101
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
102
            _readLineSignal.WaitOne();
103
            // we got signalled - return line user typed.
104
            return _lastLine;
105
        }
106

    
107
        public void WriteLine(string line)
108
        {
109
            if (!Gui.Dispatcher.CheckAccess())
110
            {
111
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
112
                return;
113
            }
114

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

    
119
    /// <summary>
120
    /// MainMenu.xaml에 대한 상호 작용 논리
121
    /// </summary>
122
    public partial class MainMenu : UserControl
123
    {
124
        #region 프로퍼티
125
        public Undo_data UndoData { get; set; }
126
        public CommentUserInfo currentControl { get; set; }
127
        public ControlType controlType { get; set; }
128
        private Move move = new Move();
129
        private double[] rotateValue = { 0, 90, 180, 270 };
130
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
131
        private static readonly double DragThreshold = 5;
132
        private System.Windows.Input.Cursor cursor { get; set; }
133
        private Point canvasDrawingMouseDownPoint;
134
        public string filename { get; set; }
135
        private Point canvasZoomPanningMouseDownPoint;
136
        public Point getCurrentPoint;
137
        private Point canvasZoommovingMouseDownPoint;
138
        List<object> ControlList = new List<object>();
139
        private ListBox listBox = new ListBox();
140
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
141
        private bool isDraggingSelectionRect = false;
142
        DrawingAttributes inkDA = new DrawingAttributes();
143
        private VPRevision CurrentRev { get; set; }
144
        public RadRibbonButton btnConsolidate { get; set; }
145
        public RadRibbonButton btnFinalPDF { get; set; }
146
        public RadRibbonButton btnTeamConsolidate { get; set; }
147
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
148

    
149
        public string Filename_ { get; set; }
150
        public double L_Size = 0;
151
        public AdornerFinal adorner_;
152
        public Multi_Undo_data multi_Undo_Data;
153
        public string Symbol_ID = "";
154
        /// <summary>
155
        /// Set to 'true' when the left mouse-button is down.
156
        /// </summary>
157
        public bool isLeftMouseButtonDownOnWindow = false;
158

    
159
        public InkPresenter _InkBoard = null;
160
        Stroke stroke;
161
        Boolean IsDrawing = false;
162
        StylusPointCollection strokePoints;
163
        //StylusPointCollection erasePoints;
164
        RenderTargetBitmap canvasImage;
165
        Point Sync_Offset_Point;
166

    
167
        //강인구 테스트
168
        private Path _SelectionPath { get; set; }
169
        public Path SelectionPath
170
        {
171
            get
172
            {
173
                return _SelectionPath;
174
            }
175
            set
176
            {
177
                if (_SelectionPath != value)
178
                {
179
                    _SelectionPath = value;
180
                    RaisePropertyChanged("SelectionPath");
181

    
182
                }
183
            }
184
        }
185

    
186
        private System.Windows.Controls.Image _imageViewer { get; set; }
187
        public System.Windows.Controls.Image imageViewer
188
        {
189
            get
190
            {
191
                if (_imageViewer == null)
192
                {
193
                    _imageViewer = new System.Windows.Controls.Image();
194
                    return _imageViewer;
195
                }
196
                else
197
                {
198
                    return _imageViewer;
199
                }
200
            }
201
            set
202
            {
203
                if (_imageViewer != value)
204
                {
205
                    _imageViewer = value;
206
                }
207
            }
208
        }
209

    
210
        public bool IsSyncPDFMode { get; set; }
211

    
212
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
213
        public System.Windows.Controls.Image imageViewer_Compare
214
        {
215
            get
216
            {
217
                if (_imageViewer_Compare == null)
218
                {
219
                    _imageViewer_Compare = new System.Windows.Controls.Image();
220
                    return _imageViewer_Compare;
221
                }
222
                else
223
                {
224
                    return _imageViewer_Compare;
225
                }
226
            }
227
            set
228
            {
229
                if (_imageViewer_Compare != value)
230
                {
231
                    _imageViewer_Compare = value;
232
                }
233
            }
234
        }
235

    
236
        #endregion
237

    
238
        public MainMenu()
239
        {
240
            //InitializeComponent();    
241
            this.Loaded += MainMenu_Loaded;
242
        }
243

    
244
        public class TempDt
245
        {
246
            public int PageNumber { get; set; }
247
            public string CommentID { get; set; }
248
            public string ConvertData { get; set; }
249
            public int DATA_TYPE { get; set; }
250
            public string MarkupInfoID { get; set; }
251
            public int IsUpdate { get; set; }
252
        }
253

    
254
        List<TempDt> tempDtList = new List<TempDt>();
255

    
256
        private void SetCursor()
257
        {
258
            this.Cursor = cursor;
259
        }
260

    
261
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
262
        {
263
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
264
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
265
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
266
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
267
            {
268
                return true;
269
            }
270

    
271
            return false;
272
        }
273

    
274
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
275
        {
276
            if (rotate.Angle == 90 || rotate.Angle == 270)
277
            {
278
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
279
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
280
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
281
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
282
                {
283
                    return true;
284
                }
285
            }
286
            else
287
            {
288
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
289
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
290
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
291
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
292
                {
293
                    return true;
294
                }
295
            }
296

    
297
            return false;
298
        }
299

    
300

    
301
        public void DeleteItem(MarkupInfoItem item)
302
        {
303
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
304
            {
305
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
306
            }
307

    
308
            ViewerDataModel.Instance._markupInfoList.Remove(item);
309

    
310
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
311
            {
312
                ViewerDataModel.Instance.MarkupControls.Remove(a);
313
            });
314

    
315
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
316
            {
317
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
318
            });
319

    
320
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
321
            {
322
                ComingNewBieEnd = false;
323
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
324
                //임시파일에서도 삭제
325
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
326
            });
327

    
328
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
329

    
330
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
331
            {
332
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
333
                {
334
                    var infoId = Commons.shortGuid();
335
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
336
                    {
337
                        CreateTime = DateTime.Now,
338
                        Depatment = userData.DEPARTMENT,
339
                        UpdateTime = DateTime.Now,
340
                        DisplayColor = "#FFFF0000",
341
                        UserID = userData.ID,
342
                        UserName = userData.NAME,
343
                        PageCount = 1,
344
                        Description = "",
345
                        MarkupInfoID = infoId,
346
                        MarkupList = null,
347
                        MarkupVersionID = Commons.shortGuid(),
348
                        Consolidate = 0,
349
                        PartConsolidate = 0,
350
                        userDelete = true,
351
                        AvoidConsolidate = 0,
352
                        IsPreviewUser = true
353
                    };
354
                    App.Custom_ViewInfoId = infoId;
355
                }
356
            }
357
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
358
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
359
        }
360

    
361
        /// <summary>
362
        /// delete selected comments
363
        /// </summary>
364
        /// <param name="sender"></param>
365
        /// <param name="e"></param>
366
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
367
        {
368
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
369
            SelectionSet.Instance.UnSelect(this);
370

    
371
            Button content = (sender as Button);
372
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
373

    
374
            DeleteItem(item);
375
        }
376

    
377
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
378

    
379
        private static Timer timer;
380
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
381
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
382
        {
383
            InitializeComponent();
384
            
385
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
386

    
387
            if (App.ParameterMode)
388
            {
389
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
390
                imageViewer_Compare = new Image();
391
                ViewerDataModel.Instance.Capture_Opacity = 0;
392
                da.From = 0.8;
393
                da.To = 0;
394
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
395
                da.AutoReverse = true;
396
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
397

    
398
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
399
                {
400
                    this.SymbolPane.Visibility = Visibility.Collapsed;
401
                    this.FavoritePane.Visibility = Visibility.Collapsed;
402
                    this.drawingRotateCanvas.IsHitTestVisible = false;
403
                }
404
            }
405
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
406
        }
407

    
408
        private void timercallback(Object o)
409
        {
410
            Stopwatch sw = new Stopwatch();
411
            sw.Start();
412
            TempFile.TempFileAdd();
413
            sw.Stop();
414

    
415
            Dispatcher.InvokeAsync(new Action(delegate
416
            {
417
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
418
                {
419
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
420
                }
421
            }));
422

    
423
            ////GC.Collect();
424
        }
425
        
426
        /// <summary>
427
        /// update my markuplist
428
        ///  - update existing markup data if already exist
429
        ///  - add new markup data if control is new
430
        /// </summary>
431
        public void UpdateMyMarkupList()
432
        {
433
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
434
            bool isComingNewBie = false;
435

    
436
            /// add or update markup list
437
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
438
            {
439
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
440

    
441
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
442
                if (exist != null) //신규 추가 된 코멘트
443
                {
444
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
445
                    {
446
                        exist.Data = root.ConvertData;
447
                        exist.IsUpdate = true;
448
                        ComingNewBieEnd = false;
449
                    }
450
                }
451
                else if (root.CommentID != null)
452
                {
453
                    isComingNewBie = true;
454
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
455
                    {
456
                        ID = control.CommentID,
457
                        Data = root.ConvertData,
458
                        Data_Type = root.DATA_TYPE,
459
                        MarkupInfoID = App.Custom_ViewInfoId,
460
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
461
                        Symbol_ID = control.SymbolID,
462
                        //Group_ID = control.GroupID,
463
                    });
464
                    ComingNewBieEnd = false;
465
                }
466
            }
467

    
468
            /// delete markup list
469
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
470
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
471
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
472
                          select markup).ToList();
473
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
474
            /// up to here
475

    
476
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
477
            {
478
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
479
                {
480
                    ComingNewBieEnd = true;
481
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
482
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
483
                    gridViewMarkup.ItemsSource = null;
484
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
485
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
486

    
487
                    GroupDescriptor descriptor = new GroupDescriptor();
488
                    descriptor.Member = "Depatment";
489
                    descriptor.DisplayContent = "DEPT";
490
                    descriptor.SortDirection = ListSortDirection.Ascending;
491
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
492
                }
493
            }
494
        }
495

    
496
        bool ComingNewBieEnd = false;
497

    
498
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
499
        {
500
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
501
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
502
            {
503
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
504
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
505
            }
506
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
507
            ViewerDataModel.Instance.UndoDataList.Clear();
508

    
509
            InkControl_Convert();
510

    
511
            SelectionSet.Instance.UnSelect(this);
512
            UpdateMyMarkupList();
513

    
514
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
515
            CompareMode.IsChecked = false;
516
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
517

    
518

    
519
            #region 페이지가 벗어난 경우
520

    
521
            if (BalancePoint < 1)
522
            {
523
                BalancePoint = 1;
524
                ViewerDataModel.Instance.PageBalanceNumber = 0;
525
            }
526

    
527
            if (pageNavigator.PageCount < BalancePoint)
528
            {
529
                BalancePoint = pageNavigator.PageCount;
530
                ViewerDataModel.Instance.PageBalanceNumber = 0;
531
            }
532

    
533
            #endregion
534

    
535
            ViewerDataModel.Instance.PageNumber = BalancePoint;
536

    
537
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
538
            string uri = "";
539
            if (userData.COMPANY != "EXT")
540
            {
541
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
542
            }
543
            else
544
            {
545
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
546
            }
547

    
548
            var defaultBitmapImage = new BitmapImage();
549
            defaultBitmapImage.BeginInit();
550
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
551
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
552
            defaultBitmapImage.UriSource = new Uri(uri);
553
            defaultBitmapImage.EndInit();
554

    
555
            ViewerDataModel.Instance.ImageViewPath = null;
556
            GC.Collect();
557

    
558
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
559
            if (defaultBitmapImage.IsDownloading)
560
            {
561
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
562
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
563
                {
564
                    defaultBitmapImage.Freeze();
565
                    mainPanel.UpdateLayout();
566
                    GC.Collect();
567
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
568
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
569
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
570
                };
571
            }
572

    
573
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
574
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
575

    
576

    
577
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
578
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
579
            inkBoard.Width = zoomAndPanCanvas.Width;
580
            inkBoard.Height = zoomAndPanCanvas.Height;
581

    
582

    
583

    
584
            if (!testPanel2.IsHidden)
585
            {
586
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
587
                //PDF모드일때 잠시 대기(강인구)
588
                if (IsSyncPDFMode)
589
                {
590
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
591
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
592

    
593
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
594
                    if (pdfpath.IsDownloading)
595
                    {
596
                        pdfpath.DownloadCompleted += (ex, arg) =>
597
                        {
598
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
599
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
600
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
601
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
602
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
603
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
604
                        };
605
                    }
606
                    else
607
                    {
608
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
609
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
610
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
611
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
612

    
613
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
614
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
615
                    }
616
                }
617
                else
618
                {
619
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
620
                    string uri2 = "";
621
                    if (userData.COMPANY != "EXT")
622
                    {
623
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
624
                    }
625
                    else
626
                    {
627
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
628
                    }
629

    
630
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
631
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
632

    
633
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
634
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
635
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
636
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
637
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
638
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
639

    
640
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
641
                    zoomAndPanControl.ZoomTo(new Rect
642
                    {
643
                        X = 0,
644
                        Y = 0,
645
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
646
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
647
                    });
648

    
649
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
650
                    if (defaultBitmapImage_Compare.IsDownloading)
651
                    {
652
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
653
                        {
654
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
655
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
656
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
657
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
658

    
659
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
660
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
661

    
662
                            zoomAndPanControl.ZoomTo(new Rect
663
                            {
664
                                X = 0,
665
                                Y = 0,
666
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
667
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
668
                            });
669
                        };
670
                    }
671
                }
672
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
673
            }
674

    
675
            this.pageNavigator.SetNextPage();
676

    
677
            if (zoomAndPanCanvas2.Width.IsNaN())
678
            {
679
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
680
            }
681

    
682
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
683
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
684
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
685

    
686
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
687
            foreach (var info in gridSelectionItem)
688
            {
689
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
690
            }
691
            /// fire selection event
692
            this.gridViewMarkup.UnselectAll();
693
            this.gridViewMarkup.Select(gridSelectionItem);
694

    
695
            if (!testPanel2.IsHidden)
696
            {
697
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
698
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
699
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
700

    
701
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
702
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
703

    
704

    
705
                foreach (var item in gridSelectionRevItem)
706
                {
707
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
708
                    {
709
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
710
                    });
711
                }
712
            }
713

    
714
            var instanceMain = this.ParentOfType<MainWindow>();
715
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
716
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
717

    
718
            instanceMain.dzTopMenu.rotateOffSet = 0;
719
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
720
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
721

    
722
            //}
723
            SetCommentPages(true);
724
        }
725

    
726

    
727
        
728

    
729
        private void SetCommentPages(bool onlyMe = false)
730
        {
731
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
732
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
733
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
734
            {
735
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
736
                instance.UserName = item.UserName;
737
                instance.Depart = item.Depatment;
738
                instance.MarkupInfoID = item.MarkupInfoID;
739
                instance.IsSelected = true;
740
                instance.isConSolidation = item.Consolidate;
741
                instance.SetColor = item.DisplayColor;
742
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
743
                {
744
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
745
                }
746
                else
747
                {
748
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
749
                }
750
                _pages.Add(instance);
751
            }
752
            this.pageNavigator.SetCommentList(_pages.ToList());
753
        }
754

    
755
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
756
        {
757
            if (e.MiddleButton == MouseButtonState.Pressed)
758
            {
759

    
760
            }
761
            e.Handled = true;
762
            if (e.Delta > 0)
763
            {
764
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
765
                ZoomIn(currentContentMousePoint);
766
            }
767
            else
768
            {
769
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
770
                ZoomOut(currentContentMousePoint);
771
            }
772
        }
773

    
774
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
775
        {
776
            e.Handled = true;
777
            if (e.Delta > 0)
778
            {
779
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
780
                ZoomIn_Sync(currentContentMousePoint);
781
            }
782
            else
783
            {
784
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
785
                ZoomOut_Sync(currentContentMousePoint);
786
            }
787
        }
788

    
789
        #region ZoomIn & ZoomOut
790

    
791
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
792
        {
793
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
794
                zoomAndPanControl.ContentZoomFocusY));
795
        }
796

    
797
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
798
        {
799
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
800
                zoomAndPanControl.ContentZoomFocusY));
801
        }
802

    
803

    
804
        //강인구 추가 (줌 인아웃 수치 변경)
805
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
806
        private void ZoomOut(Point contentZoomCenter)
807
        {
808
            if (zoomAndPanControl.ContentScale > 0.39)
809
            {
810
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
811
            }
812
            else
813
            {
814
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
815
            }
816

    
817
            if (zoomAndPanControl2 != null && Sync.IsChecked)
818
            {
819
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
820
            }
821
        }
822

    
823
        private void ZoomIn(Point contentZoomCenter)
824
        {
825
            if (zoomAndPanControl.ContentScale > 0.19)
826
            {
827
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
828
            }
829
            else
830
            {
831
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
832
            }
833

    
834
            if (zoomAndPanControl2 != null && Sync.IsChecked)
835
            {
836
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
837
            }
838

    
839
        }
840

    
841
        private void ZoomOut_Sync(Point contentZoomCenter)
842
        {
843
            if (zoomAndPanControl2.ContentScale > 0.39)
844
            {
845
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
846
            }
847
            else
848
            {
849
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
850
            }
851

    
852
            if (Sync.IsChecked)
853
            {
854
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
855
            }
856
        }
857

    
858
        private void ZoomIn_Sync(Point contentZoomCenter)
859
        {
860
            if (zoomAndPanControl2.ContentScale > 0.19)
861
            {
862
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
863
            }
864
            else
865
            {
866
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
867
            }
868

    
869
            if (Sync.IsChecked)
870
            {
871
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
872
            }
873
        }
874

    
875
        private void ZoomOut()
876
        {
877
            zoomAndPanControl.ContentScale -= 0.1;
878
            //if (zoomAndPanControl2 != null)
879
            //{
880
            //    zoomAndPanControl2.ContentScale -= 0.1;
881
            //}
882
        }
883

    
884
        private void ZoomIn()
885
        {
886
            zoomAndPanControl.ContentScale += 0.1;
887
            //if (zoomAndPanControl2 != null)
888
            //{
889
            //    zoomAndPanControl2.ContentScale += 0.1;
890
            //}
891
        }
892

    
893
        #endregion
894

    
895
        private void init()
896
        {
897
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
898
            {
899

    
900
                ControlList.Clear();
901
                listBox.Items.Clear();
902
                selected_item.Clear();
903

    
904
                (item as IMarkupCommonData).IsSelected = false;
905
            }
906

    
907
        }
908

    
909
        private HitTestResultBehavior MyCallback(HitTestResult result)
910
        {
911
            //this.cursor = Cursors.UpArrow;
912
            var element = result.VisualHit;
913
            while (element != null && !(element is CommentUserInfo))
914
                element = VisualTreeHelper.GetParent(element);
915

    
916
            if (element == null)
917
            {
918
                return HitTestResultBehavior.Stop;
919
            }
920
            else
921
            {
922
                if (element is CommentUserInfo)
923
                {
924
                    if (!hitList.Contains(element))
925
                    {
926
                        hitList.Add((CommentUserInfo)element);
927
                    }
928
                    else
929
                    {
930
                        return HitTestResultBehavior.Stop;
931
                    }
932
                }
933
            }
934
            return HitTestResultBehavior.Continue;
935
        }
936

    
937
        public void ReleaseSelectPath()
938
        {
939
            if (SelectionPath == null)
940
            {
941
                SelectionPath = new Path();
942
                SelectionPath.Name = "";
943
            }
944
            if (SelectionPath.Name != "")
945
            {
946
                SelectionPath.Name = "None";
947
            }
948
            SelectionPath.Opacity = 0.01;
949
            SelectionPath.RenderTransform = null;
950
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
951
        }
952

    
953
        #region 컨트롤 초기화 
954
        public void Control_Init(object control)
955
        {
956
            if (L_Size != 0 && (control as IPath) != null)
957
            {
958
                (control as IPath).LineSize = L_Size;
959
                L_Size = 0;
960
            }
961

    
962
            switch (control.GetType().Name)
963
            {
964
                case "RectangleControl":
965
                    {
966
                        (control as RectangleControl).StrokeColor = Brushes.Red;
967
                    }
968
                    break;
969
                case "CircleControl":
970
                    {
971
                        (control as CircleControl).StrokeColor = Brushes.Red;
972
                    }
973
                    break;
974
                case "TriControl":
975
                    {
976
                        (control as TriControl).StrokeColor = Brushes.Red;
977
                    }
978
                    break;
979
                case "RectCloudControl":
980
                    {
981
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
982
                    }
983
                    break;
984
                case "CloudControl":
985
                    {
986
                        (control as CloudControl).StrokeColor = Brushes.Red;
987
                    }
988
                    break;
989
                case "PolygonControl":
990
                    {
991
                        (control as PolygonControl).StrokeColor = Brushes.Red;
992
                    }
993
                    break;
994
                case "ArcControl":
995
                    {
996
                        (control as ArcControl).StrokeColor = Brushes.Red;
997
                    }
998
                    break;
999
                case "ArrowArcControl":
1000
                    {
1001
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1002
                    }
1003
                    break;
1004
                case "LineControl":
1005
                    {
1006
                        (control as LineControl).StrokeColor = Brushes.Red;
1007
                    }
1008
                    break;
1009
                case "ArrowControl_Multi":
1010
                    {
1011
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1012
                    }
1013
                    break;
1014
                case "TextControl":
1015
                    {
1016
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1017
                    }
1018
                    break;
1019
                case "ArrowTextControl":
1020
                    {
1021
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1022
                    }
1023
                    break;
1024
                case "InsideWhiteControl":
1025
                    {
1026
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1027
                    }
1028
                    break;
1029
                case "OverlapWhiteControl":
1030
                    {
1031
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1032
                    }
1033
                    break;
1034
                case "ClipWhiteControl":
1035
                    {
1036
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1037
                    }
1038
                    break;
1039
                case "CoordinateControl":
1040
                    {
1041
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1042
                    }
1043
                    break;
1044
            }
1045
        }
1046
        #endregion
1047

    
1048
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1049
        {
1050
            //Control_Init(e.Source);
1051
        }
1052
        private Window _dragdropWindow = null;
1053

    
1054
        [DllImport("user32.dll")]
1055
        [return: MarshalAs(UnmanagedType.Bool)]
1056
        internal static extern bool GetCursorPos(ref Win32Point pt);
1057

    
1058
        [StructLayout(LayoutKind.Sequential)]
1059
        internal struct Win32Point
1060
        {
1061
            public Int32 X;
1062
            public Int32 Y;
1063
        };
1064
        public string symbol_id = null;
1065
        public long symbol_group_id;
1066
        public int symbol_SelectedIndex;
1067
        public ImageSource symbol_img;
1068
        public string symbol_Data = null;
1069
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1070
        {
1071
            if (this._dragdropWindow != null)
1072
            {
1073
                this._dragdropWindow.Close();
1074
                this._dragdropWindow = null;
1075
            }
1076

    
1077
            symbol_id = id;
1078
            symbol_group_id = group_id;
1079
            symbol_SelectedIndex = SelectedIndex;
1080
            symbol_Data = Data_;
1081
            symbol_img = img;
1082

    
1083
      
1084
            CreateDragDropWindow2(img);
1085
        }
1086

    
1087
        private void CreateDragDropWindow2(ImageSource image)
1088
        {
1089
            this._dragdropWindow = new Window();
1090
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1091
            _dragdropWindow.WindowStyle = WindowStyle.None;
1092
            _dragdropWindow.AllowsTransparency = true;           
1093
            _dragdropWindow.AllowDrop = false;
1094
            _dragdropWindow.Background = null;
1095
            _dragdropWindow.IsHitTestVisible = false;
1096
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1097
            _dragdropWindow.Topmost = true;
1098
            _dragdropWindow.ShowInTaskbar = false;
1099
            
1100
            Rectangle r = new Rectangle();
1101
            r.Width = image.Width;
1102
            r.Height = image.Height;
1103
            r.Opacity = 0.5;            
1104
            r.Fill = new ImageBrush(image);
1105
            this._dragdropWindow.Content = r;
1106

    
1107
            Win32Point w32Mouse = new Win32Point();
1108
            GetCursorPos(ref w32Mouse);
1109

    
1110
            //w32Mouse.X = getCurrentPoint.X;
1111
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1112
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1113
            this._dragdropWindow.Show();
1114
        }
1115

    
1116
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1117
        {
1118
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1119
            {
1120
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1121

    
1122
                Point currentPos = e.GetPosition(rect);
1123

    
1124
                floatingTip.HorizontalOffset = currentPos.X + 20;
1125
                floatingTip.VerticalOffset = currentPos.Y;
1126
            }
1127

    
1128
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1129
            
1130
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1131
            {
1132
                SetCursor();
1133
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1134
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1135

    
1136
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1137
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1138
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1139

    
1140
                if (Sync.IsChecked)
1141
                {
1142
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1143
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1144
                }
1145
            }
1146

    
1147
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1148
            {
1149
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1150
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1151
                SetCursor();
1152

    
1153
                if (currentControl != null)
1154
                {
1155
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1156
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1157
                    //강인구 추가
1158
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1159

    
1160
                    if ((currentControl as IPath) != null)
1161
                    {
1162
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1163
                    }
1164
                    if ((currentControl as LineControl) != null)
1165
                    {
1166
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1167
                    }
1168

    
1169
                    if ((currentControl as IShapeControl) != null)
1170
                    {
1171
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1172
                    }
1173
                    if ((currentControl as TextControl) != null)
1174
                    {
1175
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1176
                        {
1177
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1178
                        }
1179
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1180
                        {
1181
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1182
                        }
1183
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1184
                        {
1185
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1186
                        }
1187
                    }
1188
                    else if ((currentControl as ArrowTextControl) != null)
1189
                    {
1190
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1191
                        {
1192
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1193
                        }
1194
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1195
                        {
1196
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1197
                        }
1198
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1199
                        {
1200
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1201
                        }
1202
                    }
1203
                    else if ((currentControl as RectCloudControl) != null)
1204
                    {
1205
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1206
                    }
1207
                    else if ((currentControl as CloudControl) != null)
1208
                    {
1209
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1210
                    }
1211

    
1212
                    switch (controlType)
1213
                    {
1214
                        case (ControlType.Coordinate):
1215
                            {
1216
                                var control = currentControl as CoordinateControl;
1217
                                if (control != null)
1218
                                {
1219
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1220
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1221
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1222
                                }
1223
                            }
1224
                            break;
1225
                        case (ControlType.InsideWhite):
1226
                            {
1227
                                var control = currentControl as InsideWhiteControl;
1228
                                if (control != null)
1229
                                {
1230
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1231
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1232
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1233
                                    control.Paint = PaintSet.Fill;
1234
                                }
1235
                            }
1236
                            break;
1237
                        case ControlType.OverlapWhite:
1238
                            {
1239
                                var control = currentControl as OverlapWhiteControl;
1240
                                if (control != null)
1241
                                {
1242
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1243
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1244
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1245
                                    control.Paint = PaintSet.Fill;
1246
                                }
1247
                            }
1248
                            break;
1249
                        case ControlType.ClipWhite:
1250
                            {
1251
                                var control = currentControl as ClipWhiteControl;
1252
                                if (control != null)
1253
                                {
1254
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1255
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1256
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1257
                                    control.Paint = PaintSet.Fill;
1258
                                }
1259
                            }
1260
                            break;
1261
                        case ControlType.RectCloud:
1262
                            {
1263
                                var control = currentControl as RectCloudControl;
1264
                                if (control != null)
1265
                                {
1266
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1267
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1268
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1269
                                }
1270
                            }
1271
                            break;
1272
                        case ControlType.SingleLine:
1273
                        case ControlType.CancelLine:
1274
                        case ControlType.ArrowLine:
1275
                        case ControlType.TwinLine:
1276
                        case ControlType.DimLine:
1277
                            {
1278
                                var control = currentControl as LineControl;
1279
                                if (control != null)
1280
                                {
1281
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1282
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1283
                                }
1284
                            }
1285
                            break;
1286

    
1287
                        case ControlType.ArcLine:
1288
                            {
1289
                                var control = currentControl as ArcControl;
1290
                                if (control != null)
1291
                                {
1292
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1293
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1294
                                }
1295
                            }
1296
                            break;
1297

    
1298
                        case ControlType.ArcArrow:
1299
                            {
1300
                                var control = currentControl as ArrowArcControl;
1301
                                if (control != null)
1302
                                {
1303
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1304
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1305
                                }
1306
                            }
1307
                            break;
1308

    
1309
                        case ControlType.ArrowMultiLine:
1310
                            {
1311
                                var control = currentControl as ArrowControl_Multi;
1312
                                if (control != null)
1313
                                {
1314
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1315
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1316
                                }
1317
                            }
1318
                            break;
1319

    
1320
                        case ControlType.Circle:
1321
                            {
1322
                                if (currentControl != null)
1323
                                {
1324
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1325
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1326
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1327
                                }
1328
                            }
1329
                            break;
1330

    
1331
                        case ControlType.PolygonCloud:
1332
                            {
1333
                                var control = currentControl as CloudControl;
1334
                                if (control != null)
1335
                                {
1336
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1337
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1338
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1339
                                }
1340
                            }
1341
                            break;
1342

    
1343
                        case ControlType.Triangle:
1344
                            {
1345
                                var control = currentControl as TriControl;
1346
                                if (control != null)
1347
                                {
1348
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1349
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1350
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1351
                                }
1352
                            }
1353
                            break;
1354

    
1355
                        case ControlType.ImgControl:
1356
                            {
1357
                                var control = currentControl as ImgControl;
1358
                                if (control != null)
1359
                                {
1360
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1361
                                }
1362
                            }
1363
                            break;
1364

    
1365
                        case ControlType.Date:
1366
                            {
1367
                                var control = currentControl as DateControl;
1368
                                if (control != null)
1369
                                {
1370
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1371
                                }
1372
                            }
1373
                            break;
1374

    
1375
                        case ControlType.ArrowTextControl:
1376
                        case ControlType.ArrowTransTextControl:
1377
                        case ControlType.ArrowTextBorderControl:
1378
                        case ControlType.ArrowTransTextBorderControl:
1379
                        case ControlType.ArrowTextCloudControl:
1380
                        case ControlType.ArrowTransTextCloudControl:
1381
                            {
1382
                                var control = currentControl as ArrowTextControl;
1383
                                if (control != null)
1384
                                {
1385
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1386
                                }
1387
                            }
1388
                            break;
1389
                        case ControlType.PolygonControl:
1390
                        case ControlType.ChainLine:
1391
                            {
1392
                                var control = currentControl as PolygonControl;
1393
                                if (control != null)
1394
                                {
1395
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1396
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1397
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1398
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1399
                                }
1400
                            }
1401
                            break;
1402
                        case ControlType.Sign:
1403
                            {
1404
                                var control = currentControl as SignControl;
1405
                                if (control != null)
1406
                                {
1407
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1408
                                }
1409
                            }
1410
                            break;
1411
                        case ControlType.Symbol:
1412
                            {
1413
                                var control = currentControl as SymControl;
1414
                                if (control != null)
1415
                                {
1416
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1417
                                }
1418
                            }
1419
                            break;
1420
                        case ControlType.Stamp:
1421
                            {
1422
                                var control = currentControl as SymControlN;
1423
                                if (control != null)
1424
                                {
1425
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1426
                                }
1427
                            }
1428
                            break;
1429
                        case ControlType.Rectangle:
1430
                        case ControlType.Mark:
1431
                            {
1432
                                var control = currentControl as RectangleControl;
1433
                                if (control != null)
1434
                                {
1435
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1436
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1437
                                }
1438
                            }
1439
                            break;
1440
                        case ControlType.PenControl:
1441
                            {
1442
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1443
                                //inkBoard.Strokes.Add(stroke);
1444
                            }
1445
                            break;
1446
                        default:
1447
                            break;
1448
                    }
1449
                }
1450
            }
1451
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1452
            {
1453
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1454
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1455
                SetCursor();
1456
                if (currentControl == null)
1457
                {
1458
                    switch (controlType)
1459
                    {
1460
                        case ControlType.PenControl:
1461
                            {
1462
                                if (inkBoard.Tag.ToString() == "Ink")
1463
                                {
1464
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1465
                                }
1466
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1467
                                {
1468
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1469
                                }
1470
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1471
                                {
1472
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1473
                                }
1474

    
1475
                                //inkBoard.Strokes.Add(stroke);
1476
                            }
1477
                            break;
1478
                    }
1479
                    return;
1480
                }
1481
            }
1482
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1483
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1484
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1485
            {
1486
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1487

    
1488
                if (isDraggingSelectionRect)
1489
                {
1490
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1491
                    e.Handled = true;
1492
                }
1493
                else if (isLeftMouseButtonDownOnWindow)
1494
                {
1495
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1496
                    double dragDistance = Math.Abs(dragDelta.Length);
1497

    
1498
                    if (dragDistance > DragThreshold)
1499
                    {
1500
                        isDraggingSelectionRect = true;
1501
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1502
                    }
1503

    
1504
                    e.Handled = true;
1505
                }
1506

    
1507
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1508
                {
1509
                }
1510
                else
1511
                {
1512
                    e.Handled = true;
1513
                }
1514
            }
1515
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1516
            { //symbol      
1517
                if(_dragdropWindow != null)
1518
                {
1519
                    Win32Point w32Mouse = new Win32Point();
1520
                    GetCursorPos(ref w32Mouse);
1521

    
1522
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1523
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1524
                }                
1525
            }
1526
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1527
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1528
            {
1529
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1530
                if(control != null)
1531
                {
1532
                    this.cursor = Cursors.Hand;
1533
                    SetCursor();
1534
                }
1535
                else
1536
                {
1537
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1538
                    SetCursor();
1539
                }
1540
            }
1541
            else
1542
            {
1543
            }
1544
        }
1545

    
1546
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1547
        {
1548
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1549
            {
1550
                SetCursor();
1551
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1552
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1553

    
1554
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1555

    
1556
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1557
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1558

    
1559
                if (Sync.IsChecked)
1560
                {
1561
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1562
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1563
                }
1564
            }
1565
        }
1566

    
1567
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1568

    
1569
        private EllipseGeometry hitArea = new EllipseGeometry();
1570

    
1571
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1572
        {
1573
            IsDrawing = false;
1574

    
1575
            if (mouseHandlingMode != MouseHandlingMode.None)
1576
            {
1577
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1578
                {
1579
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1580

    
1581
                    SetCursor();
1582

    
1583
                    switch (controlType)
1584
                    {
1585
                        case ControlType.None:
1586
                            break;
1587
                        case ControlType.Rectangle:
1588
                            {
1589

    
1590
                            }
1591
                            break;
1592
                        case ControlType.PenControl:
1593
                            {
1594

    
1595
                            }
1596
                            break;
1597
                        default:
1598
                            break;
1599
                    }
1600
                }
1601
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1602
                {
1603
                    if (isLeftMouseButtonDownOnWindow)
1604
                    {
1605
                        bool wasDragSelectionApplied = false;
1606

    
1607
                        if (isDraggingSelectionRect)
1608
                        {
1609
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1610
                            {
1611
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1612
                                mouseHandlingMode = MouseHandlingMode.None;
1613
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1614
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1615
                                Set_Symbol_Capture(endPoint);
1616
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1617
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1618
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1619
                            }
1620
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1621
                            {
1622
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1623
                                mouseHandlingMode = MouseHandlingMode.None;
1624
                                Set_Capture();
1625

    
1626
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1627
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1628
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1629
                            }
1630
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1631
                            {
1632
                                ApplyDragSelectionRect();
1633
                            }
1634
                            else
1635
                            {
1636
                                double x = Canvas.GetLeft(dragZoomBorder);
1637
                                double y = Canvas.GetTop(dragZoomBorder);
1638
                                double width = dragZoomBorder.Width;
1639
                                double height = dragZoomBorder.Height;
1640
                                Rect dragRect = new Rect(x, y, width, height);
1641

    
1642
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1643

    
1644
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1645
                            }
1646

    
1647
                            isDraggingSelectionRect = false;
1648
                            e.Handled = true;
1649
                            wasDragSelectionApplied = true;
1650
                        }
1651

    
1652
                        if (isLeftMouseButtonDownOnWindow)
1653
                        {
1654
                            isLeftMouseButtonDownOnWindow = false;
1655
                            this.ReleaseMouseCapture();
1656
                            e.Handled = true;
1657
                        }
1658

    
1659
                        if (!wasDragSelectionApplied)
1660
                        {
1661
                            init();
1662
                        }
1663
                    }
1664
                }
1665
                else if (e.RightButton == MouseButtonState.Pressed)
1666
                {
1667
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1668
                    SetCursor();
1669
                }
1670

    
1671
                zoomAndPanControl.ReleaseMouseCapture();
1672

    
1673

    
1674
                e.Handled = true;
1675
            }
1676
            else
1677
            {
1678
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1679
                SetCursor();
1680
            }
1681

    
1682
            ///mouseButtonDown = MouseButton.Left;
1683
            //controlType = ControlType.SingleLine;
1684
        }
1685

    
1686
        public void Set_Symbol_Capture(Point endPoint)
1687
        {       
1688
            double x = canvasDrawingMouseDownPoint.X;
1689
            double y = canvasDrawingMouseDownPoint.Y;
1690
            if(x > endPoint.X)
1691
            {
1692
                x = endPoint.X;
1693
                y = endPoint.Y;
1694
            }
1695

    
1696
            double width = dragCaptureBorder.Width;
1697
            double height = dragCaptureBorder.Height;
1698

    
1699
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1700

    
1701
            if (x < 0)
1702
            {
1703
                width += x;
1704
                x = 0;
1705
            }
1706
            if (y < 0)
1707
            {
1708
                height += y;
1709
                y = 0;
1710

    
1711
                width = (int)canvasImage.PixelWidth - x;
1712
            }
1713
            if (x + width > canvasImage.PixelWidth)
1714
            {
1715
                width = (int)canvasImage.PixelWidth - x;
1716
            }
1717
            if (y + height > canvasImage.PixelHeight)
1718
            {
1719
                height = (int)canvasImage.PixelHeight - y;
1720
            }
1721
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1722

    
1723
            string uri = "";
1724
            if (userData.COMPANY != "EXT")
1725
            {
1726
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1727
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1728
            }
1729
            else
1730
            {
1731
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1732
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1733
            }
1734

    
1735
            var defaultBitmapImage = new BitmapImage();
1736
            defaultBitmapImage.BeginInit();
1737
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1738
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1739
            defaultBitmapImage.UriSource = new Uri(uri);
1740
            defaultBitmapImage.EndInit();
1741

    
1742
            //GC.Collect();
1743

    
1744
            if (defaultBitmapImage.IsDownloading)
1745
            {
1746
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1747
                {
1748
                    defaultBitmapImage.Freeze();
1749
                    //GC.Collect();
1750
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1751
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1752
                };
1753
            }
1754
        }
1755

    
1756
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1757
        {
1758
            ///mouseButtonDown = MouseButton.Left;
1759
        }
1760

    
1761
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1762
        {
1763
            ///mouseButtonDown = MouseButton.Left;
1764
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1765
        }
1766

    
1767
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1768
        {
1769

    
1770
        }
1771

    
1772
        /// <summary>
1773
        /// select items by dragging
1774
        /// </summary>
1775
        private void ApplyDragSelectionRect()
1776
        {
1777
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1778

    
1779
            double x = Canvas.GetLeft(dragSelectionBorder);
1780
            double y = Canvas.GetTop(dragSelectionBorder);
1781
            double width = dragSelectionBorder.Width;
1782
            double height = dragSelectionBorder.Height;
1783
            Boolean Flag = false;
1784
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1785
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1786

    
1787
            Rect dragRect = new Rect(x, y, width, height);
1788
            ///dragRect.Inflate(width / 10, height / 10);
1789

    
1790
            foreach (var item in Items)
1791
            {
1792
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1793

    
1794
                if (Flag)
1795
                {
1796
                    adornerSet.Add(item);
1797
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1798
                    Control_Style(item);
1799
                }
1800
            }
1801
            if (adornerSet.Count > 0)
1802
            {
1803
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1804
                SelectLayer.Children.Add(final);
1805
            }
1806
        }
1807

    
1808
        private void InitDragSelectionRect(Point pt1, Point pt2)
1809
        {
1810
            //캡쳐 중
1811
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1812
            {
1813
                dragCaptureBorder.Visibility = Visibility.Visible;
1814
            }
1815
            //선택 중
1816
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1817
            {
1818

    
1819
                dragSelectionBorder.Visibility = Visibility.Visible;
1820
            }
1821
            else
1822
            {
1823
                dragZoomBorder.Visibility = Visibility.Visible;
1824
            }
1825
            UpdateDragSelectionRect(pt1, pt2);
1826
        }
1827

    
1828
        /// <summary>
1829
        /// Update the position and size of the rectangle used for drag selection.
1830
        /// </summary>
1831
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1832
        {
1833
            double x, y, width, height;
1834

    
1835
            //
1836
            // Determine x,y,width and height of the rect inverting the points if necessary.
1837
            // 
1838

    
1839
            if (pt2.X < pt1.X)
1840
            {
1841
                x = pt2.X;
1842
                width = pt1.X - pt2.X;
1843
            }
1844
            else
1845
            {
1846
                x = pt1.X;
1847
                width = pt2.X - pt1.X;
1848
            }
1849

    
1850
            if (pt2.Y < pt1.Y)
1851
            {
1852
                y = pt2.Y;
1853
                height = pt1.Y - pt2.Y;
1854
            }
1855
            else
1856
            {
1857
                y = pt1.Y;
1858
                height = pt2.Y - pt1.Y;
1859
            }
1860

    
1861
            //
1862
            // Update the coordinates of the rectangle used for drag selection.
1863
            //
1864
            //캡쳐 중
1865
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1866
            {
1867
                Canvas.SetLeft(dragCaptureBorder, x);
1868
                Canvas.SetTop(dragCaptureBorder, y);
1869
                dragCaptureBorder.Width = width;
1870
                dragCaptureBorder.Height = height;
1871
            }
1872
            //선택 중
1873
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1874
            {
1875
                Canvas.SetLeft(dragSelectionBorder, x);
1876
                Canvas.SetTop(dragSelectionBorder, y);
1877
                dragSelectionBorder.Width = width;
1878
                dragSelectionBorder.Height = height;
1879
            }
1880
            else
1881
            {
1882
                Canvas.SetLeft(dragZoomBorder, x);
1883
                Canvas.SetTop(dragZoomBorder, y);
1884
                dragZoomBorder.Width = width;
1885
                dragZoomBorder.Height = height;
1886
            }
1887
        }
1888

    
1889
        private void drawingPannelRotate(double angle)
1890
        {
1891
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1892
            rotate.Angle = angle;
1893
            var rotationNum = Math.Abs((rotate.Angle / 90));
1894

    
1895
            if (angle == 90 || angle == 270)
1896
            {
1897
                double emptySize = zoomAndPanCanvas.Width;
1898
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1899
                zoomAndPanCanvas.Height = emptySize;
1900
            }
1901
            if (angle == 0)
1902
            {
1903
                translate.X = 0;
1904
                translate.Y = 0;
1905
            }
1906
            else if (angle == 90)
1907
            {
1908
                translate.X = zoomAndPanCanvas.Width;
1909
                translate.Y = 0;
1910
            }
1911
            else if (angle == 180)
1912
            {
1913
                translate.X = zoomAndPanCanvas.Width;
1914
                translate.Y = zoomAndPanCanvas.Height;
1915
            }
1916
            else
1917
            {
1918
                translate.X = 0;
1919
                translate.Y = zoomAndPanCanvas.Height;
1920
            }
1921

    
1922
            zoomAndPanControl.RotationAngle = rotate.Angle;
1923

    
1924

    
1925
            if (!testPanel2.IsHidden)
1926
            {
1927
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1928
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1929
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1930
            }
1931

    
1932
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1933
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1934
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1935
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1936
            ViewerDataModel.Instance.Angle = rotate.Angle;
1937
        }
1938

    
1939
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1940
        {
1941
            string Data_ = "";
1942

    
1943
            try
1944
            {
1945
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1946
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1947
                if (Data_ != null || Data_ != "")
1948
                {
1949
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1950
                }
1951
                else
1952
                {
1953
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1954
                }
1955

    
1956
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1957
                //{
1958
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1959
                //    STATE = 0,
1960
                //};
1961
                if (Data_ != null)
1962
                {
1963
                    Image img = new Image();
1964
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1965
                    if (Data_.Contains(".svg"))
1966
                    {
1967
                        byte[] imageData = null;
1968
                        DrawingImage image = null;
1969
                        using (System.Net.WebClient web = new System.Net.WebClient())
1970
                        {
1971
                            imageData = web.DownloadData(new Uri(Data_));
1972
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1973
                            image = SvgReader.Load(stream);
1974
                        }
1975
                        img.Source = image;
1976
                    }
1977
                    else
1978
                    {
1979
                        img.Source = new BitmapImage(new Uri(Data_));
1980
                    }
1981

    
1982
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1983
                    {
1984
                        PointSet = new List<Point>(),
1985
                        FilePath = Data_,
1986
                        ImageData = img.Source,
1987
                        StartPoint = canvasZoomPanningMouseDownPoint,
1988
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
1989
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
1990
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
1991
                        canvasZoomPanningMouseDownPoint.Y),
1992
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
1993
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
1994
                    };
1995

    
1996
                    currentControl.PointSet = new List<Point>
1997
                                        {
1998
                                            currentControl.StartPoint,
1999
                                            currentControl.LeftBottomPoint,
2000
                                            currentControl.EndPoint,
2001
                                            currentControl.TopRightPoint,
2002
                                        };
2003
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2004
                    UndoData = new Undo_data()
2005
                    {
2006
                        IsUndo = false,
2007
                        Event = Event_Type.Create,
2008
                        EventTime = DateTime.Now,
2009
                        Markup_List = new List<Multi_Undo_data>()
2010
                    };
2011
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2012
                    {
2013
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2014
                    });
2015

    
2016
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2017
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2018
                    UndoData.Markup_List.Add(multi_Undo_Data);
2019
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2020

    
2021
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2022
                    currentControl.CommentID = Commons.shortGuid();
2023
                    currentControl.SymbolID = id;
2024
                    currentControl.GroupID = group_id;
2025
                    currentControl.ApplyTemplate();
2026
                    currentControl.SetImage();
2027

    
2028
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2029
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2030
                    SelectLayer.Children.Add(final);
2031
                }
2032
            }
2033
            catch (Exception ex)
2034
            {
2035
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2036
            }
2037
        }
2038

    
2039
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2040
        {            
2041
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2042
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2043
            {
2044
                set_option.Value = double.Parse(set_option.ContentText);
2045
            }
2046

    
2047
            InkControl_Convert();
2048

    
2049
            ///TODO:
2050
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2051
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2052

    
2053
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2054
            {
2055
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2056
            }
2057
            /// up to here
2058

    
2059
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2060
            {
2061
                if (arrow_text as ArrowTextControl != null)
2062
                {
2063
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2064
                }
2065
            }
2066

    
2067
            //if (currentControl != null)
2068
            {
2069
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2070
                if (text_item_ != null)
2071
                {
2072
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2073
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2074
                    (text_item_ as TextControl).IsEditing = false;
2075
                    (text_item_ as TextControl).EnableEditing = false;
2076
                    currentControl = null;
2077
                }
2078

    
2079
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2080
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2081
                {
2082
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2083
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2084
                    currentControl = null;
2085
                }
2086
            }
2087

    
2088
            double Ang = 0;                                          
2089
            if (rotate.Angle != 0)
2090
            {
2091
                Ang = 360 - rotate.Angle;
2092
            }
2093

    
2094
            if (e.OriginalSource is System.Windows.Controls.Image)
2095
            {
2096
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2097
            }
2098

    
2099
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2100
            {                
2101
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2102
                if(symbol_id != null)
2103
                {
2104
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2105
                }                
2106
            }
2107

    
2108
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2109
            {
2110
                if (this._dragdropWindow != null)
2111
                {
2112
                    this._dragdropWindow.Close();
2113
                    this._dragdropWindow = null;
2114
                    symbol_id = null;
2115
                }
2116
            }
2117

    
2118
            if (e.LeftButton == MouseButtonState.Pressed)
2119
            {
2120
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2121
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2122

    
2123
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2124
                SetCursor();
2125

    
2126
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2127
            }
2128

    
2129
            if (e.MiddleButton == MouseButtonState.Pressed)
2130
            {
2131
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2132
                cursor = Cursors.SizeAll;
2133
                SetCursor();
2134
            }
2135
            if (e.RightButton == MouseButtonState.Pressed)
2136
            {
2137
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2138
                cursor = Cursors.SizeAll;
2139
                SetCursor();
2140
            }
2141
            else if (e.XButton1 == MouseButtonState.Pressed)
2142
            {
2143
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2144
                {
2145
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2146
                }
2147

    
2148
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2149

    
2150
            }
2151
            else if (e.XButton2 == MouseButtonState.Pressed)
2152
            {
2153
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2154
                {
2155
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2156
                }
2157
            }
2158

    
2159
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2160
            {
2161
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2162
                {
2163
                    if (SelectLayer.Children.Count == 0)
2164
                    {
2165
                        isLeftMouseButtonDownOnWindow = true;
2166
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2167
                    }
2168

    
2169
                    if (controlType == ControlType.None)
2170
                    {
2171
                        isLeftMouseButtonDownOnWindow = true;
2172
                    }
2173
                }
2174

    
2175
                /// 캡쳐 모드 설정
2176
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2177
                {
2178
                    dragCaptureBorder.Visibility = Visibility.Visible;
2179
                    isLeftMouseButtonDownOnWindow = true;
2180
                }
2181

    
2182
                /// 줌 모드 설정
2183
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2184
                {
2185
                    isLeftMouseButtonDownOnWindow = true;
2186
                }
2187

    
2188
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2189
                if (control != null)
2190
                {
2191
                    AdornerFinal final = null;
2192

    
2193
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2194
                    {
2195
                        /// 기존 selection 해제
2196
                        SelectionSet.Instance.UnSelect(this);
2197

    
2198
                        final = new AdornerFinal(control);
2199

    
2200
                        this.Control_Style(control);
2201

    
2202
                        if ((control as IPath) != null)
2203
                        {
2204
                            if ((control as IPath).LineSize != 0)
2205
                            {
2206
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2207
                            }
2208
                        }
2209
                        if ((control as IShapeControl) != null)
2210
                        {
2211
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2212
                            {
2213
                                ViewerDataModel.Instance.checkHatchShape = true;
2214
                            }
2215
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2216
                            {
2217
                                ViewerDataModel.Instance.checkFillShape = true;
2218
                            }
2219
                            else
2220
                            {
2221
                                ViewerDataModel.Instance.checkHatchShape = false;
2222
                                ViewerDataModel.Instance.checkFillShape = false;
2223
                            }
2224
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2225
                        }
2226

    
2227
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2228

    
2229
                        if ((control as TextControl) != null)
2230
                        {
2231
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2232
                            {
2233
                                ViewerDataModel.Instance.checkTextStyle = true;
2234
                            }
2235
                            else
2236
                            {
2237
                                ViewerDataModel.Instance.checkTextStyle = false;
2238
                            }
2239

    
2240
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2241
                            {
2242
                                ViewerDataModel.Instance.checkTextStyle = true;
2243
                            }
2244
                            else
2245
                            {
2246
                                ViewerDataModel.Instance.checkTextStyle = false;
2247
                            }
2248
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2249
                            {
2250
                                ViewerDataModel.Instance.checkTextWeight = true;
2251
                            }
2252
                            else
2253
                            {
2254
                                ViewerDataModel.Instance.checkTextWeight = false;
2255
                            }
2256
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2257
                            {
2258
                                ViewerDataModel.Instance.checkUnderLine = true;
2259
                            }
2260
                            else
2261
                            {
2262
                                ViewerDataModel.Instance.checkUnderLine = false;
2263
                            }
2264
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2265
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2266

    
2267
                        }
2268
                        else if ((control as ArrowTextControl) != null)
2269
                        {
2270
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2271
                            {
2272
                                ViewerDataModel.Instance.checkTextStyle = true;
2273
                            }
2274
                            else
2275
                            {
2276
                                ViewerDataModel.Instance.checkTextStyle = false;
2277
                            }
2278

    
2279
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2280
                            {
2281
                                ViewerDataModel.Instance.checkTextStyle = true;
2282
                            }
2283
                            else
2284
                            {
2285
                                ViewerDataModel.Instance.checkTextStyle = false;
2286
                            }
2287
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2288
                            {
2289
                                ViewerDataModel.Instance.checkTextWeight = true;
2290
                            }
2291
                            else
2292
                            {
2293
                                ViewerDataModel.Instance.checkTextWeight = false;
2294
                            }
2295
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2296
                            {
2297
                                ViewerDataModel.Instance.checkUnderLine = true;
2298
                            }
2299
                            else
2300
                            {
2301
                                ViewerDataModel.Instance.checkUnderLine = false;
2302
                            }
2303
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2304
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2305
                        }
2306
                        else if ((control as RectCloudControl) != null)
2307
                        {
2308
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2309
                        }
2310
                        else if ((control as CloudControl) != null)
2311
                        {
2312
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2313
                        }
2314
                    }
2315
                    else
2316
                    {
2317
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2318
                        SelectionSet.Instance.UnSelect(this);
2319
                        comment.Add(control);
2320

    
2321
                        Control_Style(control);
2322

    
2323
                        final = new AdornerFinal(comment);
2324
                    }
2325

    
2326
                    if (final != null)
2327
                    {
2328
                        this.SelectLayer.Children.Add(final);
2329
                    }
2330
                }              
2331
            }
2332
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2333
            {               
2334
                init();
2335
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2336
                if (cursor != Cursors.SizeAll)
2337
                {
2338
                    cursor = Cursors.Cross;
2339
                    SetCursor();
2340
                }
2341
                bool init_user = false;
2342
                foreach (var user in gridViewMarkup.Items)
2343
                {
2344
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2345
                    {
2346
                        init_user = true;
2347
                    }
2348
                }
2349
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2350
                {
2351
                    RadWindow.Alert(new DialogParameters
2352
                    {
2353
                        Owner = Application.Current.MainWindow,
2354
                        Theme = new VisualStudio2013Theme(),
2355
                        Header = "안내",
2356
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2357
                    });
2358
                    return;
2359
                }
2360
                else
2361
                {
2362
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2363
                    if (item != null)
2364
                    {
2365
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2366
                    }
2367
                }
2368

    
2369
                switch (controlType)
2370
                {
2371
                    case ControlType.Coordinate:
2372
                        {
2373
                            if (e.LeftButton == MouseButtonState.Pressed)
2374
                            {
2375
                                if (currentControl is CoordinateControl)
2376
                                {
2377
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2378
                                    {
2379
                                        return;
2380
                                    }
2381

    
2382
                                    CreateCommand.Instance.Execute(currentControl);
2383

    
2384
                                    currentControl = null;
2385
                                    this.cursor = Cursors.Arrow;
2386
                                }
2387
                                else
2388
                                {
2389
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2390
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2391
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2392
                                    {
2393
                                        currentControl = null;
2394
                                        this.cursor = Cursors.Arrow;
2395
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2396
                                        return;
2397
                                    }
2398
                                    else
2399
                                    {
2400
                                        currentControl = new CoordinateControl
2401
                                        {
2402
                                            Background = new SolidColorBrush(Colors.Black),
2403
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2404
                                            ControlType = ControlType.Coordinate
2405
                                        };
2406

    
2407
                                        currentControl.CommentID = Commons.shortGuid();
2408
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2409
                                        currentControl.IsNew = true;
2410

    
2411
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2412

    
2413
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2414
                                    }
2415
                                }
2416
                            }
2417
                        }
2418
                        break;
2419
                    case ControlType.InsideWhite:
2420
                        {
2421
                            if (e.LeftButton == MouseButtonState.Pressed)
2422
                            {
2423
                                if (currentControl is InsideWhiteControl)
2424
                                {
2425
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2426
                                    {
2427
                                        return;
2428
                                    }
2429

    
2430
                                    CreateCommand.Instance.Execute(currentControl);
2431

    
2432
                                    currentControl = null;
2433
                                    this.cursor = Cursors.Arrow;
2434
                                }
2435
                                else
2436
                                {
2437
                                    currentControl = new InsideWhiteControl
2438
                                    {
2439
                                        Background = new SolidColorBrush(Colors.Black),
2440
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2441
                                        ControlType = ControlType.InsideWhite
2442
                                    };
2443

    
2444
                                    currentControl.CommentID = Commons.shortGuid();
2445
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2446
                                    currentControl.IsNew = true;
2447
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2448

    
2449
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2450
                                }
2451
                            }
2452
                        }
2453
                        break;
2454
                    case ControlType.OverlapWhite:
2455
                        {
2456
                            if (e.LeftButton == MouseButtonState.Pressed)
2457
                            {
2458
                                if (currentControl is OverlapWhiteControl)
2459
                                {
2460
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2461
                                    {
2462
                                        return;
2463
                                    }
2464

    
2465
                                    CreateCommand.Instance.Execute(currentControl);
2466

    
2467
                                    currentControl = null;
2468
                                    this.cursor = Cursors.Arrow;
2469
                                }
2470
                                else
2471
                                {
2472
                                    currentControl = new OverlapWhiteControl
2473
                                    {
2474
                                        Background = new SolidColorBrush(Colors.Black),
2475
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2476
                                        ControlType = ControlType.OverlapWhite
2477
                                    };
2478

    
2479
                                    currentControl.CommentID = Commons.shortGuid();
2480
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2481
                                    currentControl.IsNew = true;
2482
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2483

    
2484
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2485
                                }
2486
                            }
2487
                        }
2488
                        break;
2489
                    case ControlType.ClipWhite:
2490
                        {
2491
                            if (e.LeftButton == MouseButtonState.Pressed)
2492
                            {
2493
                                if (currentControl is ClipWhiteControl)
2494
                                {
2495
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2496
                                    {
2497
                                        return;
2498
                                    }
2499

    
2500
                                    CreateCommand.Instance.Execute(currentControl);
2501

    
2502
                                    currentControl = null;
2503
                                    this.cursor = Cursors.Arrow;
2504
                                }
2505
                                else
2506
                                {
2507
                                    currentControl = new ClipWhiteControl
2508
                                    {
2509
                                        Background = new SolidColorBrush(Colors.Black),
2510
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2511
                                        ControlType = ControlType.ClipWhite
2512
                                    };
2513

    
2514
                                    currentControl.CommentID = Commons.shortGuid();
2515
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2516
                                    currentControl.IsNew = true;
2517
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2518

    
2519
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2520
                                }
2521
                            }
2522
                        }
2523
                        break;
2524
                    case ControlType.Rectangle:
2525
                        {
2526
                            if (e.LeftButton == MouseButtonState.Pressed)
2527
                            {
2528
                                if (currentControl is RectangleControl)
2529
                                {
2530
                                    //20180906 LJY TEST IsRotationDrawingEnable
2531
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2532
                                    {
2533
                                        return;
2534
                                    }
2535

    
2536
                                    CreateCommand.Instance.Execute(currentControl);
2537
                                    currentControl = null;
2538
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2539
                                }
2540
                                else
2541
                                {
2542
                                    currentControl = new RectangleControl
2543
                                    {
2544
                                        Background = new SolidColorBrush(Colors.Black),
2545
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2546
                                        ControlType = ControlType.Rectangle
2547
                                    };
2548

    
2549
                                    currentControl.CommentID = Commons.shortGuid();
2550
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2551
                                    currentControl.IsNew = true;
2552
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2553

    
2554
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2555
                                }
2556
                            }
2557
                        }
2558
                        break;
2559
                    case ControlType.RectCloud:
2560
                        {
2561
                            if (e.LeftButton == MouseButtonState.Pressed)
2562
                            {
2563
                                if (currentControl is RectCloudControl)
2564
                                {
2565
                                    //20180906 LJY TEST IsRotationDrawingEnable
2566
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2567
                                    {
2568
                                        return;
2569
                                    }
2570

    
2571
                                    CreateCommand.Instance.Execute(currentControl);
2572

    
2573
                                    currentControl = null;
2574
                                
2575
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2576
                                }
2577
                                else
2578
                                {
2579
                                    currentControl = new RectCloudControl
2580
                                    {
2581
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2582
                                        ControlType = ControlType.RectCloud,
2583
                                        Background = new SolidColorBrush(Colors.Black)
2584
                                    };
2585

    
2586
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2587
                                    currentControl.CommentID = Commons.shortGuid();
2588
                                    currentControl.IsNew = true;
2589
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2590
                                }
2591
                            }
2592
                        }
2593
                        break;
2594
                    case ControlType.Circle:
2595
                        {
2596
                            if (e.LeftButton == MouseButtonState.Pressed)
2597
                            {
2598
                                if (currentControl is CircleControl)
2599
                                {
2600
                                    //20180906 LJY TEST IsRotationDrawingEnable
2601
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2602
                                    {
2603
                                        return;
2604
                                    }
2605

    
2606
                                    CreateCommand.Instance.Execute(currentControl);
2607

    
2608
                                    currentControl = null;
2609
                                }
2610
                                else
2611
                                {
2612
                                    currentControl = new CircleControl
2613
                                    {
2614
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2615
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2616
                                        Background = new SolidColorBrush(Colors.Black)
2617
                                    };
2618

    
2619
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2620
                                    currentControl.CommentID = Commons.shortGuid();
2621
                                    currentControl.IsNew = true;
2622
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2623
                                }
2624
                            }
2625
                        }
2626
                        break;
2627
                    case ControlType.Triangle:
2628
                        {
2629
                            if (e.LeftButton == MouseButtonState.Pressed)
2630
                            {
2631
                                if (currentControl is TriControl)
2632
                                {
2633
                                    var content = currentControl as TriControl;
2634
                                    if (content.MidPoint == new Point(0, 0))
2635
                                    {
2636
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2637
                                    }
2638
                                    else
2639
                                    {
2640
                                        //20180906 LJY TEST IsRotationDrawingEnable
2641
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2642
                                        {
2643
                                            return;
2644
                                        }
2645

    
2646
                                        CreateCommand.Instance.Execute(currentControl);
2647

    
2648
                                        currentControl = null;
2649
                                    }
2650
                                }
2651
                                else
2652
                                {
2653
                                    currentControl = new TriControl
2654
                                    {
2655
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2656
                                        Background = new SolidColorBrush(Colors.Black),
2657
                                    };
2658

    
2659
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2660
                                    currentControl.CommentID = Commons.shortGuid();
2661
                                    currentControl.IsNew = true;
2662
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2663
                                }
2664
                            }
2665
                        }
2666
                        break;
2667
                    case ControlType.CancelLine:
2668
                    case ControlType.SingleLine:
2669
                    case ControlType.ArrowLine:
2670
                    case ControlType.TwinLine:
2671
                    case ControlType.DimLine:
2672
                        {
2673
                            if (e.LeftButton == MouseButtonState.Pressed)
2674
                            {
2675
                                if (currentControl is LineControl)
2676
                                {
2677
                                    //20180906 LJY TEST IsRotationDrawingEnable
2678
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2679
                                    {
2680
                                        return;
2681
                                    }
2682

    
2683
                                    CreateCommand.Instance.Execute(currentControl);
2684
                                    currentControl = null;
2685
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2686
                                }
2687
                                else
2688
                                {
2689
                                    currentControl = new LineControl
2690
                                    {
2691
                                        ControlType = this.controlType,
2692
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2693
                                        Background = new SolidColorBrush(Colors.Black)
2694
                                    };
2695

    
2696
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2697
                                    currentControl.CommentID = Commons.shortGuid();
2698
                                    currentControl.IsNew = true;
2699
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2700
                                    this.MainAngle.Visibility = Visibility.Visible;
2701
                                }
2702
                            }
2703
                        }
2704
                        break;
2705
                    case ControlType.PolygonControl:
2706
                        {
2707
                            if (currentControl is PolygonControl)
2708
                            {
2709
                                var control = currentControl as PolygonControl;
2710

    
2711
                                if (e.RightButton == MouseButtonState.Pressed)
2712
                                {
2713
                                    control.IsCompleted = true;
2714
                                }
2715

    
2716
                                if (!control.IsCompleted)
2717
                                {
2718
                                    control.PointSet.Add(control.EndPoint);
2719
                                }
2720
                                else
2721
                                {
2722
                                    //20180906 LJY TEST IsRotationDrawingEnable
2723
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2724
                                    {
2725
                                        return;
2726
                                    }
2727

    
2728
                                    var firstPoint = control.PointSet.First();
2729
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2730
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2731
                                    control.PointSet.Add(firstPoint);
2732

    
2733
                                    control.ApplyOverViewData();
2734

    
2735
                                    CreateCommand.Instance.Execute(currentControl);
2736
                                    control.updateControl();
2737
                                    currentControl = null;
2738
                                }
2739
                            }
2740
                            else
2741
                            {
2742
                                if (e.LeftButton == MouseButtonState.Pressed)
2743
                                {
2744
                                    currentControl = new PolygonControl
2745
                                    {
2746
                                        PointSet = new List<Point>(),
2747
                                    };
2748

    
2749
                                    var polygonControl = (currentControl as PolygonControl);
2750
                                    currentControl.CommentID = Commons.shortGuid();
2751
                                    currentControl.IsNew = true;
2752
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2753
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2754
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2755
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2756
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2757
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2758
                                    polygonControl.ApplyTemplate();
2759
                                    polygonControl.Visibility = Visibility.Visible;
2760
                                }
2761
                            }
2762
                        }
2763
                        break;
2764
                    case ControlType.ChainLine:
2765
                        {
2766
                            if (currentControl is PolygonControl)
2767
                            {
2768
                                var control = currentControl as PolygonControl;
2769

    
2770
                                if (e.RightButton == MouseButtonState.Pressed)
2771
                                {
2772
                                    //20180906 LJY TEST IsRotationDrawingEnable
2773
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2774
                                    {
2775
                                        return;
2776
                                    }
2777

    
2778
                                    CreateCommand.Instance.Execute(currentControl);
2779

    
2780
                                    currentControl = null;
2781
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2782
                                    return;
2783
                                }
2784

    
2785
                                if (!control.IsCompleted)
2786
                                {
2787
                                    control.PointSet.Add(control.EndPoint);
2788
                                    this.MainAngle.Visibility = Visibility.Visible;
2789
                                }
2790
                            }
2791
                            else
2792
                            {
2793
                                if (e.LeftButton == MouseButtonState.Pressed)
2794
                                {
2795
                                    MainAngle.Visibility = Visibility.Visible;
2796
                                    currentControl = new PolygonControl
2797
                                    {
2798
                                        PointSet = new List<Point>(),
2799
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2800
                                        ControlType = ControlType.ChainLine,
2801
                                        DashSize = ViewerDataModel.Instance.DashSize,
2802
                                        LineSize = ViewerDataModel.Instance.LineSize,
2803
                                        //PointC = new StylusPointSet()
2804
                                    };
2805

    
2806
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2807
                                    //{
2808
                                        var polygonControl = (currentControl as PolygonControl);
2809
                                        currentControl.CommentID = Commons.shortGuid();
2810
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2811
                                        currentControl.IsNew = true;
2812
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2813
                                        //currentControl.OnApplyTemplate();
2814
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2815
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2816
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2817
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2818
                                    //}
2819
                                }
2820
                            }
2821
                        }
2822
                        break;
2823
                    case ControlType.ArcLine:
2824
                        {
2825
                            if (e.LeftButton == MouseButtonState.Pressed)
2826
                            {
2827
                                if (currentControl is ArcControl)
2828
                                {
2829
                                    //20180906 LJY TEST IsRotationDrawingEnable
2830
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2831
                                    {
2832
                                        return;
2833
                                    }
2834

    
2835
                                    CreateCommand.Instance.Execute(currentControl);
2836

    
2837
                                    currentControl = null;
2838
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2839
                                }
2840
                                else
2841
                                {
2842
                                    currentControl = new ArcControl
2843
                                    {
2844
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2845
                                        Background = new SolidColorBrush(Colors.Black)
2846
                                    };
2847
                                    currentControl.CommentID = Commons.shortGuid();
2848
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2849
                                    currentControl.IsNew = true;
2850
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2851
                                    this.MainAngle.Visibility = Visibility.Visible;
2852
                                }
2853
                            }
2854
                            else if (e.RightButton == MouseButtonState.Pressed)
2855
                            {
2856
                                if (currentControl != null)
2857
                                {
2858
                                    (currentControl as ArcControl).setClock();
2859
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2860
                                }
2861
                            }
2862
                        }
2863
                        break;
2864
                    case ControlType.ArcArrow:
2865
                        {
2866
                            if (e.LeftButton == MouseButtonState.Pressed)
2867
                            {
2868
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2869
                                //{
2870
                                if (currentControl is ArrowArcControl)
2871
                                {
2872
                                    //20180906 LJY TEST IsRotationDrawingEnable
2873
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2874
                                    {
2875
                                        return;
2876
                                    }
2877

    
2878
                                    CreateCommand.Instance.Execute(currentControl);
2879

    
2880
                                    currentControl = null;
2881
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2882
                                }
2883
                                else
2884
                                {
2885
                                    currentControl = new ArrowArcControl
2886
                                    {
2887
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2888
                                        Background = new SolidColorBrush(Colors.Black)
2889
                                    };
2890
                                    currentControl.CommentID = Commons.shortGuid();
2891
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2892
                                    currentControl.IsNew = true;
2893
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2894
                                    this.MainAngle.Visibility = Visibility.Visible;
2895
                                }
2896
                                //}
2897
                            }
2898
                            else if (e.RightButton == MouseButtonState.Pressed)
2899
                            {
2900
                                if (currentControl != null)
2901
                                {
2902
                                    (currentControl as ArrowArcControl).setClock();
2903
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2904
                                    //(currentControl as ArcControl).ApplyTemplate();
2905
                                }
2906
                            }
2907
                        }
2908
                        break;
2909
                    case ControlType.ArrowMultiLine:
2910
                        {
2911
                            if (e.LeftButton == MouseButtonState.Pressed)
2912
                            {
2913
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2914
                                //{
2915

    
2916
                                    if (currentControl is ArrowControl_Multi)
2917
                                    {
2918
                                        var content = currentControl as ArrowControl_Multi;
2919
                                        if (content.MiddlePoint == new Point(0, 0))
2920
                                        {
2921
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2922
                                            {
2923
                                                content.MiddlePoint = content.EndPoint;
2924
                                            }
2925
                                            else
2926
                                            {
2927
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2928
                                            }
2929
                                        }
2930
                                        else
2931
                                        {
2932
                                            //20180906 LJY TEST IsRotationDrawingEnable
2933
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2934
                                            {
2935
                                                return;
2936
                                            }
2937

    
2938
                                            CreateCommand.Instance.Execute(currentControl);
2939

    
2940
                                            currentControl = null;
2941
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2942
                                        }
2943
                                    }
2944
                                    else
2945
                                    {
2946
                                        currentControl = new ArrowControl_Multi
2947
                                        {
2948
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2949
                                            Background = new SolidColorBrush(Colors.Black)
2950
                                        };
2951
                                        currentControl.CommentID = Commons.shortGuid();
2952
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2953
                                        currentControl.IsNew = true;
2954
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2955
                                        this.MainAngle.Visibility = Visibility.Visible;
2956
                                    }
2957
                                //}
2958
                            }
2959
                        }
2960
                        break;
2961
                    case ControlType.PolygonCloud:
2962
                        {
2963
                            if (currentControl is CloudControl)
2964
                            {
2965
                                var control = currentControl as CloudControl;
2966
                                if (e.RightButton == MouseButtonState.Pressed)
2967
                                {
2968
                                    control.IsCompleted = true;
2969
                                }
2970

    
2971
                                if (!control.IsCompleted)
2972
                                {
2973
                                    control.PointSet.Add(control.EndPoint);
2974
                                }
2975
                                else
2976
                                {
2977
                                    //20180906 LJY TEST IsRotationDrawingEnable
2978
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2979
                                    {
2980
                                        return;
2981
                                    }
2982

    
2983
                                    CreateCommand.Instance.Execute(currentControl);
2984

    
2985
                                    control.isTransOn = true;
2986
                                    var firstPoint = control.PointSet.First();
2987

    
2988
                                    control.PointSet.Add(firstPoint);
2989
                                    control.DrawingCloud();
2990
                                    control.ApplyOverViewData();
2991

    
2992
                                    currentControl = null;
2993
                                }
2994
                            }
2995
                            else
2996
                            {
2997
                                if (e.LeftButton == MouseButtonState.Pressed)
2998
                                {
2999
                                    currentControl = new CloudControl
3000
                                    {
3001
                                        PointSet = new List<Point>(),
3002
                                        PointC = new StylusPointSet()
3003
                                    };
3004

    
3005
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3006
                                    //{
3007
                                        var polygonControl = (currentControl as CloudControl);
3008
                                        currentControl.CommentID = Commons.shortGuid();
3009
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3010
                                        currentControl.IsNew = true;
3011
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3012

    
3013
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3014
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3015
                                    
3016
                                    //}
3017
                                }
3018
                            }
3019
                        }
3020
                        break;
3021
                    case ControlType.ImgControl:
3022
                        {
3023
                            if (e.LeftButton == MouseButtonState.Pressed)
3024
                            {
3025
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3026
                                //{
3027
                                    if (currentControl is ImgControl)
3028
                                    {
3029
                                        //20180906 LJY TEST IsRotationDrawingEnable
3030
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3031
                                        {
3032
                                            return;
3033
                                        }
3034

    
3035
                                        CreateCommand.Instance.Execute(currentControl);
3036
                                        controlType = ControlType.ImgControl;
3037
                                        currentControl = null;
3038
                                    }
3039
                                    else
3040
                                    {
3041
                                        
3042
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3043
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3044
                                        {
3045
                                            Image img = new Image();
3046
                                            if (filename.Contains(".svg"))
3047
                                            {
3048
                                                byte[] imageData = null;
3049
                                                DrawingImage image = null;
3050
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3051
                                                {
3052
                                                    imageData = web.DownloadData(new Uri(filename));
3053
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3054
                                                    image = SvgReader.Load(stream);
3055
                                                }
3056
                                                img.Source = image;
3057
                                            }
3058
                                            else
3059
                                            {
3060
                                                img.Source = new BitmapImage(new Uri(filename));
3061
                                            }
3062

    
3063
                                            currentControl = new ImgControl
3064
                                            {
3065
                                                    Background = new SolidColorBrush(Colors.Black),
3066
                                                    PointSet = new List<Point>(),
3067
                                                    FilePath = filename,
3068
                                                    ImageData = img.Source,
3069
                                                    StartPoint = canvasDrawingMouseDownPoint,
3070
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3071
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3072
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3073
                                                    ControlType = ControlType.ImgControl
3074
                                                };
3075

    
3076
                                        
3077
                                                currentControl.CommentID = Commons.shortGuid();                                            
3078
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3079
                                                currentControl.IsNew = true;
3080
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3081

    
3082
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3083
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3084
                                        }
3085
                                    }
3086
                                //}
3087
                            }
3088
                        }
3089
                        break;
3090
                    case ControlType.Date:
3091
                        {
3092
                            if (e.LeftButton == MouseButtonState.Pressed)
3093
                            {
3094
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3095
                                //{
3096
                                    if (currentControl is DateControl)
3097
                                    {
3098
                                        //20180906 LJY TEST IsRotationDrawingEnable
3099
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3100
                                        {
3101
                                            return;
3102
                                        }
3103

    
3104
                                        CreateCommand.Instance.Execute(currentControl);
3105
                                        currentControl = null;
3106

    
3107
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3108
                                        {
3109
                                            controlType = ControlType.None;
3110
                                            IsSwingMode = false;
3111
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3112
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3113
                                            mouseHandlingMode = MouseHandlingMode.None;
3114
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3115
                                            txtBatch.Visibility = Visibility.Collapsed;
3116

    
3117
                                        }
3118
                                    }
3119
                                    else
3120
                                    {
3121
                                        currentControl = new DateControl
3122
                                        {
3123
                                            StartPoint = canvasDrawingMouseDownPoint,
3124
                                            Background = new SolidColorBrush(Colors.Black)
3125
                                        };
3126
                                        currentControl.CommentID = Commons.shortGuid();
3127
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3128
                                        currentControl.IsNew = true;
3129
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3130

    
3131
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3132
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3133
                                }
3134
                                //}
3135
                            }
3136
                        }
3137
                        break;
3138
                    case ControlType.TextControl:
3139
                        {
3140
                            if (e.LeftButton == MouseButtonState.Pressed)
3141
                            {
3142
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3143
                                {
3144
                                    currentControl = new TextControl
3145
                                    {
3146
                                        ControlType = controlType
3147
                                    };
3148
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3149
                                    currentControl.CommentID = Commons.shortGuid();
3150
                                    currentControl.IsNew = true;
3151
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3152
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3153
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3154

    
3155
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3156
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3157
                                    
3158
                                    (currentControl as TextControl).ControlType_No = 0;
3159
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3160
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3161
                                    (currentControl as TextControl).ApplyTemplate();
3162
                                    (currentControl as TextControl).Base_TextBox.Focus();
3163

    
3164
                                    CreateCommand.Instance.Execute(currentControl);
3165
                                }
3166
                            }
3167
                        }
3168
                        break;
3169
                    case ControlType.TextBorder:
3170
                        {
3171
                            if (e.LeftButton == MouseButtonState.Pressed)
3172
                            {
3173
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3174
                                {
3175
                                    currentControl = new TextControl
3176
                                    {
3177
                                        ControlType = controlType
3178
                                    };
3179

    
3180
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3181
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3182
                                    currentControl.CommentID = Commons.shortGuid();
3183
                                    currentControl.IsNew = true;
3184
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3185
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3186
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3187
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3188
                                    
3189
                                    (currentControl as TextControl).ControlType_No = 1;
3190
                                    (currentControl as TextControl).Angle = Ang;
3191
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3192
                                    (currentControl as TextControl).ApplyTemplate();
3193
                                    (currentControl as TextControl).Base_TextBox.Focus();
3194
                                    CreateCommand.Instance.Execute(currentControl);
3195
                                }
3196
                            }
3197
                        }
3198
                        break;
3199
                    case ControlType.TextCloud:
3200
                        {
3201
                            if (e.LeftButton == MouseButtonState.Pressed)
3202
                            {
3203
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3204
                                {
3205
                                    currentControl = new TextControl
3206
                                    {
3207
                                        ControlType = controlType
3208
                                    };
3209

    
3210
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3211
                                    currentControl.CommentID = Commons.shortGuid();
3212
                                    currentControl.IsNew = true;
3213
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3214
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3215

    
3216
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3217
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3218
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3219

    
3220
                                    (currentControl as TextControl).Angle = Ang;
3221
                                    (currentControl as TextControl).ControlType_No = 2;
3222
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3223
                                    (currentControl as TextControl).ApplyTemplate();
3224
                                    (currentControl as TextControl).Base_TextBox.Focus();
3225
                                    CreateCommand.Instance.Execute(currentControl);
3226
                                    //currentControl = null;
3227
                                }
3228
                            }
3229
                        }
3230
                        break;
3231
                    case ControlType.ArrowTextControl:
3232
                         {
3233
                            if (e.LeftButton == MouseButtonState.Pressed)
3234
                            {
3235
                                if (currentControl is ArrowTextControl)
3236
                                {
3237
                                    //20180906 LJY TEST IsRotationDrawingEnable
3238
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3239
                                    {
3240
                                        return;
3241
                                    }
3242

    
3243
                                    CreateCommand.Instance.Execute(currentControl);
3244

    
3245
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3246
                                    (currentControl as ArrowTextControl).IsEditing = false;
3247
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3248
                                    (currentControl as ArrowTextControl).IsNew = false;
3249
                                    currentControl = null;
3250
                                }
3251
                                else
3252
                                {
3253
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3254
                                    //{
3255
                                        currentControl = new ArrowTextControl();
3256
                                        currentControl.CommentID = Commons.shortGuid();
3257
                                        currentControl.IsNew = true;
3258
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3259
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3260

    
3261
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3262
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3263
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3264
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3265
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3266

    
3267
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3268
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3269

    
3270
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3271
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3272
                                        this.MainAngle.Visibility = Visibility.Visible;
3273

    
3274
                                    
3275
                                    //}
3276
                                }
3277
                            }
3278
                        }
3279
                        break;
3280
                    case ControlType.ArrowTransTextControl:
3281
                        {
3282
                            if (e.LeftButton == MouseButtonState.Pressed)
3283
                            {
3284
                                if (currentControl is ArrowTextControl)
3285
                                {
3286
                                    //20180906 LJY TEST IsRotationDrawingEnable
3287
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3288
                                    {
3289
                                        return;
3290
                                    }
3291

    
3292
                                    CreateCommand.Instance.Execute(currentControl);
3293
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3294
                                    currentControl.IsNew = false;
3295
                                    currentControl = null;
3296
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3297
                                }
3298
                                else
3299
                                {
3300
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3301
                                    //{
3302
                                         currentControl = new ArrowTextControl();
3303
                                        currentControl.CommentID = Commons.shortGuid();
3304
                                        currentControl.IsNew = true;
3305
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3306
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3307
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3308
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3309
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3310
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3311
                                        (currentControl as ArrowTextControl).isFixed = true;
3312
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3313

    
3314
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3315
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3316

    
3317
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3318
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3319
                                        (currentControl as ArrowTextControl).isTrans = true;
3320
                                }
3321
                            }
3322
                        }
3323
                        break;
3324
                    case ControlType.ArrowTextBorderControl:
3325
                         {
3326
                            if (e.LeftButton == MouseButtonState.Pressed)
3327
                            {
3328
                                if (currentControl is ArrowTextControl)
3329
                                {
3330
                                    //20180906 LJY TEST IsRotationDrawingEnable
3331
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3332
                                    {
3333
                                        return;
3334
                                    }
3335

    
3336
                                    CreateCommand.Instance.Execute(currentControl);
3337
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3338
                                    currentControl.IsNew = false;
3339
                                    currentControl = null;
3340
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3341
                                }
3342
                                else
3343
                                {
3344
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3345
                                    //{
3346
                                        currentControl = new ArrowTextControl()
3347
                                        {
3348
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3349
                                        };
3350
                                        currentControl.CommentID = Commons.shortGuid();
3351
                                        currentControl.IsNew = true;
3352
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3353
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3354

    
3355
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3356

    
3357
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3358

    
3359
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3360
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3361
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3362

    
3363
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3364
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3365
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3366
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3367
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3368
                                    //}
3369
                                }
3370
                            }
3371
                        }
3372
                        break;
3373
                    case ControlType.ArrowTransTextBorderControl:
3374
                        {
3375
                            if (e.LeftButton == MouseButtonState.Pressed)
3376
                            {
3377
                                if (currentControl is ArrowTextControl)
3378
                                {
3379
                                    //20180906 LJY TEST IsRotationDrawingEnable
3380
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3381
                                    {
3382
                                        return;
3383
                                    }
3384
                                    CreateCommand.Instance.Execute(currentControl);
3385
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3386
                                    currentControl.IsNew = false;
3387
                                    currentControl = null;
3388
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3389
                                }
3390
                                else
3391
                                {
3392
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3393
                                    //{
3394
                                    
3395

    
3396
                                    currentControl = new ArrowTextControl()
3397
                                        {
3398
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3399
                                        };
3400
                                        currentControl.CommentID = Commons.shortGuid();
3401
                                        currentControl.IsNew = true;
3402
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3403
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3404

    
3405
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3406

    
3407
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3408
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3409
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3410
                                        (currentControl as ArrowTextControl).isFixed = true;
3411
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3412
                                     
3413
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3414
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3415
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3416

    
3417
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3418
                                        this.MainAngle.Visibility = Visibility.Visible;
3419
                                    
3420
                                    //20180911 LJY
3421
                                        (currentControl as ArrowTextControl).isTrans = true;
3422
                                    
3423

    
3424
                                    //}
3425
                                }
3426
                            }
3427
                        }
3428
                        break;
3429
                    case ControlType.ArrowTextCloudControl:
3430
                        {
3431
                            if (e.LeftButton == MouseButtonState.Pressed)
3432
                            {
3433
                                if (currentControl is ArrowTextControl)
3434
                                {
3435
                                    //20180906 LJY TEST IsRotationDrawingEnable
3436
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3437
                                    {
3438
                                        return;
3439
                                    }
3440
                                    CreateCommand.Instance.Execute(currentControl);
3441
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3442
                                    currentControl.IsNew = false;
3443
                                    currentControl = null;
3444
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3445
                                }
3446
                                else
3447
                                {
3448
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3449
                                    //{
3450
                                        currentControl = new ArrowTextControl()
3451
                                        {
3452
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3453
                                        };
3454
                                        currentControl.CommentID = Commons.shortGuid();
3455
                                        currentControl.IsNew = true;
3456
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3457
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3458

    
3459
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3460
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3461
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3462
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3463
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3464

    
3465
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3466
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3467
                                    
3468
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3469
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3470
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3471
                                    //}
3472
                                }
3473
                            }
3474
                        }
3475
                        break;
3476
                    case ControlType.ArrowTransTextCloudControl:
3477
                        {
3478
                            if (e.LeftButton == MouseButtonState.Pressed)
3479
                            {
3480
                                if (currentControl is ArrowTextControl)
3481
                                {
3482
                                    //20180906 LJY TEST IsRotationDrawingEnable
3483
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3484
                                    {
3485
                                        return;
3486
                                    }
3487
                                    CreateCommand.Instance.Execute(currentControl);
3488
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3489
                                    currentControl.IsNew = false;
3490
                                    currentControl = null;
3491
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3492
                                }
3493
                                else
3494
                                {
3495
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3496
                                    //{
3497
                                        currentControl = new ArrowTextControl()
3498
                                        {
3499
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3500
                                        };
3501
                                        currentControl.CommentID = Commons.shortGuid();
3502
                                        currentControl.IsNew = true; 
3503
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3504
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3505
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3506

    
3507
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3508
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3509
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3510
                                        (currentControl as ArrowTextControl).isFixed = true;
3511
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3512

    
3513
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3514
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3515

    
3516
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3517
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3518
                                        this.MainAngle.Visibility = Visibility.Visible;  
3519
                                    
3520
                                    //20180911 LJY
3521
                                        (currentControl as ArrowTextControl).isTrans = true;
3522
                                    //}
3523
                                }
3524
                            }
3525
                        }
3526
                        break;
3527
                    //강인구 추가
3528
                    case ControlType.Sign:
3529
                        {
3530
                            if (e.LeftButton == MouseButtonState.Pressed)
3531
                            {
3532
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3533
                                //{
3534
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3535

    
3536
                                    if (_sign == null)
3537
                                    {
3538
                                        txtBatch.Visibility = Visibility.Collapsed;
3539
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3540
                                        controlType = ControlType.None;
3541

    
3542
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3543
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3544
                                        return;
3545
                                    }
3546

    
3547
                                    if (currentControl is SignControl)
3548
                                    {
3549
                                        //20180906 LJY TEST IsRotationDrawingEnable
3550
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3551
                                        {
3552
                                            return;
3553
                                        }
3554

    
3555
                                        CreateCommand.Instance.Execute(currentControl);
3556
                                        currentControl = null;
3557
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3558
                                        {
3559
                                            txtBatch.Text = "Place Date";
3560
                                            controlType = ControlType.Date;
3561
                                        }
3562
                                    }
3563
                                    else
3564
                                    {
3565
                                        currentControl = new SignControl
3566
                                        {
3567
                                            Background = new SolidColorBrush(Colors.Black),
3568
                                            UserNumber = App.ViewInfo.UserID,
3569
                                            ProjectNO = App.ViewInfo.ProjectNO,
3570
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3571
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3572
                                            ControlType = ControlType.Sign
3573
                                        };
3574

    
3575
                                        currentControl.CommentID = Commons.shortGuid();
3576
                                        currentControl.IsNew = true;
3577
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3578
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3579

    
3580
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3581
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3582
                                }
3583
                                //}
3584
                            }
3585
                        }
3586
                        break;
3587
                    case ControlType.Mark:
3588
                        {
3589
                            if (e.LeftButton == MouseButtonState.Pressed)
3590
                            {
3591
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3592
                                //{
3593
                                    if (currentControl is RectangleControl)
3594
                                    {
3595
                                        //20180906 LJY TEST IsRotationDrawingEnable
3596
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3597
                                        {
3598
                                            return;
3599
                                        }
3600

    
3601
                                        CreateCommand.Instance.Execute(currentControl);
3602
                                        (currentControl as RectangleControl).ApplyOverViewData();
3603
                                        currentControl = null;
3604
                                    
3605
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3606

    
3607
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3608
                                        {
3609
                                            txtBatch.Text = "Place Signature";
3610
                                            controlType = ControlType.Sign;
3611
                                        }
3612
                                    }
3613
                                    else
3614
                                    {
3615
                                        currentControl = new RectangleControl
3616
                                        {
3617
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3618
                                            Background = new SolidColorBrush(Colors.Black),
3619
                                            ControlType = ControlType.Mark ,
3620
                                            Paint = PaintSet.Fill
3621
                                        };
3622

    
3623
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3624
                                        currentControl.CommentID = Commons.shortGuid();
3625
                                        currentControl.IsNew = true;
3626
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3627
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3628
                                    }
3629
                                //}
3630
                            }
3631
                        }
3632
                        break;
3633
                    case ControlType.Symbol:
3634
                        {
3635
                            if (e.LeftButton == MouseButtonState.Pressed)
3636
                            {
3637
                                if (currentControl is SymControl)
3638
                                {
3639
                                    //20180906 LJY TEST IsRotationDrawingEnable
3640
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3641
                                    {
3642
                                        return;
3643
                                    }
3644
                                    CreateCommand.Instance.Execute(currentControl);
3645
                                    currentControl = null;
3646
                                
3647
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3648
                                }
3649
                                else
3650
                                {
3651
                                    currentControl = new SymControl
3652
                                    {
3653
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3654
                                        Background = new SolidColorBrush(Colors.Black),
3655
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3656
                                        ControlType = ControlType.Symbol
3657
                                    };
3658

    
3659
                                    currentControl.IsNew = true;
3660
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3661
                                    currentControl.CommentID = Commons.shortGuid();
3662
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3663

    
3664
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3665
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3666
                                }
3667
                                //}
3668
                            }
3669
                        }
3670
                        break;
3671
                    case ControlType.Stamp:
3672
                        {
3673
                            if (e.LeftButton == MouseButtonState.Pressed)
3674
                            {
3675
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3676
                                //{
3677
                                    if (currentControl is SymControlN)
3678
                                    {
3679
                                        //20180906 LJY TEST IsRotationDrawingEnable
3680
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3681
                                        {
3682
                                            return;
3683
                                        }
3684

    
3685
                                        CreateCommand.Instance.Execute(currentControl);
3686
                                        currentControl = null;
3687
                                   
3688

    
3689
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3690
                                    }
3691
                                    else
3692
                                    {
3693
                                        currentControl = new SymControlN
3694
                                        {
3695
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3696
                                            Background = new SolidColorBrush(Colors.Black),
3697
                                            STAMP = App.SystemInfo.STAMP,
3698
                                            ControlType = ControlType.Stamp
3699
                                        };
3700

    
3701
                                        currentControl.IsNew = true;
3702
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3703
                                        currentControl.CommentID = Commons.shortGuid();
3704
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3705
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3706
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3707
                                }                                    
3708
                                //}
3709
                            }
3710
                        }
3711
                        break;
3712
                    case ControlType.PenControl:
3713
                        {
3714
                            if (inkBoard.Tag.ToString() == "Ink")
3715
                            {
3716
                                inkBoard.IsEnabled = true;
3717
                                StartNewStroke(canvasDrawingMouseDownPoint);
3718
                            }
3719
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3720
                            {
3721
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3722
                            }
3723
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3724
                            {
3725
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3726
                            }
3727
                            IsDrawing = true;
3728
                            return;
3729
                        }
3730
                    default:
3731
                        if (currentControl != null)
3732
                        {
3733
                            currentControl.CommentID = null;
3734
                            currentControl.IsNew = false;
3735
                        }
3736
                        break;
3737
                }
3738
            }
3739
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3740
            {
3741
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3742
                {
3743
                    bool mouseOff = false;
3744
                    foreach (var item in SelectLayer.Children)
3745
                    {
3746
                        if (item is AdornerFinal)
3747
                        {
3748

    
3749
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3750
                            if (over != null)
3751
                            {
3752
                                mouseOff = true;
3753
                            }
3754
                        }
3755
                    }
3756

    
3757
                    if (!mouseOff)
3758
                    {
3759
                        SelectionSet.Instance.UnSelect(this);
3760
                    }
3761
                }
3762
                zoomAndPanControl.CaptureMouse();
3763
                e.Handled = true;
3764
            }
3765
        }
3766

    
3767
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3768
        {
3769
            ///mouseButtonDown = e.ChangedButton;
3770
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3771
        }
3772

    
3773
        private void RemoveLineStroke(Point P)
3774
        {
3775
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3776
            if (control != null)
3777
            {
3778
                UndoData = new Undo_data()
3779
                {
3780
                    IsUndo = false,
3781
                    Event = Event_Type.Delete,
3782
                    EventTime = DateTime.Now,
3783
                    Markup_List = new List<Multi_Undo_data>()
3784
                };
3785

    
3786

    
3787
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
3788
                UndoData.Markup_List.Add(multi_Undo_Data);
3789
                multi_Undo_Data = new Multi_Undo_data();
3790

    
3791
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3792
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
3793
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
3794
                
3795
                //임시파일에서도 삭제한다.
3796
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
3797
                
3798
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3799
                {
3800
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3801
                });
3802
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3803

    
3804
            }
3805
        }
3806

    
3807
        private void RemovePointStroke(Point P)
3808
        {
3809
            foreach (Stroke hits in inkBoard.Strokes)
3810
            {
3811
                foreach (StylusPoint sty in hits.StylusPoints)
3812
                {
3813

    
3814
                }
3815
                if (hits.HitTest(P))
3816
                {
3817
                    inkBoard.Strokes.Remove(hits);
3818
                    return;
3819
                }
3820
            }
3821
        }
3822

    
3823
        private void StartNewStroke(Point P)
3824
        {
3825
            strokePoints = new StylusPointCollection();
3826
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3827
            strokePoints.Add(segment1Start);
3828
            stroke = new Stroke(strokePoints);
3829

    
3830
            stroke.DrawingAttributes.Color = Colors.Red;
3831
            stroke.DrawingAttributes.Width = 4;
3832
            stroke.DrawingAttributes.Height = 4;
3833

    
3834
            inkBoard.Strokes.Add(stroke);
3835

    
3836
        }
3837

    
3838
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3839
        {
3840
            ConsolidationMethod();
3841
        }
3842

    
3843
        /// <summary>
3844
        /// execute TeamConsolidationCommand
3845
        /// </summary>
3846
        public void TeamConsolidationMethod()
3847
        {
3848
            this.UpdateMyMarkupList();
3849
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3850
            {
3851
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3852
            }
3853
            else
3854
            {
3855

    
3856
                ViewerDataModel.Instance.IsConsolidate = true;
3857
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3858

    
3859
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3860
                {
3861
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3862
                    {
3863
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3864
                        return;
3865
                    }                    
3866
                }
3867
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3868
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3869
                {
3870
                    MarkupInfoList.Add(item);
3871
                }
3872
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3873
            }
3874
        }
3875

    
3876
        public void ConsolidationMethod()
3877
        {
3878
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3879
            {
3880
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3881
            }
3882
            else
3883
            {
3884
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3885
                foreach (var item in this.gridViewMarkup.SelectedItems)
3886
                {
3887
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3888
                }
3889
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3890
                
3891
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3892
            }
3893
        }
3894

    
3895
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3896
        {
3897
            if (App.ViewInfo != null)
3898
            {
3899
                btnConsolidate = (sender as RadRibbonButton);
3900
                if (!App.ViewInfo.NewCommentPermission)
3901
                {
3902
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3903
                }
3904
            }
3905
        }
3906

    
3907
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3908
        {
3909
            TeamConsolidationMethod();
3910
        }
3911

    
3912
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3913
        {
3914
            btnTeamConsolidate = sender as RadRibbonButton;
3915
            if (App.ViewInfo != null)
3916
            {
3917
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3918
                {
3919
                    if (btnConsolidate != null)
3920
                    {
3921
                        btnConsolidate.Visibility = Visibility.Collapsed;
3922
                    }
3923

    
3924
                    if (!App.ViewInfo.NewCommentPermission)
3925
                    {
3926
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3927
                    }
3928
                }
3929
                else
3930
                {
3931
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3932
                }
3933
            }
3934
        }
3935

    
3936
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3937
        {
3938
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3939
            if (item != null)
3940
            {
3941
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3942

    
3943
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3944
            }
3945
            else
3946
            {
3947
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3948
            }
3949
        }
3950

    
3951
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3952
        {
3953
            btnFinalPDF = sender as RadRibbonButton;
3954
            if (App.ViewInfo != null)
3955
            {
3956
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3957
                {
3958
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3959
                    if (btnConsolidate != null)
3960
                    {
3961
                        btnConsolidate.Visibility = Visibility.Collapsed;
3962
                    }
3963
                }
3964
            }
3965
        }
3966

    
3967
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3968
        {
3969
            UpdateMyMarkupList();
3970

    
3971
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3972
            {
3973
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3974
            }
3975
            else
3976
            {
3977
                ViewerDataModel.Instance.IsConsolidate = true;
3978
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3979
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3980

    
3981
                string project_no = App.ViewInfo.ProjectNO;
3982
                string doc_id = _DocInfo.ID;
3983
                string user_id = App.ViewInfo.UserID;
3984
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3985
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3986
                {
3987
                    markupInfoItems.Add(item);
3988
                }
3989
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3990
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3991
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3992
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3993

    
3994
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3995
                if (item2 != null)
3996
                {
3997
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3998

    
3999
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4000
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4001
                }
4002
                else
4003
                {
4004
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4005
                }
4006
            }
4007
        }
4008

    
4009
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4010
        {
4011
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4012

    
4013
            if (App.ViewInfo != null)
4014
            {
4015
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4016
                {
4017
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4018
                }
4019
            }
4020
        }
4021

    
4022
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4023
        {
4024
            if (CompareMode.IsChecked)
4025
            {
4026
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4027
                {
4028
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4029
                }
4030
                if (ViewerDataModel.Instance.PageNumber == 0)
4031
                {
4032
                    ViewerDataModel.Instance.PageNumber = 1;
4033
                }
4034

    
4035
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4036
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4037
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4038

    
4039
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4040
            }
4041
            else
4042
            {
4043
                da.From = 1;
4044
                da.To = 1;
4045
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4046
                da.AutoReverse = false;
4047
                canvas_compareBorder.Children.Clear();
4048
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4049
            }
4050
        }
4051

    
4052
        private void Sync_Click(object sender, RoutedEventArgs e)
4053
        {
4054
            if (Sync.IsChecked)
4055
            {
4056
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4057
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4058
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4059
            }
4060
        }
4061

    
4062
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4063
        {
4064
            if (UserList.IsChecked)
4065
            {
4066
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4067
            }
4068
            else
4069
            {
4070
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4071
            }
4072
        }
4073

    
4074
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4075
        {
4076

    
4077
            if (BalanceMode.IsChecked)
4078
            {
4079
                ViewerDataModel.Instance.PageBalanceMode = true;
4080
            }
4081
            else
4082
            {
4083
                ViewerDataModel.Instance.PageBalanceMode = false;
4084
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4085
            }
4086
        }
4087

    
4088
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4089
        {
4090
            //초기화
4091
            testPanel2.IsHidden = true;
4092
            ViewerDataModel.Instance.PageBalanceMode = false;
4093
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4094
            ViewerDataModel.Instance.PageNumber = 0;
4095
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4096
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4097
            UserList.IsChecked = false;
4098
            BalanceMode.IsChecked = false;
4099
        }
4100

    
4101
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4102
        {
4103
            if ((sender as System.Windows.Controls.Control).Tag != null)
4104
            {
4105
                //Compare 초기화
4106
                CompareMode.IsChecked = false;
4107
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4108

    
4109
                if (ViewerDataModel.Instance.PageNumber == 0)
4110
                {
4111
                    ViewerDataModel.Instance.PageNumber = 1;
4112
                }
4113

    
4114
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4115
                {
4116
                }
4117
                else
4118
                {
4119
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4120
                }
4121

    
4122
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4123
                {
4124

    
4125
                }
4126
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4127
                {
4128
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4129
                }
4130

    
4131
                if (!testPanel2.IsHidden)
4132
                {
4133
                    if (IsSyncPDFMode)
4134
                    {
4135
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4136
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4137

    
4138
                        if (pdfpath.IsDownloading)
4139
                        {
4140
                            pdfpath.DownloadCompleted += (ex, arg) =>
4141
                            {
4142
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4143
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4144
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4145
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4146
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4147
                            };
4148
                        }
4149
                        else
4150
                        {
4151
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4152
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4153
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4154

    
4155
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4156
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4157
                        }
4158

    
4159
                    }
4160
                    else
4161
                    {
4162
                        string uri = "";
4163

    
4164
                        if (userData.COMPANY != "EXT")
4165
                        {
4166
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4167
                        }
4168
                        else
4169
                        {
4170
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4171
                        }
4172

    
4173
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4174

    
4175
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4176
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4177
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4178

    
4179
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4180
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4181

    
4182
                        if (defaultBitmapImage_Compare.IsDownloading)
4183
                        {
4184
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4185
                            {
4186
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4187
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4188
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4189

    
4190
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4191
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4192
                            };
4193
                        }
4194
                    }
4195

    
4196
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4197
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4198
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4199

    
4200
                    foreach (var item in gridSelectionRevItem)
4201
                    {
4202
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4203
                        {
4204
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4205
                        });
4206
                    }
4207

    
4208
                    //강인구 추가
4209
                    zoomAndPanControl2.ZoomTo(new Rect
4210
                    {
4211
                        X = 0,
4212
                        Y = 0,
4213
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4214
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4215
                    });
4216

    
4217
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4218

    
4219
                }
4220
            }
4221
        }
4222

    
4223
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4224
        {
4225
            if (MarkupMode.IsChecked)
4226
            {
4227
                IsSyncPDFMode = true;
4228

    
4229
                var uri = CurrentRev.TO_VENDOR;
4230

    
4231
                if (ViewerDataModel.Instance.PageNumber == 0)
4232
                {
4233
                    ViewerDataModel.Instance.PageNumber = 1;
4234
                }
4235

    
4236
                //PDF모드 잠시 대기(강인구)
4237
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4238
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4239

    
4240
                if (pdfpath.IsDownloading)
4241
                {
4242
                    pdfpath.DownloadCompleted += (ex, arg) =>
4243
                    {
4244
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4245
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4246
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4247
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4248
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4249
                    };
4250
                }
4251
                else
4252
                {
4253
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4254
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4255
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4256

    
4257
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4258
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4259
                }
4260
            }
4261
            else
4262
            {
4263
                IsSyncPDFMode = false;
4264
                string uri = "";
4265
                if (userData.COMPANY != "EXT")
4266
                {
4267
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4268
                }
4269
                else
4270
                {
4271
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4272
                }
4273

    
4274
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4275

    
4276
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4277
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4278
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4279

    
4280
                if (defaultBitmapImage_Compare.IsDownloading)
4281
                {
4282
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4283
                    {
4284
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4285
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4286
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4287
                    };
4288
                }
4289
                zoomAndPanControl2.ApplyTemplate();
4290
                zoomAndPanControl2.UpdateLayout();
4291
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4292
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4293
            }
4294
        }
4295

    
4296
        private void RadButton_Click(object sender, RoutedEventArgs e)
4297
        {
4298
            gridViewHistory_Busy.IsBusy = true;
4299

    
4300
            RadButton instance = sender as RadButton;
4301
            if (instance.CommandParameter != null)
4302
            {
4303
                CurrentRev = instance.CommandParameter as VPRevision;
4304
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4305
                {
4306
                    if (ea.Error == null && ea.Result != null)
4307
                    {
4308
                        testPanel2.IsHidden = false;
4309

    
4310
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4311
                        foreach(var info in ea.Result)
4312
                        {
4313
                            if(info.UserID == App.ViewInfo.UserID)
4314
                            {
4315
                                info.userDelete = true;
4316
                                info.DisplayColor = "FFFF0000";
4317
                            }
4318
                            else
4319
                            {
4320
                                info.userDelete = false;
4321
                            }
4322
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4323
                        }
4324
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4325

    
4326
                        string uri = "";
4327
                        if (userData.COMPANY != "EXT")
4328
                        {
4329
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4330
                        }
4331
                        else
4332
                        {
4333
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4334
                        }
4335

    
4336
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4337

    
4338
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4339

    
4340
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4341
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4342
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4343

    
4344
                        if (defaultBitmapImage_Compare.IsDownloading)
4345
                        {
4346
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4347
                            {
4348
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4349
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4350
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4351
                            };
4352
                        }
4353

    
4354
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4355
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4356
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4357
                        zoomAndPanControl2.ApplyTemplate();
4358
                        zoomAndPanControl2.UpdateLayout();
4359

    
4360
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4361
                        {
4362
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4363
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4364
                        }
4365

    
4366
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4367
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4368
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4369

    
4370
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4371
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4372
                        gridViewHistory_Busy.IsBusy = false;
4373
                    }
4374

    
4375
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4376
                };
4377
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4378
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4379
            }
4380
        }
4381

    
4382
        public void Sync_Event(VPRevision Currnet_Rev)
4383
        {
4384
            CurrentRev = Currnet_Rev;
4385

    
4386
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4387
            {
4388
                if (ea.Error == null && ea.Result != null)
4389
                {
4390
                    testPanel2.IsHidden = false;
4391

    
4392
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4393
                    foreach(var info in ea.Result)
4394
                    {
4395
                        if(info.UserID == App.ViewInfo.UserID)
4396
                        {
4397
                            info.userDelete = true;
4398
                            info.DisplayColor = "FFFF0000";
4399
                        }
4400
                        else
4401
                        {
4402
                            info.userDelete = false;
4403
                        }
4404
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4405
                    }
4406
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4407

    
4408
                    string uri = "";
4409
                    if (userData.COMPANY != "EXT")
4410
                    {
4411
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4412
                    }
4413
                    else
4414
                    {
4415
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4416
                    }
4417

    
4418
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4419

    
4420
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4421

    
4422
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4423
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4424
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4425

    
4426
                    if (defaultBitmapImage_Compare.IsDownloading)
4427
                    {
4428
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4429
                        {
4430
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4431
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4432
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4433
                        };
4434
                    }
4435

    
4436

    
4437
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4438
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4439
                    zoomAndPanControl2.ApplyTemplate();
4440
                    zoomAndPanControl2.UpdateLayout();
4441

    
4442
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4443
                    {
4444
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4445
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4446
                    }
4447
                    //}
4448

    
4449
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4450
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4451
                    gridViewHistory_Busy.IsBusy = false;
4452
                }
4453
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4454

    
4455
            };
4456
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4457
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4458
        }
4459

    
4460
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4461
        {
4462
            if (sender is Image)
4463
            {
4464
                if ((sender as Image).Tag != null)
4465
                {
4466
                    var pdfUrl = (sender as Image).Tag.ToString();
4467
                    System.Diagnostics.Process.Start(pdfUrl);
4468
                }
4469
                else
4470
                {
4471
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4472
                }
4473
            }
4474
        }
4475

    
4476
        private void Create_Symbol(object sender, RoutedEventArgs e)
4477
        {
4478
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4479

    
4480
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4481
            {
4482
                DialogMessage_Alert("Please Select Controls", "Alert");
4483
            }
4484
            else //선택된 것이 있으면
4485
            {
4486
                string MarkupData = "";
4487
                adorner_ = new AdornerFinal();
4488

    
4489
                foreach (var item in SelectLayer.Children)
4490
                {
4491
                    if (item.GetType().Name == "AdornerFinal")
4492
                    {
4493
                        adorner_ = (item as Controls.AdornerFinal);
4494
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4495
                        {
4496
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4497
                            {
4498
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4499
                                MarkupData += markupReturn.ConvertData;
4500
                            }
4501
                        }
4502
                    }
4503
                }
4504
                DialogParameters parameters = new DialogParameters()
4505
                {
4506
                    Owner = Application.Current.MainWindow,
4507
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4508
                    DefaultPromptResultValue = "Custom State",
4509
                    Content = "Name :",
4510
                    Header = "Insert Custom Symbol Name",
4511
                    Theme = new VisualStudio2013Theme(),
4512
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4513
                };
4514
                RadWindow.Prompt(parameters);
4515
            }
4516

    
4517
        }
4518
        public int symbolselectindex = 0;
4519
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4520
        {
4521
            //Save save = new Save();
4522
            try
4523
            {
4524
                string svgfilename = null;
4525
                if (symbolname != null)
4526
                {
4527
                    if (symbolpng == true || symbolsvg == true)
4528
                    {
4529
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4530
                        string guid = Commons.shortGuid();
4531

    
4532
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4533
                        //Check_Uri.UriCheck();
4534
                        fileUploader.RunCompleted += (ex, arg) =>
4535
                        {
4536
                            filename = arg.Result;
4537
                            if (symbolpng == true)
4538
                            {
4539
                                if (filename != null)
4540
                                { 
4541
                                    if (symbolselectindex == 0)
4542
                                    {
4543
                                        SymbolSave(symbolname, filename, data);
4544
                                    }
4545
                                    else
4546
                                    {
4547
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4548
                                    }
4549
                                    DataBind();
4550
                                }                                
4551
                            }
4552

    
4553
                            if (symbolsvg == true)
4554
                            {
4555
                                try
4556
                                {
4557
                                    var defaultBitmapImage = new BitmapImage();
4558
                                    defaultBitmapImage.BeginInit();
4559
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4560
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4561
                                    Check_Uri.UriCheck(filename);
4562
                                    defaultBitmapImage.UriSource = new Uri(filename);
4563
                                    defaultBitmapImage.EndInit();
4564

    
4565
                                    System.Drawing.Bitmap image;
4566

    
4567
                                    if (defaultBitmapImage.IsDownloading)
4568
                                    {
4569
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4570
                                        {
4571
                                            defaultBitmapImage.Freeze();
4572
                                            image = GetBitmap(defaultBitmapImage);
4573
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4574
                                            Process potrace = new Process
4575
                                            {
4576
                                                StartInfo = new ProcessStartInfo
4577
                                                {
4578
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4579
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4580
                                                    RedirectStandardInput = true,
4581
                                                    RedirectStandardOutput = true,
4582
                                                    RedirectStandardError = true,
4583
                                                    UseShellExecute = false,
4584
                                                    CreateNoWindow = true,
4585
                                                    WindowStyle = ProcessWindowStyle.Hidden
4586
                                                },
4587
                                            };
4588

    
4589
                                            StringBuilder svgBuilder = new StringBuilder();
4590
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4591
                                            {
4592
                                                svgBuilder.AppendLine(e2.Data);
4593
                                            };
4594

    
4595
                                            potrace.EnableRaisingEvents = true;
4596
                                            potrace.Start();
4597
                                            potrace.Exited += (sender, e) =>
4598
                                            {
4599
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4600
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4601
                                                Check_Uri.UriCheck(svgfilename);
4602
                                                if (symbolselectindex == 0)
4603
                                                {
4604
                                                    SymbolSave(symbolname, svgfilename, data);
4605
                                                }
4606
                                                else
4607
                                                {
4608
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4609
                                                }
4610

    
4611
                                                DataBind();
4612
                                            };
4613
                                            potrace.WaitForExit();
4614
                                        };
4615
                                    }
4616
                                    else
4617
                                    {
4618
                                        //GC.Collect();
4619
                                    }
4620
                                }
4621
                                catch(Exception ee)
4622
                                {
4623
                                    DialogMessage_Alert("" + ee, "Alert");
4624
                                }
4625
                            }
4626
                        };                                             
4627
                    }
4628
                }
4629
            }
4630
            catch (Exception e)
4631
            {
4632
                //DialogMessage_Alert(e + "", "Alert");
4633
            }            
4634
        }
4635

    
4636
        public void SymbolSave(string Name, string Url, string Data)
4637
        {
4638
            try
4639
            {
4640
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4641
                {
4642
                    ID = Commons.shortGuid(),
4643
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4644
                    NAME = Name,
4645
                    IMAGE_URL = Url,
4646
                    DATA = Data
4647
                };
4648

    
4649
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4650
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4651
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4652
            }
4653
            catch (Exception)
4654
            {
4655
                throw;
4656
            }
4657
        }
4658

    
4659
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4660
        {
4661
            try
4662
            {
4663
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4664
                {
4665
                    ID = Commons.shortGuid(),
4666
                    DEPARTMENT = Department,
4667
                    NAME = Name,
4668
                    IMAGE_URL = Url,
4669
                    DATA = Data
4670
                };
4671
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4672
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4673
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4674
            }
4675
            catch (Exception)
4676
            {
4677
                throw;
4678
            }
4679
        }
4680

    
4681
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4682
        {           
4683
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4684
            DataBind();
4685
        }
4686

    
4687
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4688
        {
4689
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4690
            DataBind();
4691
        }
4692
        private void DataBind()
4693
        {
4694
            try
4695
            {
4696
                Symbol_Custom Custom = new Symbol_Custom();
4697
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4698
                
4699
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4700
                foreach (var item in symbol_Private)
4701
                {
4702
                    Custom.Name = item.NAME;
4703
                    Custom.ImageUri = item.IMAGE_URL;
4704
                    Custom.ID = item.ID;
4705
                    Custom_List.Add(Custom);
4706
                    Custom = new Symbol_Custom();
4707
                }
4708
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4709
                
4710
                Custom = new Symbol_Custom();
4711
                Custom_List = new List<Symbol_Custom>();
4712

    
4713
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4714

    
4715
                List<SYMBOL_PUBLIC> symbol_Public;
4716

    
4717
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4718
                {
4719
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4720
                }
4721
                else
4722
                {
4723
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4724
                }
4725
                foreach (var item in symbol_Public)
4726
                {
4727
                    Custom.Name = item.NAME;
4728
                    Custom.ImageUri = item.IMAGE_URL;
4729
                    Custom.ID = item.ID;
4730
                    Custom_List.Add(Custom);
4731
                    Custom = new Symbol_Custom();
4732
                }
4733
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4734
                BaseClient.Close();                
4735
            }
4736
            catch(Exception e)
4737
            {
4738
                //DialogMessage_Alert("DataBind", "Alert");
4739
            }
4740
            
4741
        }
4742
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4743
        {
4744
            try
4745
            {
4746
                if (args.PromptResult != null)
4747
                {
4748
                    if (args.DialogResult.Value)
4749
                    {
4750
                        PngBitmapEncoder _Encoder = symImage(data);
4751

    
4752
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4753
                        _Encoder.Save(fs);
4754
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4755

    
4756
                        byte[] Img_byte = fs.ToArray();
4757

    
4758
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4759
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4760
                        Check_Uri.UriCheck(filename);
4761
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4762
                        {
4763
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4764
                        }
4765
                        else
4766
                        {
4767
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4768
                        }
4769
                        DataBind();
4770
                    }
4771
                }
4772
            }
4773
            catch(Exception ex)
4774
            {
4775
                DialogMessage_Alert("" + ex, "Alert");
4776
            }
4777
        }
4778

    
4779
        public PngBitmapEncoder symImage(string data)
4780
        {
4781

    
4782
            Canvas _canvas = new Canvas();
4783
            _canvas.Background = Brushes.White;
4784
            _canvas.Width = adorner_.BorderSize.Width;
4785
            _canvas.Height = adorner_.BorderSize.Height;
4786
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4787

    
4788
            BitmapEncoder encoder = new PngBitmapEncoder();
4789

    
4790

    
4791
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
4792

    
4793
            DrawingVisual dv = new DrawingVisual();
4794

    
4795
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
4796
            _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)));
4797

    
4798
            using (DrawingContext ctx = dv.RenderOpen())
4799
            {
4800
                VisualBrush vb = new VisualBrush(_canvas);
4801
                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)));
4802
            }
4803

    
4804
            try
4805
            {
4806
                renderBitmap.Render(dv);
4807

    
4808
                //GC.Collect();
4809
                GC.WaitForPendingFinalizers();
4810
                //GC.Collect();
4811
                // encode png data
4812
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4813
                // puch rendered bitmap into it
4814
                pngEncoder.Interlace = PngInterlaceOption.Off;
4815
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4816
                return pngEncoder;
4817

    
4818
            }
4819
            catch //(Exception ex)
4820
            {
4821
                return null;
4822
            }
4823

    
4824
        }
4825

    
4826
        public void DialogMessage_Alert(string content, string header)
4827
        {
4828
            var box = new TextBlock();
4829
            box.MinWidth = 400;
4830
            box.FontSize = 11;
4831
            //box.FontSize = 12;
4832
            box.Text = content;
4833
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4834

    
4835
            DialogParameters parameters = new DialogParameters()
4836
            {
4837
                Owner = Application.Current.MainWindow,
4838
                Content = box,
4839
                Header = header,
4840
                Theme = new VisualStudio2013Theme(),
4841
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4842
            };            
4843
            RadWindow.Alert(parameters);
4844
        }
4845

    
4846
        #region 캡쳐 기능
4847

    
4848
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4849
        {
4850
            if (x < 0)
4851
            {
4852
                width += x;
4853
                x = 0;
4854
            }
4855
            if (y < 0)
4856
            {
4857
                height += y;
4858
                y = 0;
4859

    
4860
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4861
            }
4862
            if (x + width > zoomAndPanCanvas.ActualWidth)
4863
            {
4864
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4865
            }
4866
            if (y + height > zoomAndPanCanvas.ActualHeight)
4867
            {
4868
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4869
            }
4870

    
4871
            byte[] pixels = CopyPixels(x, y, width, height);
4872

    
4873
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4874

    
4875
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4876
        }
4877

    
4878
        public byte[] CopyPixels(int x, int y, int width, int height)
4879
        {
4880
            byte[] pixels = new byte[width * height * 4];
4881
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4882

    
4883
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
4884
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
4885

    
4886
            return pixels;
4887
        }
4888

    
4889
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4890
        {
4891
            DrawingVisual drawingVisual = new DrawingVisual();
4892
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4893

    
4894
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4895
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4896
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4897
            drawingContext.Close();
4898

    
4899
            // 비트맵으로 변환합니다.
4900
            RenderTargetBitmap target =
4901
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4902
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4903

    
4904
            target.Render(drawingVisual);
4905
            return target;
4906
        }
4907

    
4908
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4909
        {
4910
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4911
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4912
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4913
            bmp.UnlockBits(data);
4914
            return bmp;
4915
        }
4916
        public string symbolname = null;
4917
        public bool symbolsvg = true;
4918
        public bool symbolpng = true;
4919

    
4920
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4921
        {
4922
            System.Drawing.Bitmap image = GetBitmap(source);
4923
            //흰색 제거
4924
            //image.MakeTransparent(System.Drawing.Color.White);
4925

    
4926
            var imageStream = new System.IO.MemoryStream();
4927
            byte[] imageBytes = null;
4928
            using (imageStream)
4929
            {
4930
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4931
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4932
                imageStream.Position = 0;
4933
                imageBytes = imageStream.ToArray();
4934
            }
4935

    
4936
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4937

    
4938
            RadWindow CheckPop = new RadWindow();
4939
            //Alert check = new Alert(Msg);
4940

    
4941
            CheckPop = new RadWindow
4942
            {
4943
                MinWidth = 400,
4944
                MinHeight = 100,
4945
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4946
                Header = "Alert",
4947
                Content = symbolPrompt,
4948
                //DialogResult = 
4949
                ResizeMode = System.Windows.ResizeMode.NoResize,
4950
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4951
                IsTopmost = true,
4952
            };
4953
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4954
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4955
            CheckPop.ShowDialog();
4956

    
4957
            /*
4958
            DialogParameters parameters = new DialogParameters()
4959
            {
4960
                Owner = Application.Current.MainWindow,
4961
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4962
                DefaultPromptResultValue = "Custom State",
4963
                Content = "Name :",
4964
                Header = "Insert Custom Symbol Name",
4965
                Theme = new VisualStudio2013Theme(),
4966
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4967
            };            
4968
            RadWindow.Prompt(parameters);
4969
            */
4970
        }
4971

    
4972
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4973
        {
4974
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4975
            KCOMDataModel.DataModel.CHECK_LIST check_;
4976
            string Result = streamToBase64.ImageToBase64(source);
4977
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4978
            string projectno = App.ViewInfo.ProjectNO;
4979
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4980

    
4981
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4982
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4983
            if (Item != null)
4984
            {
4985
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4986
            }
4987
            else
4988
            {
4989
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4990
            }
4991

    
4992
            if (Item == null)
4993
            {
4994
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4995
                {
4996
                    ID = Commons.shortGuid(),
4997
                    USER_ID = App.ViewInfo.UserID,
4998
                    IMAGE_URL = Result,
4999
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5000
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5001
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5002
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5003
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5004
                    STATUS = "False",
5005
                    CREATE_TIME = DateTime.Now,
5006
                    UPDATE_TIME = DateTime.Now,
5007
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5008
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5009
                };
5010
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5011
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5012
                //this.BaseClient.AddCheckList(projectno, check_);
5013
            }
5014
            else
5015
            {
5016
                Item.IMAGE_URL = Result;
5017
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5018
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5019
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5020
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5021
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5022
            }
5023

    
5024
        }
5025

    
5026
        public void Set_Capture()
5027
        {
5028
            double x = canvasDrawingMouseDownPoint.X;
5029
            double y = canvasDrawingMouseDownPoint.Y;
5030
            double width = dragCaptureBorder.Width;
5031
            double height = dragCaptureBorder.Height;
5032

    
5033
            if (width > 5 || height > 5)
5034
            {
5035
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5036
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5037
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5038
            }
5039
        }
5040
        #endregion
5041

    
5042
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5043
        {
5044
            multi_Undo_Data = new Multi_Undo_data();
5045

    
5046
            multi_Undo_Data.Markup = control;
5047

    
5048
            if ((control as IShapeControl) != null)
5049
            {
5050
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5051
            }
5052
            if ((control as IDashControl) != null)
5053
            {
5054
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5055
            }
5056
            if ((control as IPath) != null)
5057
            {
5058
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5059
            }
5060
            if ((control as UIElement) != null)
5061
            {
5062
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5063
            }
5064

    
5065
            return multi_Undo_Data;
5066
        }
5067

    
5068
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5069
        {
5070
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5071
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5072
            {
5073
                if (items.UserID == Select_ID)
5074
                {
5075
                    foreach (var item in items.MarkupList)
5076
                    {
5077
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5078
                        {
5079
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5080
                                items.MarkupInfoID, Commons.shortGuid());
5081
                        }
5082
                    }
5083
                }
5084
            }
5085
        }
5086

    
5087
        public void InkControl_Convert()
5088
        {
5089
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
5090
            if (inkBoard.Strokes.Count > 0)
5091
            {
5092
                inkBoard.Strokes.ToList().ForEach(stroke =>
5093
                {
5094
                    List<Stroke> removingStroke = new List<Stroke>();
5095
                    StrokeCollection stC = new StrokeCollection();
5096

    
5097
                    removingStroke.Add(stroke);
5098

    
5099
                    InkToPath ip = new InkToPath();
5100
                    List<Point> inkPointSet = new List<Point>();
5101
                    PolygonControl pc = null;
5102
                    pc = new PolygonControl()
5103
                    {
5104
                        Angle = 0,
5105
                        PointSet = new List<Point>(),
5106
                        ControlType = ControlType.Ink
5107
                    };
5108
                    foreach (var item in removingStroke)
5109
                    {
5110
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5111
                        inkBoard.Strokes.Remove(item);
5112
                    }
5113
                    if (inkPointSet.Count != 0)
5114
                    {
5115
                        //강인구 추가(PenControl Undo Redo 추가)
5116
                        UndoData = new Undo_data()
5117
                        {
5118
                            IsUndo = false,
5119
                            Event = Event_Type.Create,
5120
                            EventTime = DateTime.Now,
5121
                            Markup_List = new List<Multi_Undo_data>()
5122
                        };
5123

    
5124
                        pc.StartPoint = inkPointSet[0];
5125
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5126
                        pc.PointSet = inkPointSet;
5127
                        pc.LineSize = 3;
5128
                        pc.CommentID = Commons.shortGuid();
5129
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5130
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5131
                        ///pc.SetPolyPath();
5132

    
5133
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5134
                        {
5135
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5136
                        });
5137
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5138
                        UndoData.Markup_List.Add(multi_Undo_Data);
5139
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5140
                    }
5141
                });
5142
            }
5143
        }
5144

    
5145
        /// <summary>
5146
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5147
        /// </summary>
5148
        /// <param name="StartP">StartPoint</param>
5149
        /// <param name="EndP">EndPoint</param>
5150
        /// <returns>Return_EndPoint</returns>
5151
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5152
        {
5153
            Point Return_Point = new Point();
5154

    
5155
            double dx = EndP.X - StartP.X;
5156
            double dy = EndP.Y - StartP.Y;
5157
            double length;
5158

    
5159
            switch (controlType)
5160
            {
5161
                case ControlType.Triangle:
5162
                    {
5163
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5164
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5165
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5166
                    }
5167
                    break;
5168
                default:
5169
                    {
5170
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5171
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5172
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5173
                    }
5174
                    break;
5175
            }
5176

    
5177
            return Return_Point;
5178
        }
5179

    
5180
        /// <summary>
5181
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5182
        /// </summary>
5183
        /// <author>humkyung</author>
5184
        /// <date>2018.04.26</date>
5185
        /// <param name="StartP"></param>
5186
        /// <param name="EndP"></param>
5187
        /// <returns></returns>
5188
        /// <history>humkyung 2018.05.11 apply axis lock</history>
5189
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
5190
        {
5191
            List<Point> res = new List<Point>();
5192

    
5193
            double dx = EndP.X - StartP.X;
5194
            double dy = EndP.Y - StartP.Y;
5195
            double length = Math.Sqrt(dx * dx + dy * dy);
5196
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
5197
            dx /= length;
5198
            dy /= length;
5199
            double tmp = dx;
5200
            dx = -dy; dy = tmp; /// rotate by 90 degree
5201

    
5202
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5203
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5204

    
5205
            return res;
5206
        }
5207

    
5208
        /// <summary>
5209
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5210
        /// </summary>
5211
        /// <author>ingu</author>
5212
        /// <date>2018.06.05</date>
5213
        /// <param name="getPoint"></param>
5214
        /// <returns></returns>
5215
        private bool IsGetoutpoint(Point getPoint)
5216
        {
5217
            if (getPoint == new Point())
5218
            {
5219
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5220
                currentControl = null;
5221
                return true;
5222
            }
5223

    
5224
            return false;
5225
        }
5226

    
5227
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5228
        {
5229
            e.Effects = DragDropEffects.Copy;
5230
        }
5231

    
5232
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5233
        {
5234
            e.Effects = DragDropEffects.Copy;
5235
        }
5236

    
5237
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5238
        {
5239
            e.Effects = DragDropEffects.None;
5240
        }
5241

    
5242
        /*
5243
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5244
        {
5245
            try
5246
            {
5247
                if (e.Data.GetDataPresent(typeof(string)))
5248
                {
5249
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5250
                    string dragData = e.Data.GetData(typeof(string)) as string;
5251
                    Move_Symbol(sender, dragData);
5252
                }
5253
            }
5254
            catch (Exception ex)
5255
            {
5256
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5257
            }            
5258
        }
5259
        */
5260
    }
5261
}
클립보드 이미지 추가 (최대 크기: 500 MB)