프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (246 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 CommentUserInfo currentControl { get; set; }
126
        public ControlType controlType { get; set; }
127
        private Move move = new Move();
128
        private double[] rotateValue = { 0, 90, 180, 270 };
129
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
130
        private static readonly double DragThreshold = 5;
131
        private System.Windows.Input.Cursor cursor { get; set; }
132
        private Point canvasDrawingMouseDownPoint;
133
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137
        List<object> ControlList = new List<object>();
138
        private ListBox listBox = new ListBox();
139
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
140
        private bool isDraggingSelectionRect = false;
141
        DrawingAttributes inkDA = new DrawingAttributes();
142
        private VPRevision CurrentRev { get; set; }
143
        public RadRibbonButton btnConsolidate { get; set; }
144
        public RadRibbonButton btnFinalPDF { get; set; }
145
        public RadRibbonButton btnTeamConsolidate { get; set; }
146
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
147

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

    
237
        public MainMenu()
238
        {
239
            App.splashString(ISplashMessage.MAINMENU_0);
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
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
391
                imageViewer_Compare = new Image();
392
                ViewerDataModel.Instance.Capture_Opacity = 0;
393
                da.From = 0.8;
394
                da.To = 0;
395
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
396
                da.AutoReverse = true;
397
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
398

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

    
409
        
410

    
411
        private void timercallback(Object o)
412
        {
413
            Stopwatch sw = new Stopwatch();
414
            sw.Start();
415
            TempFile.TempFileAdd();
416
            sw.Stop();
417

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

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

    
440
            /// add or update markup list
441
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
442
            {
443
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
444

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

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

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

    
491
                    GroupDescriptor descriptor = new GroupDescriptor();
492
                    descriptor.Member = "Depatment";
493
                    descriptor.DisplayContent = "DEPT";
494
                    descriptor.SortDirection = ListSortDirection.Ascending;
495
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
496
                }
497
            }
498
        }
499

    
500
        bool ComingNewBieEnd = false;
501

    
502
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
503
        {
504
            if (zoomAndPanCanvas2.Width.IsNaN())
505
            {
506
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
507
            }
508

    
509
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
510
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
511

    
512
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
513
            foreach (var info in gridSelectionItem)
514
            {
515
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
516
            }
517
            /// fire selection event
518
            this.gridViewMarkup.UnselectAll();
519
            this.gridViewMarkup.Select(gridSelectionItem);
520

    
521
            if (!testPanel2.IsHidden)
522
            {
523
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
524
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
525
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
526

    
527
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
528
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
529

    
530

    
531
                foreach (var item in gridSelectionRevItem)
532
                {
533
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
534
                    {
535
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
536
                    });
537
                }
538
            }
539

    
540
            var instanceMain = this.ParentOfType<MainWindow>();
541
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
542
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
543

    
544
            instanceMain.dzTopMenu.rotateOffSet = 0;
545
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
546
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
547

    
548
            //}
549
            SetCommentPages(true);
550
        }
551
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
552
        {
553
            App.splashString(ISplashMessage.MAINMENU_1);
554
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
555
            {            
556
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
557
            }
558
            
559
            ViewerDataModel.Instance.UndoDataList.Clear();
560

    
561
            ConvertInkControlToPolygon();
562

    
563
            SelectionSet.Instance.UnSelect(this);
564
            UpdateMyMarkupList();
565

    
566
            CompareMode.IsChecked = false;
567
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
568

    
569

    
570
            #region 페이지가 벗어난 경우
571

    
572
            if (BalancePoint < 1)
573
            {
574
                BalancePoint = 1;
575
                ViewerDataModel.Instance.PageBalanceNumber = 0;
576
            }
577

    
578
            if (pageNavigator.PageCount < BalancePoint)
579
            {
580
                BalancePoint = pageNavigator.PageCount;
581
                ViewerDataModel.Instance.PageBalanceNumber = 0;
582
            }
583

    
584
            #endregion
585

    
586
            ViewerDataModel.Instance.PageNumber = BalancePoint;
587

    
588
            string uri = "";
589
            if (userData.COMPANY != "EXT")
590
            {
591
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
592
            }
593
            else
594
            {
595
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
596
            }
597

    
598
            var defaultBitmapImage = new BitmapImage();
599
            defaultBitmapImage.BeginInit();
600
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
601
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
602
            defaultBitmapImage.UriSource = new Uri(uri);
603
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
604
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
605
            defaultBitmapImage.EndInit();
606

    
607
            ViewerDataModel.Instance.ImageViewPath = null;
608

    
609
            App.splashString(ISplashMessage.MAINMENU_2);
610
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
611
            if (defaultBitmapImage.IsDownloading)
612
            {
613
                App.splashString(ISplashMessage.MAINMENU_4);
614
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
615
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
616
                {                   
617
                    defaultBitmapImage.Freeze();                                        
618
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
619
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
620
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
621
                    mainPanel.UpdateLayout();
622
                    this.pageNavigator.SetNextPage(); 
623
                    
624
                    //image dispose
625
                    defaultBitmapImage = null;
626
                    GC.Collect();
627
                };
628
            }
629

    
630
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
631
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
632

    
633

    
634
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
635
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
636
            inkBoard.Width = zoomAndPanCanvas.Width;
637
            inkBoard.Height = zoomAndPanCanvas.Height;
638

    
639

    
640

    
641
            if (!testPanel2.IsHidden)
642
            {
643
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
644
                //PDF모드일때 잠시 대기(강인구)
645
                if (IsSyncPDFMode)
646
                {
647
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
648
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
649

    
650
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
651
                    if (pdfpath.IsDownloading)
652
                    {
653
                        pdfpath.DownloadCompleted += (ex, arg) =>
654
                        {
655
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
656
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
657
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
658
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
659
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
660
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
661
                        };
662
                    }
663
                    else
664
                    {
665
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
666
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
667
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
668
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
669

    
670
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
671
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
672
                    }
673
                }
674
                else
675
                {
676
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
677
                    string uri2 = "";
678
                    if (userData.COMPANY != "EXT")
679
                    {
680
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
681
                    }
682
                    else
683
                    {
684
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
685
                    }
686

    
687
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
688
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
689
                    defaultBitmapImage_Compare.BeginInit();
690
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
691
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
692
                    defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
693
                    defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
694
                    defaultBitmapImage_Compare.EndInit();
695

    
696
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
697

    
698
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
699
                    zoomAndPanControl.ZoomTo(new Rect
700
                    {
701
                        X = 0,
702
                        Y = 0,
703
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
704
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
705
                    });
706

    
707
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
708
                    if (defaultBitmapImage_Compare.IsDownloading)
709
                    {
710
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
711
                        {
712
                            defaultBitmapImage_Compare.Freeze();
713
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
714
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
715
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
716
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
717
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
718

    
719
                            zoomAndPanControl.ZoomTo(new Rect
720
                            {
721
                                X = 0,
722
                                Y = 0,
723
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
724
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
725
                            });
726

    
727
                            //defaultBitmapImage_Compare dispose
728
                            defaultBitmapImage_Compare = null;
729
                            GC.Collect();
730
                        };
731
                    }
732
                }
733
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
734
            }
735

    
736
        }
737

    
738

    
739
        
740

    
741
        private void SetCommentPages(bool onlyMe = false)
742
        {
743
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
744
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
745
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
746
            {
747
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
748
                instance.UserName = item.UserName;
749
                instance.Depart = item.Depatment;
750
                instance.MarkupInfoID = item.MarkupInfoID;
751
                instance.IsSelected = true;
752
                instance.isConSolidation = item.Consolidate;
753
                instance.SetColor = item.DisplayColor;
754
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
755
                {
756
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
757
                }
758
                else
759
                {
760
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
761
                }
762
                _pages.Add(instance);
763
            }
764
            this.pageNavigator.SetCommentList(_pages.ToList());
765
        }
766

    
767
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
768
        {
769
            if (e.MiddleButton == MouseButtonState.Pressed)
770
            {
771

    
772
            }
773
            e.Handled = true;
774
            if (e.Delta > 0)
775
            {
776
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
777
                ZoomIn(currentContentMousePoint);
778
            }
779
            else
780
            {
781
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
782
                ZoomOut(currentContentMousePoint);
783
            }
784
        }
785

    
786
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
787
        {
788
            e.Handled = true;
789
            if (e.Delta > 0)
790
            {
791
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
792
                ZoomIn_Sync(currentContentMousePoint);
793
            }
794
            else
795
            {
796
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
797
                ZoomOut_Sync(currentContentMousePoint);
798
            }
799
        }
800

    
801
        #region ZoomIn & ZoomOut
802

    
803
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
804
        {
805
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
806
                zoomAndPanControl.ContentZoomFocusY));
807
        }
808

    
809
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
810
        {
811
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
812
                zoomAndPanControl.ContentZoomFocusY));
813
        }
814

    
815

    
816
        //강인구 추가 (줌 인아웃 수치 변경)
817
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
818
        private void ZoomOut(Point contentZoomCenter)
819
        {
820
            if (zoomAndPanControl.ContentScale > 0.39)
821
            {
822
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
823
            }
824
            else
825
            {
826
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
827
            }
828

    
829
            if (zoomAndPanControl2 != null && Sync.IsChecked)
830
            {
831
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
832
            }
833
        }
834

    
835
        private void ZoomIn(Point contentZoomCenter)
836
        {
837
            if (zoomAndPanControl.ContentScale > 0.19)
838
            {
839
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
840
            }
841
            else
842
            {
843
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
844
            }
845

    
846
            if (zoomAndPanControl2 != null && Sync.IsChecked)
847
            {
848
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
849
            }
850

    
851
        }
852

    
853
        private void ZoomOut_Sync(Point contentZoomCenter)
854
        {
855
            if (zoomAndPanControl2.ContentScale > 0.39)
856
            {
857
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
858
            }
859
            else
860
            {
861
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
862
            }
863

    
864
            if (Sync.IsChecked)
865
            {
866
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
867
            }
868
        }
869

    
870
        private void ZoomIn_Sync(Point contentZoomCenter)
871
        {
872
            if (zoomAndPanControl2.ContentScale > 0.19)
873
            {
874
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
875
            }
876
            else
877
            {
878
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
879
            }
880

    
881
            if (Sync.IsChecked)
882
            {
883
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
884
            }
885
        }
886

    
887
        private void ZoomOut()
888
        {
889
            zoomAndPanControl.ContentScale -= 0.1;
890
            //if (zoomAndPanControl2 != null)
891
            //{
892
            //    zoomAndPanControl2.ContentScale -= 0.1;
893
            //}
894
        }
895

    
896
        private void ZoomIn()
897
        {
898
            zoomAndPanControl.ContentScale += 0.1;
899
            //if (zoomAndPanControl2 != null)
900
            //{
901
            //    zoomAndPanControl2.ContentScale += 0.1;
902
            //}
903
        }
904

    
905
        #endregion
906

    
907
        private void init()
908
        {
909
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
910
            {
911

    
912
                ControlList.Clear();
913
                listBox.Items.Clear();
914
                selected_item.Clear();
915

    
916
                (item as IMarkupCommonData).IsSelected = false;
917
            }
918

    
919
        }
920

    
921
        private HitTestResultBehavior MyCallback(HitTestResult result)
922
        {
923
            //this.cursor = Cursors.UpArrow;
924
            var element = result.VisualHit;
925
            while (element != null && !(element is CommentUserInfo))
926
                element = VisualTreeHelper.GetParent(element);
927

    
928
            if (element == null)
929
            {
930
                return HitTestResultBehavior.Stop;
931
            }
932
            else
933
            {
934
                if (element is CommentUserInfo)
935
                {
936
                    if (!hitList.Contains(element))
937
                    {
938
                        hitList.Add((CommentUserInfo)element);
939
                    }
940
                    else
941
                    {
942
                        return HitTestResultBehavior.Stop;
943
                    }
944
                }
945
            }
946
            return HitTestResultBehavior.Continue;
947
        }
948

    
949
        public void ReleaseSelectPath()
950
        {
951
            if (SelectionPath == null)
952
            {
953
                SelectionPath = new Path();
954
                SelectionPath.Name = "";
955
            }
956
            if (SelectionPath.Name != "")
957
            {
958
                SelectionPath.Name = "None";
959
            }
960
            SelectionPath.Opacity = 0.01;
961
            SelectionPath.RenderTransform = null;
962
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
963
        }
964

    
965
        #region 컨트롤 초기화 
966
        public void Control_Init(object control)
967
        {
968
            if (L_Size != 0 && (control as IPath) != null)
969
            {
970
                (control as IPath).LineSize = L_Size;
971
                L_Size = 0;
972
            }
973

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

    
1060
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1061
        {
1062
            //Control_Init(e.Source);
1063
        }
1064
        //private Window _dragdropWindow = null;
1065

    
1066
        [DllImport("user32.dll")]
1067
        [return: MarshalAs(UnmanagedType.Bool)]
1068
        internal static extern bool GetCursorPos(ref Win32Point pt);
1069

    
1070
        [StructLayout(LayoutKind.Sequential)]
1071
        internal struct Win32Point
1072
        {
1073
            public Int32 X;
1074
            public Int32 Y;
1075
        };
1076
        /*
1077
       public string symbol_id = null;
1078
       public long symbol_group_id;
1079
       public int symbol_SelectedIndex;
1080
       public ImageSource symbol_img;
1081
       public string symbol_Data = null;
1082
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1083
       {
1084
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1085
               zoomAndPanCanvas.ActualHeight / 2));
1086

    
1087

    
1088
               if (this._dragdropWindow != null)
1089
               {
1090
                   this._dragdropWindow.Close();
1091
                   this._dragdropWindow = null;
1092
               }
1093

    
1094
               symbol_id = id;
1095
               symbol_group_id = group_id;
1096
               symbol_SelectedIndex = SelectedIndex;
1097
               symbol_Data = Data_;
1098
               symbol_img = img;
1099

    
1100

    
1101
               CreateDragDropWindow2(img);
1102
              
1103
    }
1104

    
1105
    private void CreateDragDropWindow2(ImageSource image)
1106
        {
1107
            this._dragdropWindow = new Window();
1108
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1109
            _dragdropWindow.WindowStyle = WindowStyle.None;
1110
            _dragdropWindow.AllowsTransparency = true;           
1111
            _dragdropWindow.AllowDrop = false;
1112
            _dragdropWindow.Background = null;
1113
            _dragdropWindow.IsHitTestVisible = false;
1114
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1115
            _dragdropWindow.Topmost = true;
1116
            _dragdropWindow.ShowInTaskbar = false;
1117
            
1118
            Rectangle r = new Rectangle();
1119
            r.Width = image.Width;
1120
            r.Height = image.Height;
1121
            r.Opacity = 0.5;            
1122
            r.Fill = new ImageBrush(image);
1123
            this._dragdropWindow.Content = r;
1124

    
1125
            Win32Point w32Mouse = new Win32Point();
1126
            GetCursorPos(ref w32Mouse);
1127

    
1128
            //w32Mouse.X = getCurrentPoint.X;
1129
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1130
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1131
            this._dragdropWindow.Show();
1132
        }
1133
         */
1134
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1135
        {
1136
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1137
            {
1138
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1139

    
1140
                Point currentPos = e.GetPosition(rect);
1141

    
1142
                floatingTip.HorizontalOffset = currentPos.X + 20;
1143
                floatingTip.VerticalOffset = currentPos.Y;
1144
            }
1145

    
1146
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1147
            
1148
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1149
            {
1150
                SetCursor();
1151
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1152
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1153

    
1154
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1155
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1156
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1157

    
1158
                if (Sync.IsChecked)
1159
                {
1160
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1161
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1162
                }
1163
            }
1164

    
1165
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1166
            {
1167
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1168
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1169
                SetCursor();
1170

    
1171
                if (currentControl != null)
1172
                {
1173
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1174
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1175
                    //강인구 추가
1176
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1177

    
1178
                    if ((currentControl as IPath) != null)
1179
                    {
1180
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1181
                    }
1182
                    if ((currentControl as LineControl) != null)
1183
                    {
1184
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1185
                    }
1186

    
1187
                    if ((currentControl as IShapeControl) != null)
1188
                    {
1189
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1190
                    }
1191
                    if ((currentControl as TextControl) != null)
1192
                    {
1193
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1194
                        {
1195
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1196
                        }
1197
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1198
                        {
1199
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1200
                        }
1201
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1202
                        {
1203
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1204
                        }
1205
                    }
1206
                    else if ((currentControl as ArrowTextControl) != null)
1207
                    {
1208
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1209
                        {
1210
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1211
                        }
1212
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1213
                        {
1214
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1215
                        }
1216
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1217
                        {
1218
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1219
                        }
1220
                    }
1221
                    else if ((currentControl as RectCloudControl) != null)
1222
                    {
1223
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1224
                    }
1225
                    else if ((currentControl as CloudControl) != null)
1226
                    {
1227
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1228
                    }
1229

    
1230
                    switch (controlType)
1231
                    {
1232
                        case (ControlType.Coordinate):
1233
                            {
1234
                                var control = currentControl as CoordinateControl;
1235
                                if (control != null)
1236
                                {
1237
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1238
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1239
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1240
                                }
1241
                            }
1242
                            break;
1243
                        case (ControlType.InsideWhite):
1244
                            {
1245
                                var control = currentControl as InsideWhiteControl;
1246
                                if (control != null)
1247
                                {
1248
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1249
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1250
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1251
                                    control.Paint = PaintSet.Fill;
1252
                                }
1253
                            }
1254
                            break;
1255
                        case ControlType.OverlapWhite:
1256
                            {
1257
                                var control = currentControl as OverlapWhiteControl;
1258
                                if (control != null)
1259
                                {
1260
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1261
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1262
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1263
                                    control.Paint = PaintSet.Fill;
1264
                                }
1265
                            }
1266
                            break;
1267
                        case ControlType.ClipWhite:
1268
                            {
1269
                                var control = currentControl as ClipWhiteControl;
1270
                                if (control != null)
1271
                                {
1272
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1273
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1274
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1275
                                    control.Paint = PaintSet.Fill;
1276
                                }
1277
                            }
1278
                            break;
1279
                        case ControlType.RectCloud:
1280
                            {
1281
                                var control = currentControl as RectCloudControl;
1282
                                if (control != null)
1283
                                {
1284
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1285
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1286
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1287
                                }
1288
                            }
1289
                            break;
1290
                        case ControlType.SingleLine:
1291
                        case ControlType.CancelLine:
1292
                        case ControlType.ArrowLine:
1293
                        case ControlType.TwinLine:
1294
                        case ControlType.DimLine:
1295
                            {
1296
                                var control = currentControl as LineControl;
1297
                                if (control != null)
1298
                                {
1299
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1300
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1301
                                }
1302
                            }
1303
                            break;
1304

    
1305
                        case ControlType.ArcLine:
1306
                            {
1307
                                var control = currentControl as ArcControl;
1308
                                if (control != null)
1309
                                {
1310
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1311
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1312
                                }
1313
                            }
1314
                            break;
1315

    
1316
                        case ControlType.ArcArrow:
1317
                            {
1318
                                var control = currentControl as ArrowArcControl;
1319
                                if (control != null)
1320
                                {
1321
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1322
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1323
                                }
1324
                            }
1325
                            break;
1326

    
1327
                        case ControlType.ArrowMultiLine:
1328
                            {
1329
                                var control = currentControl as ArrowControl_Multi;
1330
                                if (control != null)
1331
                                {
1332
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1333
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1334
                                }
1335
                            }
1336
                            break;
1337

    
1338
                        case ControlType.Circle:
1339
                            {
1340
                                if (currentControl != null)
1341
                                {
1342
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1343
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1344
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1345
                                }
1346
                            }
1347
                            break;
1348

    
1349
                        case ControlType.PolygonCloud:
1350
                            {
1351
                                var control = currentControl as CloudControl;
1352
                                if (control != null)
1353
                                {
1354
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1355
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1356
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1357
                                }
1358
                            }
1359
                            break;
1360

    
1361
                        case ControlType.Triangle:
1362
                            {
1363
                                var control = currentControl as TriControl;
1364
                                if (control != null)
1365
                                {
1366
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1367
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1368
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1369
                                }
1370
                            }
1371
                            break;
1372

    
1373
                        case ControlType.ImgControl:
1374
                            {
1375
                                var control = currentControl as ImgControl;
1376
                                if (control != null)
1377
                                {
1378
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1379
                                }
1380
                            }
1381
                            break;
1382

    
1383
                        case ControlType.Date:
1384
                            {
1385
                                var control = currentControl as DateControl;
1386
                                if (control != null)
1387
                                {
1388
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1389
                                }
1390
                            }
1391
                            break;
1392

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

    
1493
                                //inkBoard.Strokes.Add(stroke);
1494
                            }
1495
                            break;
1496
                    }
1497
                    return;
1498
                }
1499
            }
1500
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1501
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1502
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1503
            {
1504
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1505

    
1506
                if (isDraggingSelectionRect)
1507
                {
1508
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1509
                    e.Handled = true;
1510
                }
1511
                else if (isLeftMouseButtonDownOnWindow)
1512
                {
1513
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1514
                    double dragDistance = Math.Abs(dragDelta.Length);
1515

    
1516
                    if (dragDistance > DragThreshold)
1517
                    {
1518
                        isDraggingSelectionRect = true;
1519
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1520
                    }
1521

    
1522
                    e.Handled = true;
1523
                }
1524

    
1525
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1526
                {
1527
                }
1528
                else
1529
                {
1530
                    e.Handled = true;
1531
                }
1532
            }
1533
            /*
1534
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1535
            { //symbol      
1536
                if(_dragdropWindow != null)
1537
                {
1538
                    Win32Point w32Mouse = new Win32Point();
1539
                    GetCursorPos(ref w32Mouse);
1540

    
1541
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1542
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1543
                }                
1544
            }
1545
            */
1546
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1547
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1548
            {
1549
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1550
                if(control != null)
1551
                {
1552
                    this.cursor = Cursors.Hand;
1553
                    SetCursor();
1554
                }
1555
                else
1556
                {
1557
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1558
                    SetCursor();
1559
                }
1560
            }
1561
            else
1562
            {
1563
            }
1564
        }
1565

    
1566
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1567
        {
1568
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1569
            {
1570
                SetCursor();
1571
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1572
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1573

    
1574
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1575

    
1576
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1577
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1578

    
1579
                if (Sync.IsChecked)
1580
                {
1581
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1582
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1583
                }
1584
            }
1585
        }
1586

    
1587
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1588

    
1589
        private EllipseGeometry hitArea = new EllipseGeometry();
1590

    
1591
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1592
        {
1593
            IsDrawing = false;
1594

    
1595
            if (mouseHandlingMode != MouseHandlingMode.None)
1596
            {
1597
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1598
                {
1599
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1600

    
1601
                    SetCursor();
1602

    
1603
                    switch (controlType)
1604
                    {
1605
                        case ControlType.None:
1606
                            break;
1607
                        case ControlType.Rectangle:
1608
                            {
1609

    
1610
                            }
1611
                            break;
1612
                        case ControlType.PenControl:
1613
                            {
1614

    
1615
                            }
1616
                            break;
1617
                        default:
1618
                            break;
1619
                    }
1620
                }
1621
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1622
                {
1623
                    if (isLeftMouseButtonDownOnWindow)
1624
                    {
1625
                        bool wasDragSelectionApplied = false;
1626

    
1627
                        if (isDraggingSelectionRect)
1628
                        {
1629
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1630
                            {
1631
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1632
                                mouseHandlingMode = MouseHandlingMode.None;
1633
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1634
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1635
                                Set_Symbol_Capture(endPoint);
1636
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1637
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1638
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1639
                            }
1640
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1641
                            {
1642
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1643
                                mouseHandlingMode = MouseHandlingMode.None;
1644
                                Set_Capture();
1645

    
1646
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1647
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1648
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1649
                            }
1650
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1651
                            {
1652
                                ApplyDragSelectionRect();
1653
                            }
1654
                            else
1655
                            {
1656
                                double x = Canvas.GetLeft(dragZoomBorder);
1657
                                double y = Canvas.GetTop(dragZoomBorder);
1658
                                double width = dragZoomBorder.Width;
1659
                                double height = dragZoomBorder.Height;
1660
                                Rect dragRect = new Rect(x, y, width, height);
1661

    
1662
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1663

    
1664
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1665
                            }
1666

    
1667
                            isDraggingSelectionRect = false;
1668
                            e.Handled = true;
1669
                            wasDragSelectionApplied = true;
1670
                        }
1671

    
1672
                        if (isLeftMouseButtonDownOnWindow)
1673
                        {
1674
                            isLeftMouseButtonDownOnWindow = false;
1675
                            this.ReleaseMouseCapture();
1676
                            e.Handled = true;
1677
                        }
1678

    
1679
                        if (!wasDragSelectionApplied)
1680
                        {
1681
                            init();
1682
                        }
1683
                    }
1684
                }
1685
                else if (e.RightButton == MouseButtonState.Pressed)
1686
                {
1687
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1688
                    SetCursor();
1689
                }
1690

    
1691
                zoomAndPanControl.ReleaseMouseCapture();
1692

    
1693

    
1694
                e.Handled = true;
1695
            }
1696
            else
1697
            {
1698
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1699
                SetCursor();
1700
            }
1701

    
1702
            ///mouseButtonDown = MouseButton.Left;
1703
            //controlType = ControlType.SingleLine;
1704
        }
1705

    
1706
        public void Set_Symbol_Capture(Point endPoint)
1707
        {       
1708
            double x = canvasDrawingMouseDownPoint.X;
1709
            double y = canvasDrawingMouseDownPoint.Y;
1710
            if(x > endPoint.X)
1711
            {
1712
                x = endPoint.X;
1713
                y = endPoint.Y;
1714
            }
1715

    
1716
            double width = dragCaptureBorder.Width;
1717
            double height = dragCaptureBorder.Height;
1718

    
1719
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1720

    
1721
            if (x < 0)
1722
            {
1723
                width += x;
1724
                x = 0;
1725
            }
1726
            if (y < 0)
1727
            {
1728
                height += y;
1729
                y = 0;
1730

    
1731
                width = (int)canvasImage.PixelWidth - x;
1732
            }
1733
            if (x + width > canvasImage.PixelWidth)
1734
            {
1735
                width = (int)canvasImage.PixelWidth - x;
1736
            }
1737
            if (y + height > canvasImage.PixelHeight)
1738
            {
1739
                height = (int)canvasImage.PixelHeight - y;
1740
            }
1741
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1742

    
1743
            string uri = "";
1744
            if (userData.COMPANY != "EXT")
1745
            {
1746
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1747
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1748
            }
1749
            else
1750
            {
1751
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1752
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1753
            }
1754

    
1755
            var defaultBitmapImage = new BitmapImage();
1756
            defaultBitmapImage.BeginInit();
1757
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1758
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1759
            defaultBitmapImage.UriSource = new Uri(uri);
1760
            defaultBitmapImage.EndInit();
1761

    
1762
            //GC.Collect();
1763

    
1764
            if (defaultBitmapImage.IsDownloading)
1765
            {
1766
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1767
                {
1768
                    defaultBitmapImage.Freeze();
1769
                    //GC.Collect();
1770
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1771
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1772
                };
1773
            }
1774
        }
1775

    
1776
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1777
        {
1778
            ///mouseButtonDown = MouseButton.Left;
1779
        }
1780

    
1781
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1782
        {
1783
            ///mouseButtonDown = MouseButton.Left;
1784
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1785
        }
1786

    
1787
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1788
        {
1789

    
1790
        }
1791

    
1792
        /// <summary>
1793
        /// select items by dragging
1794
        /// </summary>
1795
        private void ApplyDragSelectionRect()
1796
        {
1797
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1798

    
1799
            double x = Canvas.GetLeft(dragSelectionBorder);
1800
            double y = Canvas.GetTop(dragSelectionBorder);
1801
            double width = dragSelectionBorder.Width;
1802
            double height = dragSelectionBorder.Height;
1803
            Boolean Flag = false;
1804
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1805
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1806

    
1807
            Rect dragRect = new Rect(x, y, width, height);
1808
            ///dragRect.Inflate(width / 10, height / 10);
1809

    
1810
            foreach (var item in Items)
1811
            {
1812
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1813

    
1814
                if (Flag)
1815
                {
1816
                    adornerSet.Add(item);
1817
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1818
                    Control_Style(item);
1819
                }
1820
            }
1821
            if (adornerSet.Count > 0)
1822
            {
1823
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1824
                SelectLayer.Children.Add(final);
1825
            }
1826
        }
1827

    
1828
        private void InitDragSelectionRect(Point pt1, Point pt2)
1829
        {
1830
            //캡쳐 중
1831
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1832
            {
1833
                dragCaptureBorder.Visibility = Visibility.Visible;
1834
            }
1835
            //선택 중
1836
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1837
            {
1838

    
1839
                dragSelectionBorder.Visibility = Visibility.Visible;
1840
            }
1841
            else
1842
            {
1843
                dragZoomBorder.Visibility = Visibility.Visible;
1844
            }
1845
            UpdateDragSelectionRect(pt1, pt2);
1846
        }
1847

    
1848
        /// <summary>
1849
        /// Update the position and size of the rectangle used for drag selection.
1850
        /// </summary>
1851
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1852
        {
1853
            double x, y, width, height;
1854

    
1855
            //
1856
            // Determine x,y,width and height of the rect inverting the points if necessary.
1857
            // 
1858

    
1859
            if (pt2.X < pt1.X)
1860
            {
1861
                x = pt2.X;
1862
                width = pt1.X - pt2.X;
1863
            }
1864
            else
1865
            {
1866
                x = pt1.X;
1867
                width = pt2.X - pt1.X;
1868
            }
1869

    
1870
            if (pt2.Y < pt1.Y)
1871
            {
1872
                y = pt2.Y;
1873
                height = pt1.Y - pt2.Y;
1874
            }
1875
            else
1876
            {
1877
                y = pt1.Y;
1878
                height = pt2.Y - pt1.Y;
1879
            }
1880

    
1881
            //
1882
            // Update the coordinates of the rectangle used for drag selection.
1883
            //
1884
            //캡쳐 중
1885
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1886
            {
1887
                Canvas.SetLeft(dragCaptureBorder, x);
1888
                Canvas.SetTop(dragCaptureBorder, y);
1889
                dragCaptureBorder.Width = width;
1890
                dragCaptureBorder.Height = height;
1891
            }
1892
            //선택 중
1893
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1894
            {
1895
                Canvas.SetLeft(dragSelectionBorder, x);
1896
                Canvas.SetTop(dragSelectionBorder, y);
1897
                dragSelectionBorder.Width = width;
1898
                dragSelectionBorder.Height = height;
1899
            }
1900
            else
1901
            {
1902
                Canvas.SetLeft(dragZoomBorder, x);
1903
                Canvas.SetTop(dragZoomBorder, y);
1904
                dragZoomBorder.Width = width;
1905
                dragZoomBorder.Height = height;
1906
            }
1907
        }
1908

    
1909
        private void drawingPannelRotate(double angle)
1910
        {
1911
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1912
            rotate.Angle = angle;
1913
            var rotationNum = Math.Abs((rotate.Angle / 90));
1914

    
1915
            if (angle == 90 || angle == 270)
1916
            {
1917
                double emptySize = zoomAndPanCanvas.Width;
1918
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1919
                zoomAndPanCanvas.Height = emptySize;
1920
            }
1921
            if (angle == 0)
1922
            {
1923
                translate.X = 0;
1924
                translate.Y = 0;
1925
            }
1926
            else if (angle == 90)
1927
            {
1928
                translate.X = zoomAndPanCanvas.Width;
1929
                translate.Y = 0;
1930
            }
1931
            else if (angle == 180)
1932
            {
1933
                translate.X = zoomAndPanCanvas.Width;
1934
                translate.Y = zoomAndPanCanvas.Height;
1935
            }
1936
            else
1937
            {
1938
                translate.X = 0;
1939
                translate.Y = zoomAndPanCanvas.Height;
1940
            }
1941

    
1942
            zoomAndPanControl.RotationAngle = rotate.Angle;
1943

    
1944

    
1945
            if (!testPanel2.IsHidden)
1946
            {
1947
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1948
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1949
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1950
            }
1951

    
1952
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1953
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1954
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1955
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1956
            ViewerDataModel.Instance.Angle = rotate.Angle;
1957
        }
1958

    
1959
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1960
        {
1961
            string Data_ = "";
1962

    
1963
            try
1964
            {
1965
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1966
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1967
                if (Data_ != null || Data_ != "")
1968
                {
1969
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1970
                }
1971
                else
1972
                {
1973
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1974
                }
1975

    
1976
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1977
                //{
1978
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1979
                //    STATE = 0,
1980
                //};
1981
                if (Data_ != null)
1982
                {
1983
                    Image img = new Image();
1984
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1985
                    if (Data_.Contains(".svg"))
1986
                    {
1987
                        byte[] imageData = null;
1988
                        DrawingImage image = null;
1989
                        using (System.Net.WebClient web = new System.Net.WebClient())
1990
                        {
1991
                            imageData = web.DownloadData(new Uri(Data_));
1992
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1993
                            image = SvgReader.Load(stream);
1994
                        }
1995
                        img.Source = image;
1996
                    }
1997
                    else
1998
                    {
1999
                        img.Source = new BitmapImage(new Uri(Data_));
2000
                    }
2001

    
2002
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2003
                    {
2004
                        PointSet = new List<Point>(),
2005
                        FilePath = Data_,
2006
                        ImageData = img.Source,
2007
                        StartPoint = canvasZoomPanningMouseDownPoint,
2008
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2009
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2010
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2011
                        canvasZoomPanningMouseDownPoint.Y),
2012
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2013
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2014
                    };
2015

    
2016
                    currentControl.PointSet = new List<Point>
2017
                                        {
2018
                                            currentControl.StartPoint,
2019
                                            currentControl.LeftBottomPoint,
2020
                                            currentControl.EndPoint,
2021
                                            currentControl.TopRightPoint,
2022
                                        };
2023
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2024
                    UndoData = new Undo_data()
2025
                    {
2026
                        IsUndo = false,
2027
                        Event = Event_Type.Create,
2028
                        EventTime = DateTime.Now,
2029
                        Markup_List = new List<Multi_Undo_data>()
2030
                    };
2031
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2032
                    {
2033
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2034
                    });
2035

    
2036
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2037
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2038
                    UndoData.Markup_List.Add(multi_Undo_Data);
2039
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2040

    
2041
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2042
                    currentControl.CommentID = Commons.shortGuid();
2043
                    currentControl.SymbolID = id;
2044
                    currentControl.GroupID = group_id;
2045
                    currentControl.ApplyTemplate();
2046
                    currentControl.SetImage();
2047

    
2048
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2049
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2050
                    SelectLayer.Children.Add(final);
2051
                }
2052
            }
2053
            catch (Exception ex)
2054
            {
2055
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2056
            }
2057
        }
2058

    
2059
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2060
        {            
2061
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2062
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2063
            {
2064
                set_option.Value = double.Parse(set_option.ContentText);
2065
            }
2066

    
2067
            ConvertInkControlToPolygon();
2068

    
2069
            ///TODO:
2070
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2071
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2072

    
2073
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2074
            {
2075
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2076
            }
2077
            /// up to here
2078

    
2079
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2080
            {
2081
                if (arrow_text as ArrowTextControl != null)
2082
                {
2083
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2084
                }
2085
            }
2086

    
2087
            //if (currentControl != null)
2088
            {
2089
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2090
                if (text_item_ != null)
2091
                {
2092
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2093
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2094
                    (text_item_ as TextControl).EnableEditing = false;
2095
                    currentControl = null;
2096
                }
2097

    
2098
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2099
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2100
                {
2101
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2102
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2103
                    currentControl = null;
2104
                }
2105
            }
2106

    
2107
            double Ang = 0;                                          
2108
            if (rotate.Angle != 0)
2109
            {
2110
                Ang = 360 - rotate.Angle;
2111
            }
2112

    
2113
            if (e.OriginalSource is System.Windows.Controls.Image)
2114
            {
2115
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2116
            }
2117
            /*
2118
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2119
            {                
2120
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2121
                if(symbol_id != null)
2122
                {
2123
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2124
                }                
2125
            }
2126

    
2127
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2128
            {
2129
                if (this._dragdropWindow != null)
2130
                {
2131
                    this._dragdropWindow.Close();
2132
                    this._dragdropWindow = null;
2133
                    symbol_id = null;
2134
                }
2135
            }
2136
            */
2137

    
2138
            if (e.LeftButton == MouseButtonState.Pressed)
2139
            {
2140
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2141
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2142

    
2143
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2144
                SetCursor();
2145

    
2146
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2147
            }
2148

    
2149
            if (e.MiddleButton == MouseButtonState.Pressed)
2150
            {
2151
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2152
                cursor = Cursors.SizeAll;
2153
                SetCursor();
2154
            }
2155
            if (e.RightButton == MouseButtonState.Pressed)
2156
            {
2157
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2158
                cursor = Cursors.SizeAll;
2159
                SetCursor();
2160
            }
2161
            else if (e.XButton1 == MouseButtonState.Pressed)
2162
            {
2163
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2164
                {
2165
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2166
                }
2167

    
2168
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2169

    
2170
            }
2171
            else if (e.XButton2 == MouseButtonState.Pressed)
2172
            {
2173
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2174
                {
2175
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2176
                }
2177
            }
2178

    
2179
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2180
            {
2181
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2182
                {
2183
                    if (SelectLayer.Children.Count == 0)
2184
                    {
2185
                        isLeftMouseButtonDownOnWindow = true;
2186
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2187
                    }
2188

    
2189
                    if (controlType == ControlType.None)
2190
                    {
2191
                        isLeftMouseButtonDownOnWindow = true;
2192
                    }
2193
                }
2194

    
2195
                /// 캡쳐 모드 설정
2196
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2197
                {
2198
                    dragCaptureBorder.Visibility = Visibility.Visible;
2199
                    isLeftMouseButtonDownOnWindow = true;
2200
                }
2201

    
2202
                /// 줌 모드 설정
2203
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2204
                {
2205
                    isLeftMouseButtonDownOnWindow = true;
2206
                }
2207

    
2208
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2209
                if (control != null)
2210
                {
2211
                    AdornerFinal final = null;
2212

    
2213
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2214
                    {
2215
                        /// 기존 selection 해제
2216
                        SelectionSet.Instance.UnSelect(this);
2217

    
2218
                        final = new AdornerFinal(control);
2219

    
2220
                        this.Control_Style(control);
2221

    
2222
                        if ((control as IPath) != null)
2223
                        {
2224
                            if ((control as IPath).LineSize != 0)
2225
                            {
2226
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2227
                            }
2228
                        }
2229
                        if ((control as IShapeControl) != null)
2230
                        {
2231
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2232
                            {
2233
                                ViewerDataModel.Instance.checkHatchShape = true;
2234
                            }
2235
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2236
                            {
2237
                                ViewerDataModel.Instance.checkFillShape = true;
2238
                            }
2239
                            else
2240
                            {
2241
                                ViewerDataModel.Instance.checkHatchShape = false;
2242
                                ViewerDataModel.Instance.checkFillShape = false;
2243
                            }
2244
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2245
                        }
2246

    
2247
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2248

    
2249
                        if ((control as TextControl) != null)
2250
                        {
2251
                            if(!((control as TextControl).EnableEditing)) {
2252
                                (control as TextControl).EnableEditing = true;
2253
                            }
2254

    
2255
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2256
                            {
2257
                                ViewerDataModel.Instance.checkTextStyle = true;
2258
                            }
2259
                            else
2260
                            {
2261
                                ViewerDataModel.Instance.checkTextStyle = false;
2262
                            }
2263

    
2264
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2265
                            {
2266
                                ViewerDataModel.Instance.checkTextStyle = true;
2267
                            }
2268
                            else
2269
                            {
2270
                                ViewerDataModel.Instance.checkTextStyle = false;
2271
                            }
2272
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2273
                            {
2274
                                ViewerDataModel.Instance.checkTextWeight = true;
2275
                            }
2276
                            else
2277
                            {
2278
                                ViewerDataModel.Instance.checkTextWeight = false;
2279
                            }
2280
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2281
                            {
2282
                                ViewerDataModel.Instance.checkUnderLine = true;
2283
                            }
2284
                            else
2285
                            {
2286
                                ViewerDataModel.Instance.checkUnderLine = false;
2287
                            }
2288
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2289
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2290

    
2291
                        }
2292
                        else if ((control as ArrowTextControl) != null)
2293
                        {
2294
                            if (!((control as ArrowTextControl).EnableEditing))
2295
                            {
2296
                                (control as ArrowTextControl).EnableEditing = true;
2297
                            }
2298
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2299
                            {
2300
                                ViewerDataModel.Instance.checkTextStyle = true;
2301
                            }
2302
                            else
2303
                            {
2304
                                ViewerDataModel.Instance.checkTextStyle = false;
2305
                            }
2306

    
2307
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2308
                            {
2309
                                ViewerDataModel.Instance.checkTextStyle = true;
2310
                            }
2311
                            else
2312
                            {
2313
                                ViewerDataModel.Instance.checkTextStyle = false;
2314
                            }
2315
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2316
                            {
2317
                                ViewerDataModel.Instance.checkTextWeight = true;
2318
                            }
2319
                            else
2320
                            {
2321
                                ViewerDataModel.Instance.checkTextWeight = false;
2322
                            }
2323
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2324
                            {
2325
                                ViewerDataModel.Instance.checkUnderLine = true;
2326
                            }
2327
                            else
2328
                            {
2329
                                ViewerDataModel.Instance.checkUnderLine = false;
2330
                            }
2331
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2332
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2333
                        }
2334
                        else if ((control as RectCloudControl) != null)
2335
                        {
2336
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2337
                        }
2338
                        else if ((control as CloudControl) != null)
2339
                        {
2340
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2341
                        }
2342
                    }
2343
                    else
2344
                    {
2345
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2346
                        SelectionSet.Instance.UnSelect(this);
2347
                        comment.Add(control);
2348

    
2349
                        Control_Style(control);
2350

    
2351
                        final = new AdornerFinal(comment);
2352
                    }
2353

    
2354
                    if (final != null)
2355
                    {
2356
                        this.SelectLayer.Children.Add(final);
2357
                    }
2358
                }              
2359
            }
2360
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2361
            {               
2362
                init();
2363
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2364
                if (cursor != Cursors.SizeAll)
2365
                {
2366
                    cursor = Cursors.Cross;
2367
                    SetCursor();
2368
                }
2369
                bool init_user = false;
2370
                foreach (var user in gridViewMarkup.Items)
2371
                {
2372
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2373
                    {
2374
                        init_user = true;
2375
                    }
2376
                }
2377
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2378
                {
2379
                    RadWindow.Alert(new DialogParameters
2380
                    {
2381
                        Owner = Application.Current.MainWindow,
2382
                        Theme = new VisualStudio2013Theme(),
2383
                        Header = "안내",
2384
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2385
                    });
2386
                    return;
2387
                }
2388
                else
2389
                {
2390
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2391
                    if (item != null)
2392
                    {
2393
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2394
                    }
2395
                }
2396

    
2397
                switch (controlType)
2398
                {
2399
                    case ControlType.Coordinate:
2400
                        {
2401
                            if (e.LeftButton == MouseButtonState.Pressed)
2402
                            {
2403
                                if (currentControl is CoordinateControl)
2404
                                {
2405
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2406
                                    {
2407
                                        return;
2408
                                    }
2409

    
2410
                                    CreateCommand.Instance.Execute(currentControl);
2411

    
2412
                                    currentControl = null;
2413
                                    this.cursor = Cursors.Arrow;
2414
                                }
2415
                                else
2416
                                {
2417
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2418
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2419
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2420
                                    {
2421
                                        currentControl = null;
2422
                                        this.cursor = Cursors.Arrow;
2423
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2424
                                        return;
2425
                                    }
2426
                                    else
2427
                                    {
2428
                                        currentControl = new CoordinateControl
2429
                                        {
2430
                                            Background = new SolidColorBrush(Colors.Black),
2431
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2432
                                            ControlType = ControlType.Coordinate
2433
                                        };
2434

    
2435
                                        currentControl.CommentID = Commons.shortGuid();
2436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2437
                                        currentControl.IsNew = true;
2438

    
2439
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2440

    
2441
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2442
                                    }
2443
                                }
2444
                            }
2445
                        }
2446
                        break;
2447
                    case ControlType.InsideWhite:
2448
                        {
2449
                            if (e.LeftButton == MouseButtonState.Pressed)
2450
                            {
2451
                                if (currentControl is InsideWhiteControl)
2452
                                {
2453
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2454
                                    {
2455
                                        return;
2456
                                    }
2457

    
2458
                                    CreateCommand.Instance.Execute(currentControl);
2459

    
2460
                                    currentControl = null;
2461
                                    this.cursor = Cursors.Arrow;
2462
                                }
2463
                                else
2464
                                {
2465
                                    currentControl = new InsideWhiteControl
2466
                                    {
2467
                                        Background = new SolidColorBrush(Colors.Black),
2468
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2469
                                        ControlType = ControlType.InsideWhite
2470
                                    };
2471

    
2472
                                    currentControl.CommentID = Commons.shortGuid();
2473
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2474
                                    currentControl.IsNew = true;
2475
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2476

    
2477
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2478
                                }
2479
                            }
2480
                        }
2481
                        break;
2482
                    case ControlType.OverlapWhite:
2483
                        {
2484
                            if (e.LeftButton == MouseButtonState.Pressed)
2485
                            {
2486
                                if (currentControl is OverlapWhiteControl)
2487
                                {
2488
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2489
                                    {
2490
                                        return;
2491
                                    }
2492

    
2493
                                    CreateCommand.Instance.Execute(currentControl);
2494

    
2495
                                    currentControl = null;
2496
                                    this.cursor = Cursors.Arrow;
2497
                                }
2498
                                else
2499
                                {
2500
                                    currentControl = new OverlapWhiteControl
2501
                                    {
2502
                                        Background = new SolidColorBrush(Colors.Black),
2503
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2504
                                        ControlType = ControlType.OverlapWhite
2505
                                    };
2506

    
2507
                                    currentControl.CommentID = Commons.shortGuid();
2508
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2509
                                    currentControl.IsNew = true;
2510
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2511

    
2512
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2513
                                }
2514
                            }
2515
                        }
2516
                        break;
2517
                    case ControlType.ClipWhite:
2518
                        {
2519
                            if (e.LeftButton == MouseButtonState.Pressed)
2520
                            {
2521
                                if (currentControl is ClipWhiteControl)
2522
                                {
2523
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2524
                                    {
2525
                                        return;
2526
                                    }
2527

    
2528
                                    CreateCommand.Instance.Execute(currentControl);
2529

    
2530
                                    currentControl = null;
2531
                                    this.cursor = Cursors.Arrow;
2532
                                }
2533
                                else
2534
                                {
2535
                                    currentControl = new ClipWhiteControl
2536
                                    {
2537
                                        Background = new SolidColorBrush(Colors.Black),
2538
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2539
                                        ControlType = ControlType.ClipWhite
2540
                                    };
2541

    
2542
                                    currentControl.CommentID = Commons.shortGuid();
2543
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2544
                                    currentControl.IsNew = true;
2545
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2546

    
2547
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2548
                                }
2549
                            }
2550
                        }
2551
                        break;
2552
                    case ControlType.Rectangle:
2553
                        {
2554
                            if (e.LeftButton == MouseButtonState.Pressed)
2555
                            {
2556
                                if (currentControl is RectangleControl)
2557
                                {
2558
                                    //20180906 LJY TEST IsRotationDrawingEnable
2559
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2560
                                    {
2561
                                        return;
2562
                                    }
2563

    
2564
                                    CreateCommand.Instance.Execute(currentControl);
2565
                                    currentControl = null;
2566
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2567
                                }
2568
                                else
2569
                                {
2570
                                    currentControl = new RectangleControl
2571
                                    {
2572
                                        Background = new SolidColorBrush(Colors.Black),
2573
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2574
                                        ControlType = ControlType.Rectangle
2575
                                    };
2576

    
2577
                                    currentControl.CommentID = Commons.shortGuid();
2578
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2579
                                    currentControl.IsNew = true;
2580
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2581

    
2582
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2583
                                }
2584
                            }
2585
                        }
2586
                        break;
2587
                    case ControlType.RectCloud:
2588
                        {
2589
                            if (e.LeftButton == MouseButtonState.Pressed)
2590
                            {
2591
                                if (currentControl is RectCloudControl)
2592
                                {
2593
                                    //20180906 LJY TEST IsRotationDrawingEnable
2594
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2595
                                    {
2596
                                        return;
2597
                                    }
2598

    
2599
                                    CreateCommand.Instance.Execute(currentControl);
2600

    
2601
                                    currentControl = null;
2602
                                
2603
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2604
                                }
2605
                                else
2606
                                {
2607
                                    currentControl = new RectCloudControl
2608
                                    {
2609
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2610
                                        ControlType = ControlType.RectCloud,
2611
                                        Background = new SolidColorBrush(Colors.Black)
2612
                                    };
2613

    
2614
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2615
                                    currentControl.CommentID = Commons.shortGuid();
2616
                                    currentControl.IsNew = true;
2617
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2618
                                }
2619
                            }
2620
                        }
2621
                        break;
2622
                    case ControlType.Circle:
2623
                        {
2624
                            if (e.LeftButton == MouseButtonState.Pressed)
2625
                            {
2626
                                if (currentControl is CircleControl)
2627
                                {
2628
                                    //20180906 LJY TEST IsRotationDrawingEnable
2629
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2630
                                    {
2631
                                        return;
2632
                                    }
2633

    
2634
                                    CreateCommand.Instance.Execute(currentControl);
2635

    
2636
                                    currentControl = null;
2637
                                }
2638
                                else
2639
                                {
2640
                                    currentControl = new CircleControl
2641
                                    {
2642
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2643
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2644
                                        Background = new SolidColorBrush(Colors.Black)
2645
                                    };
2646

    
2647
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2648
                                    currentControl.CommentID = Commons.shortGuid();
2649
                                    currentControl.IsNew = true;
2650
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2651
                                }
2652
                            }
2653
                        }
2654
                        break;
2655
                    case ControlType.Triangle:
2656
                        {
2657
                            if (e.LeftButton == MouseButtonState.Pressed)
2658
                            {
2659
                                if (currentControl is TriControl)
2660
                                {
2661
                                    var content = currentControl as TriControl;
2662
                                    if (content.MidPoint == new Point(0, 0))
2663
                                    {
2664
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2665
                                    }
2666
                                    else
2667
                                    {
2668
                                        //20180906 LJY TEST IsRotationDrawingEnable
2669
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2670
                                        {
2671
                                            return;
2672
                                        }
2673

    
2674
                                        CreateCommand.Instance.Execute(currentControl);
2675

    
2676
                                        currentControl = null;
2677
                                    }
2678
                                }
2679
                                else
2680
                                {
2681
                                    currentControl = new TriControl
2682
                                    {
2683
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2684
                                        Background = new SolidColorBrush(Colors.Black),
2685
                                    };
2686

    
2687
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2688
                                    currentControl.CommentID = Commons.shortGuid();
2689
                                    currentControl.IsNew = true;
2690
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2691
                                }
2692
                            }
2693
                        }
2694
                        break;
2695
                    case ControlType.CancelLine:
2696
                    case ControlType.SingleLine:
2697
                    case ControlType.ArrowLine:
2698
                    case ControlType.TwinLine:
2699
                    case ControlType.DimLine:
2700
                        {
2701
                            if (e.LeftButton == MouseButtonState.Pressed)
2702
                            {
2703
                                if (currentControl is LineControl)
2704
                                {
2705
                                    //20180906 LJY TEST IsRotationDrawingEnable
2706
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2707
                                    {
2708
                                        return;
2709
                                    }
2710

    
2711
                                    CreateCommand.Instance.Execute(currentControl);
2712
                                    currentControl = null;
2713
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2714
                                }
2715
                                else
2716
                                {
2717
                                    currentControl = new LineControl
2718
                                    {
2719
                                        ControlType = this.controlType,
2720
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2721
                                        Background = new SolidColorBrush(Colors.Black)
2722
                                    };
2723

    
2724
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2725
                                    currentControl.CommentID = Commons.shortGuid();
2726
                                    currentControl.IsNew = true;
2727
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2728
                                    this.MainAngle.Visibility = Visibility.Visible;
2729
                                }
2730
                            }
2731
                        }
2732
                        break;
2733
                    case ControlType.PolygonControl:
2734
                        {
2735
                            if (currentControl is PolygonControl)
2736
                            {
2737
                                var control = currentControl as PolygonControl;
2738

    
2739
                                if (e.RightButton == MouseButtonState.Pressed)
2740
                                {
2741
                                    control.IsCompleted = true;
2742
                                }
2743

    
2744
                                if (!control.IsCompleted)
2745
                                {
2746
                                    control.PointSet.Add(control.EndPoint);
2747
                                }
2748
                                else
2749
                                {
2750
                                    //20180906 LJY TEST IsRotationDrawingEnable
2751
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2752
                                    {
2753
                                        return;
2754
                                    }
2755

    
2756
                                    var firstPoint = control.PointSet.First();
2757
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2758
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2759
                                    control.PointSet.Add(firstPoint);
2760

    
2761
                                    control.ApplyOverViewData();
2762

    
2763
                                    CreateCommand.Instance.Execute(currentControl);
2764
                                    control.UpdateControl();
2765
                                    currentControl = null;
2766
                                }
2767
                            }
2768
                            else
2769
                            {
2770
                                if (e.LeftButton == MouseButtonState.Pressed)
2771
                                {
2772
                                    currentControl = new PolygonControl
2773
                                    {
2774
                                        PointSet = new List<Point>(),
2775
                                    };
2776

    
2777
                                    var polygonControl = (currentControl as PolygonControl);
2778
                                    currentControl.CommentID = Commons.shortGuid();
2779
                                    currentControl.IsNew = true;
2780
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2781
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2782
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2783
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2784
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2785
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2786
                                    polygonControl.ApplyTemplate();
2787
                                    polygonControl.Visibility = Visibility.Visible;
2788
                                }
2789
                            }
2790
                        }
2791
                        break;
2792
                    case ControlType.ChainLine:
2793
                        {
2794
                            if (currentControl is PolygonControl)
2795
                            {
2796
                                var control = currentControl as PolygonControl;
2797

    
2798
                                if (e.RightButton == MouseButtonState.Pressed)
2799
                                {
2800
                                    //20180906 LJY TEST IsRotationDrawingEnable
2801
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2802
                                    {
2803
                                        return;
2804
                                    }
2805

    
2806
                                    CreateCommand.Instance.Execute(currentControl);
2807

    
2808
                                    currentControl = null;
2809
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2810
                                    return;
2811
                                }
2812

    
2813
                                if (!control.IsCompleted)
2814
                                {
2815
                                    control.PointSet.Add(control.EndPoint);
2816
                                    this.MainAngle.Visibility = Visibility.Visible;
2817
                                }
2818
                            }
2819
                            else
2820
                            {
2821
                                if (e.LeftButton == MouseButtonState.Pressed)
2822
                                {
2823
                                    MainAngle.Visibility = Visibility.Visible;
2824
                                    currentControl = new PolygonControl
2825
                                    {
2826
                                        PointSet = new List<Point>(),
2827
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2828
                                        ControlType = ControlType.ChainLine,
2829
                                        DashSize = ViewerDataModel.Instance.DashSize,
2830
                                        LineSize = ViewerDataModel.Instance.LineSize,
2831
                                        //PointC = new StylusPointSet()
2832
                                    };
2833

    
2834
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2835
                                    //{
2836
                                        var polygonControl = (currentControl as PolygonControl);
2837
                                        currentControl.CommentID = Commons.shortGuid();
2838
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2839
                                        currentControl.IsNew = true;
2840
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2841
                                        //currentControl.OnApplyTemplate();
2842
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2843
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2844
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2845
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2846
                                    //}
2847
                                }
2848
                            }
2849
                        }
2850
                        break;
2851
                    case ControlType.ArcLine:
2852
                        {
2853
                            if (e.LeftButton == MouseButtonState.Pressed)
2854
                            {
2855
                                if (currentControl is ArcControl)
2856
                                {
2857
                                    //20180906 LJY TEST IsRotationDrawingEnable
2858
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2859
                                    {
2860
                                        return;
2861
                                    }
2862

    
2863
                                    CreateCommand.Instance.Execute(currentControl);
2864

    
2865
                                    currentControl = null;
2866
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2867
                                }
2868
                                else
2869
                                {
2870
                                    currentControl = new ArcControl
2871
                                    {
2872
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2873
                                        Background = new SolidColorBrush(Colors.Black)
2874
                                    };
2875
                                    currentControl.CommentID = Commons.shortGuid();
2876
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2877
                                    currentControl.IsNew = true;
2878
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2879
                                    this.MainAngle.Visibility = Visibility.Visible;
2880
                                }
2881
                            }
2882
                            else if (e.RightButton == MouseButtonState.Pressed)
2883
                            {
2884
                                if (currentControl != null)
2885
                                {
2886
                                    (currentControl as ArcControl).setClock();
2887
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2888
                                }
2889
                            }
2890
                        }
2891
                        break;
2892
                    case ControlType.ArcArrow:
2893
                        {
2894
                            if (e.LeftButton == MouseButtonState.Pressed)
2895
                            {
2896
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2897
                                //{
2898
                                if (currentControl is ArrowArcControl)
2899
                                {
2900
                                    //20180906 LJY TEST IsRotationDrawingEnable
2901
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2902
                                    {
2903
                                        return;
2904
                                    }
2905

    
2906
                                    CreateCommand.Instance.Execute(currentControl);
2907

    
2908
                                    currentControl = null;
2909
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2910
                                }
2911
                                else
2912
                                {
2913
                                    currentControl = new ArrowArcControl
2914
                                    {
2915
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2916
                                        Background = new SolidColorBrush(Colors.Black)
2917
                                    };
2918
                                    currentControl.CommentID = Commons.shortGuid();
2919
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2920
                                    currentControl.IsNew = true;
2921
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2922
                                    this.MainAngle.Visibility = Visibility.Visible;
2923
                                }
2924
                                //}
2925
                            }
2926
                            else if (e.RightButton == MouseButtonState.Pressed)
2927
                            {
2928
                                if (currentControl != null)
2929
                                {
2930
                                    (currentControl as ArrowArcControl).setClock();
2931
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2932
                                    //(currentControl as ArcControl).ApplyTemplate();
2933
                                }
2934
                            }
2935
                        }
2936
                        break;
2937
                    case ControlType.ArrowMultiLine:
2938
                        {
2939
                            if (e.LeftButton == MouseButtonState.Pressed)
2940
                            {
2941
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2942
                                //{
2943

    
2944
                                    if (currentControl is ArrowControl_Multi)
2945
                                    {
2946
                                        var content = currentControl as ArrowControl_Multi;
2947
                                        if (content.MiddlePoint == new Point(0, 0))
2948
                                        {
2949
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2950
                                            {
2951
                                                content.MiddlePoint = content.EndPoint;
2952
                                            }
2953
                                            else
2954
                                            {
2955
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2956
                                            }
2957
                                        }
2958
                                        else
2959
                                        {
2960
                                            //20180906 LJY TEST IsRotationDrawingEnable
2961
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2962
                                            {
2963
                                                return;
2964
                                            }
2965

    
2966
                                            CreateCommand.Instance.Execute(currentControl);
2967

    
2968
                                            currentControl = null;
2969
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2970
                                        }
2971
                                    }
2972
                                    else
2973
                                    {
2974
                                        currentControl = new ArrowControl_Multi
2975
                                        {
2976
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2977
                                            Background = new SolidColorBrush(Colors.Black)
2978
                                        };
2979
                                        currentControl.CommentID = Commons.shortGuid();
2980
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2981
                                        currentControl.IsNew = true;
2982
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2983
                                        this.MainAngle.Visibility = Visibility.Visible;
2984
                                    }
2985
                                //}
2986
                            }
2987
                        }
2988
                        break;
2989
                    case ControlType.PolygonCloud:
2990
                        {
2991
                            if (currentControl is CloudControl)
2992
                            {
2993
                                var control = currentControl as CloudControl;
2994
                                if (e.RightButton == MouseButtonState.Pressed)
2995
                                {
2996
                                    control.IsCompleted = true;
2997
                                }
2998

    
2999
                                if (!control.IsCompleted)
3000
                                {
3001
                                    control.PointSet.Add(control.EndPoint);
3002
                                }
3003
                                else
3004
                                {
3005
                                    //20180906 LJY TEST IsRotationDrawingEnable
3006
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3007
                                    {
3008
                                        return;
3009
                                    }
3010

    
3011
                                    CreateCommand.Instance.Execute(currentControl);
3012

    
3013
                                    control.isTransOn = true;
3014
                                    var firstPoint = control.PointSet.First();
3015

    
3016
                                    control.PointSet.Add(firstPoint);
3017
                                    control.DrawingCloud();
3018
                                    control.ApplyOverViewData();
3019

    
3020
                                    currentControl = null;
3021
                                }
3022
                            }
3023
                            else
3024
                            {
3025
                                if (e.LeftButton == MouseButtonState.Pressed)
3026
                                {
3027
                                    currentControl = new CloudControl
3028
                                    {
3029
                                        PointSet = new List<Point>(),
3030
                                        PointC = new StylusPointSet()
3031
                                    };
3032

    
3033
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3034
                                    //{
3035
                                        var polygonControl = (currentControl as CloudControl);
3036
                                        currentControl.CommentID = Commons.shortGuid();
3037
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3038
                                        currentControl.IsNew = true;
3039
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3040

    
3041
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3042
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3043
                                    
3044
                                    //}
3045
                                }
3046
                            }
3047
                        }
3048
                        break;
3049
                    case ControlType.ImgControl:
3050
                        {
3051
                            if (e.LeftButton == MouseButtonState.Pressed)
3052
                            {
3053
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3054
                                //{
3055
                                    if (currentControl is ImgControl)
3056
                                    {
3057
                                        //20180906 LJY TEST IsRotationDrawingEnable
3058
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3059
                                        {
3060
                                            return;
3061
                                        }
3062

    
3063
                                        CreateCommand.Instance.Execute(currentControl);
3064
                                        controlType = ControlType.ImgControl;
3065
                                        currentControl = null;
3066
                                    }
3067
                                    else
3068
                                    {
3069
                                        
3070
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3071
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3072
                                        {
3073
                                            Image img = new Image();
3074
                                            if (filename.Contains(".svg"))
3075
                                            {
3076
                                                byte[] imageData = null;
3077
                                                DrawingImage image = null;
3078
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3079
                                                {
3080
                                                    imageData = web.DownloadData(new Uri(filename));
3081
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3082
                                                    image = SvgReader.Load(stream);
3083
                                                }
3084
                                                img.Source = image;
3085
                                            }
3086
                                            else
3087
                                            {
3088
                                                img.Source = new BitmapImage(new Uri(filename));
3089
                                            }
3090

    
3091
                                            currentControl = new ImgControl
3092
                                            {
3093
                                                    Background = new SolidColorBrush(Colors.Black),
3094
                                                    PointSet = new List<Point>(),
3095
                                                    FilePath = filename,
3096
                                                    ImageData = img.Source,
3097
                                                    StartPoint = canvasDrawingMouseDownPoint,
3098
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3099
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3100
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3101
                                                    ControlType = ControlType.ImgControl
3102
                                                };
3103

    
3104
                                        
3105
                                                currentControl.CommentID = Commons.shortGuid();                                            
3106
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3107
                                                currentControl.IsNew = true;
3108
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3109

    
3110
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3111
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3112
                                        }
3113
                                    }
3114
                                //}
3115
                            }
3116
                        }
3117
                        break;
3118
                    case ControlType.Date:
3119
                        {
3120
                            if (e.LeftButton == MouseButtonState.Pressed)
3121
                            {
3122
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3123
                                //{
3124
                                    if (currentControl is DateControl)
3125
                                    {
3126
                                        //20180906 LJY TEST IsRotationDrawingEnable
3127
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3128
                                        {
3129
                                            return;
3130
                                        }
3131

    
3132
                                        CreateCommand.Instance.Execute(currentControl);
3133
                                        currentControl = null;
3134

    
3135
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3136
                                        {
3137
                                            controlType = ControlType.None;
3138
                                            IsSwingMode = false;
3139
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3140
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3141
                                            mouseHandlingMode = MouseHandlingMode.None;
3142
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3143
                                            txtBatch.Visibility = Visibility.Collapsed;
3144

    
3145
                                        }
3146
                                    }
3147
                                    else
3148
                                    {
3149
                                        currentControl = new DateControl
3150
                                        {
3151
                                            StartPoint = canvasDrawingMouseDownPoint,
3152
                                            Background = new SolidColorBrush(Colors.Black)
3153
                                        };
3154
                                        currentControl.CommentID = Commons.shortGuid();
3155
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3156
                                        currentControl.IsNew = true;
3157
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3158

    
3159
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3160
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3161
                                }
3162
                                //}
3163
                            }
3164
                        }
3165
                        break;
3166
                    case ControlType.TextControl:
3167
                        {
3168
                            if (e.LeftButton == MouseButtonState.Pressed)
3169
                            {
3170
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3171
                                {
3172
                                    currentControl = new TextControl
3173
                                    {
3174
                                        ControlType = controlType
3175
                                    };
3176
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3177
                                    currentControl.CommentID = Commons.shortGuid();
3178
                                    currentControl.IsNew = true;
3179
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3180
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3181
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3182

    
3183
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3184
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3185
                                    
3186
                                    (currentControl as TextControl).ControlType_No = 0;
3187
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3188
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3189
                                    (currentControl as TextControl).ApplyTemplate();
3190
                                    (currentControl as TextControl).Base_TextBox.Focus();
3191

    
3192
                                    CreateCommand.Instance.Execute(currentControl);
3193
                                }
3194
                            }
3195
                        }
3196
                        break;
3197
                    case ControlType.TextBorder:
3198
                        {
3199
                            if (e.LeftButton == MouseButtonState.Pressed)
3200
                            {
3201
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3202
                                {
3203
                                    currentControl = new TextControl
3204
                                    {
3205
                                        ControlType = controlType
3206
                                    };
3207

    
3208
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3209
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3210
                                    currentControl.CommentID = Commons.shortGuid();
3211
                                    currentControl.IsNew = true;
3212
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3213
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3214
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3215
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3216
                                    
3217
                                    (currentControl as TextControl).ControlType_No = 1;
3218
                                    (currentControl as TextControl).Angle = Ang;
3219
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3220
                                    (currentControl as TextControl).ApplyTemplate();
3221
                                    (currentControl as TextControl).Base_TextBox.Focus();
3222
                                    CreateCommand.Instance.Execute(currentControl);
3223
                                }
3224
                            }
3225
                        }
3226
                        break;
3227
                    case ControlType.TextCloud:
3228
                        {
3229
                            if (e.LeftButton == MouseButtonState.Pressed)
3230
                            {
3231
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3232
                                {
3233
                                    currentControl = new TextControl
3234
                                    {
3235
                                        ControlType = controlType
3236
                                    };
3237

    
3238
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3239
                                    currentControl.CommentID = Commons.shortGuid();
3240
                                    currentControl.IsNew = true;
3241
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3242
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3243

    
3244
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3245
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3246
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3247

    
3248
                                    (currentControl as TextControl).Angle = Ang;
3249
                                    (currentControl as TextControl).ControlType_No = 2;
3250
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3251
                                    (currentControl as TextControl).ApplyTemplate();
3252
                                    (currentControl as TextControl).Base_TextBox.Focus();
3253
                                    CreateCommand.Instance.Execute(currentControl);
3254
                                    //currentControl = null;
3255
                                }
3256
                            }
3257
                        }
3258
                        break;
3259
                    case ControlType.ArrowTextControl:
3260
                         {
3261
                            if (e.LeftButton == MouseButtonState.Pressed)
3262
                            {
3263
                                if (currentControl is ArrowTextControl)
3264
                                {
3265
                                    //20180906 LJY TEST IsRotationDrawingEnable
3266
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3267
                                    {
3268
                                        return;
3269
                                    }
3270

    
3271
                                    CreateCommand.Instance.Execute(currentControl);
3272

    
3273
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3274
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3275
                                    (currentControl as ArrowTextControl).IsNew = false;
3276
                                    currentControl = null;
3277
                                }
3278
                                else
3279
                                {
3280
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3281
                                    //{
3282
                                        currentControl = new ArrowTextControl();
3283
                                        currentControl.CommentID = Commons.shortGuid();
3284
                                        currentControl.IsNew = true;
3285
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3286
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3287

    
3288
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3289
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3290
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3291
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3292
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3293

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

    
3297
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3298
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3299
                                        this.MainAngle.Visibility = Visibility.Visible;
3300

    
3301
                                    
3302
                                    //}
3303
                                }
3304
                            }
3305
                        }
3306
                        break;
3307
                    case ControlType.ArrowTransTextControl:
3308
                        {
3309
                            if (e.LeftButton == MouseButtonState.Pressed)
3310
                            {
3311
                                if (currentControl is ArrowTextControl)
3312
                                {
3313
                                    //20180906 LJY TEST IsRotationDrawingEnable
3314
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3315
                                    {
3316
                                        return;
3317
                                    }
3318

    
3319
                                    CreateCommand.Instance.Execute(currentControl);
3320
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3321
                                    currentControl.IsNew = false;
3322
                                    currentControl = null;
3323
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3324
                                }
3325
                                else
3326
                                {
3327
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3328
                                    //{
3329
                                    currentControl = new ArrowTextControl()
3330
                                    {
3331
                                        ControlType = ControlType.ArrowTransTextControl
3332
                                    };
3333
                                    currentControl.CommentID = Commons.shortGuid();
3334
                                    currentControl.IsNew = true;
3335
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3336
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3337
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3338
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3339
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3340
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3341
                                    (currentControl as ArrowTextControl).isFixed = true;
3342
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3343

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

    
3347
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3348
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3349
                                    (currentControl as ArrowTextControl).isTrans = true;
3350
                                }
3351
                            }
3352
                        }
3353
                        break;
3354
                    case ControlType.ArrowTextBorderControl:
3355
                         {
3356
                            if (e.LeftButton == MouseButtonState.Pressed)
3357
                            {
3358
                                if (currentControl is ArrowTextControl)
3359
                                {
3360
                                    //20180906 LJY TEST IsRotationDrawingEnable
3361
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3362
                                    {
3363
                                        return;
3364
                                    }
3365

    
3366
                                    CreateCommand.Instance.Execute(currentControl);
3367
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3368
                                    currentControl.IsNew = false;
3369
                                    currentControl = null;
3370
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3371
                                }
3372
                                else
3373
                                {
3374
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3375
                                    //{
3376
                                        currentControl = new ArrowTextControl()
3377
                                        {
3378
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3379
                                        };
3380
                                        currentControl.CommentID = Commons.shortGuid();
3381
                                        currentControl.IsNew = true;
3382
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3383
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3384

    
3385
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3386

    
3387
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3388

    
3389
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3390
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3391
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3392

    
3393
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3394
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3395
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3396
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3397
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3398
                                    //}
3399
                                }
3400
                            }
3401
                        }
3402
                        break;
3403
                    case ControlType.ArrowTransTextBorderControl:
3404
                        {
3405
                            if (e.LeftButton == MouseButtonState.Pressed)
3406
                            {
3407
                                if (currentControl is ArrowTextControl)
3408
                                {
3409
                                    //20180906 LJY TEST IsRotationDrawingEnable
3410
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3411
                                    {
3412
                                        return;
3413
                                    }
3414
                                    CreateCommand.Instance.Execute(currentControl);
3415
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3416
                                    currentControl.IsNew = false;
3417
                                    currentControl = null;
3418
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3419
                                }
3420
                                else
3421
                                {
3422
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3423
                                    //{
3424
                                    
3425

    
3426
                                    currentControl = new ArrowTextControl()
3427
                                    {
3428
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3429
                                        ControlType = ControlType.ArrowTransTextBorderControl
3430

    
3431
                                    };
3432
                                        currentControl.CommentID = Commons.shortGuid();
3433
                                        currentControl.IsNew = true;
3434
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3435
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3436

    
3437
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3438

    
3439
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3440
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3441
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3442
                                        (currentControl as ArrowTextControl).isFixed = true;
3443
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3444
                                     
3445
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3446
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3447
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3448

    
3449
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3450
                                        this.MainAngle.Visibility = Visibility.Visible;
3451
                                    
3452
                                    //20180911 LJY
3453
                                        (currentControl as ArrowTextControl).isTrans = true;
3454
                                    
3455

    
3456
                                    //}
3457
                                }
3458
                            }
3459
                        }
3460
                        break;
3461
                    case ControlType.ArrowTextCloudControl:
3462
                        {
3463
                            if (e.LeftButton == MouseButtonState.Pressed)
3464
                            {
3465
                                if (currentControl is ArrowTextControl)
3466
                                {
3467
                                    //20180906 LJY TEST IsRotationDrawingEnable
3468
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3469
                                    {
3470
                                        return;
3471
                                    }
3472
                                    CreateCommand.Instance.Execute(currentControl);
3473
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3474
                                    currentControl.IsNew = false;
3475
                                    currentControl = null;
3476
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3477
                                }
3478
                                else
3479
                                {
3480
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3481
                                    //{
3482
                                        currentControl = new ArrowTextControl()
3483
                                        {
3484
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3485
                                        };
3486
                                        currentControl.CommentID = Commons.shortGuid();
3487
                                        currentControl.IsNew = true;
3488
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3489
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3490

    
3491
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3492
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3493
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3494
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3495
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3496

    
3497
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3498
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3499
                                    
3500
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3501
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3502
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3503
                                    //}
3504
                                }
3505
                            }
3506
                        }
3507
                        break;
3508
                    case ControlType.ArrowTransTextCloudControl:
3509
                        {
3510
                            if (e.LeftButton == MouseButtonState.Pressed)
3511
                            {
3512
                                if (currentControl is ArrowTextControl)
3513
                                {
3514
                                    //20180906 LJY TEST IsRotationDrawingEnable
3515
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3516
                                    {
3517
                                        return;
3518
                                    }
3519
                                    CreateCommand.Instance.Execute(currentControl);
3520
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3521
                                    currentControl.IsNew = false;
3522
                                    currentControl = null;
3523
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3524
                                }
3525
                                else
3526
                                {
3527
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3528
                                    //{
3529
                                        currentControl = new ArrowTextControl()
3530
                                        {
3531
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3532
                                            ControlType = ControlType.ArrowTransTextCloudControl
3533

    
3534
                                        };
3535
                                        currentControl.CommentID = Commons.shortGuid();
3536
                                        currentControl.IsNew = true; 
3537
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3538
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3539
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3540

    
3541
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3542
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3543
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3544
                                        (currentControl as ArrowTextControl).isFixed = true;
3545
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3546

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

    
3550
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3551
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3552
                                        this.MainAngle.Visibility = Visibility.Visible;  
3553
                                    
3554
                                    //20180911 LJY
3555
                                        (currentControl as ArrowTextControl).isTrans = true;
3556
                                    //}
3557
                                }
3558
                            }
3559
                        }
3560
                        break;
3561
                    //강인구 추가
3562
                    case ControlType.Sign:
3563
                        {
3564
                            if (e.LeftButton == MouseButtonState.Pressed)
3565
                            {
3566
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3567
                                //{
3568
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3569

    
3570
                                    if (_sign == null)
3571
                                    {
3572
                                        txtBatch.Visibility = Visibility.Collapsed;
3573
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3574
                                        controlType = ControlType.None;
3575

    
3576
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3577
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3578
                                        return;
3579
                                    }
3580

    
3581
                                    if (currentControl is SignControl)
3582
                                    {
3583
                                        //20180906 LJY TEST IsRotationDrawingEnable
3584
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3585
                                        {
3586
                                            return;
3587
                                        }
3588

    
3589
                                        CreateCommand.Instance.Execute(currentControl);
3590
                                        currentControl = null;
3591
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3592
                                        {
3593
                                            txtBatch.Text = "Place Date";
3594
                                            controlType = ControlType.Date;
3595
                                        }
3596
                                    }
3597
                                    else
3598
                                    {
3599
                                        currentControl = new SignControl
3600
                                        {
3601
                                            Background = new SolidColorBrush(Colors.Black),
3602
                                            UserNumber = App.ViewInfo.UserID,
3603
                                            ProjectNO = App.ViewInfo.ProjectNO,
3604
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3605
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3606
                                            ControlType = ControlType.Sign
3607
                                        };
3608

    
3609
                                        currentControl.CommentID = Commons.shortGuid();
3610
                                        currentControl.IsNew = true;
3611
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3612
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3613

    
3614
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3615
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3616
                                }
3617
                                //}
3618
                            }
3619
                        }
3620
                        break;
3621
                    case ControlType.Mark:
3622
                        {
3623
                            if (e.LeftButton == MouseButtonState.Pressed)
3624
                            {
3625
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3626
                                //{
3627
                                    if (currentControl is RectangleControl)
3628
                                    {
3629
                                        //20180906 LJY TEST IsRotationDrawingEnable
3630
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3631
                                        {
3632
                                            return;
3633
                                        }
3634

    
3635
                                        CreateCommand.Instance.Execute(currentControl);
3636
                                        (currentControl as RectangleControl).ApplyOverViewData();
3637
                                        currentControl = null;
3638
                                    
3639
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3640

    
3641
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3642
                                        {
3643
                                            txtBatch.Text = "Place Signature";
3644
                                            controlType = ControlType.Sign;
3645
                                        }
3646
                                    }
3647
                                    else
3648
                                    {
3649
                                        currentControl = new RectangleControl
3650
                                        {
3651
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3652
                                            Background = new SolidColorBrush(Colors.Black),
3653
                                            ControlType = ControlType.Mark ,
3654
                                            Paint = PaintSet.Fill
3655
                                        };
3656

    
3657
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3658
                                        currentControl.CommentID = Commons.shortGuid();
3659
                                        currentControl.IsNew = true;
3660
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3661
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3662
                                    }
3663
                                //}
3664
                            }
3665
                        }
3666
                        break;
3667
                    case ControlType.Symbol:
3668
                        {
3669
                            if (e.LeftButton == MouseButtonState.Pressed)
3670
                            {
3671
                                if (currentControl is SymControl)
3672
                                {
3673
                                    //20180906 LJY TEST IsRotationDrawingEnable
3674
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3675
                                    {
3676
                                        return;
3677
                                    }
3678
                                    CreateCommand.Instance.Execute(currentControl);
3679
                                    currentControl = null;
3680
                                
3681
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3682
                                }
3683
                                else
3684
                                {
3685
                                    currentControl = new SymControl
3686
                                    {
3687
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3688
                                        Background = new SolidColorBrush(Colors.Black),
3689
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3690
                                        ControlType = ControlType.Symbol
3691
                                    };
3692

    
3693
                                    currentControl.IsNew = true;
3694
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3695
                                    currentControl.CommentID = Commons.shortGuid();
3696
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3697

    
3698
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3699
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3700
                                }
3701
                                //}
3702
                            }
3703
                        }
3704
                        break;
3705
                    case ControlType.Stamp:
3706
                        {
3707
                            if (e.LeftButton == MouseButtonState.Pressed)
3708
                            {
3709
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3710
                                //{
3711
                                    if (currentControl is SymControlN)
3712
                                    {
3713
                                        //20180906 LJY TEST IsRotationDrawingEnable
3714
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3715
                                        {
3716
                                            return;
3717
                                        }
3718

    
3719
                                        CreateCommand.Instance.Execute(currentControl);
3720
                                        currentControl = null;
3721
                                   
3722

    
3723
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3724
                                    }
3725
                                    else
3726
                                    {
3727
                                        currentControl = new SymControlN
3728
                                        {
3729
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3730
                                            Background = new SolidColorBrush(Colors.Black),
3731
                                            STAMP = App.SystemInfo.STAMP,
3732
                                            ControlType = ControlType.Stamp
3733
                                        };
3734

    
3735
                                        currentControl.IsNew = true;
3736
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3737
                                        currentControl.CommentID = Commons.shortGuid();
3738
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3739
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3740
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3741
                                }                                    
3742
                                //}
3743
                            }
3744
                        }
3745
                        break;
3746
                    case ControlType.PenControl:
3747
                        {
3748
                            if (inkBoard.Tag.ToString() == "Ink")
3749
                            {
3750
                                inkBoard.IsEnabled = true;
3751
                                StartNewStroke(canvasDrawingMouseDownPoint);
3752
                            }
3753
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3754
                            {
3755
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3756
                            }
3757
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3758
                            {
3759
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3760
                            }
3761
                            IsDrawing = true;
3762
                            return;
3763
                        }
3764
                    default:
3765
                        if (currentControl != null)
3766
                        {
3767
                            currentControl.CommentID = null;
3768
                            currentControl.IsNew = false;
3769
                        }
3770
                        break;
3771
                }
3772
            }
3773
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3774
            {
3775
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3776
                {
3777
                    bool mouseOff = false;
3778
                    foreach (var item in SelectLayer.Children)
3779
                    {
3780
                        if (item is AdornerFinal)
3781
                        {
3782

    
3783
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3784
                            if (over != null)
3785
                            {
3786
                                mouseOff = true;
3787
                            }
3788
                        }
3789
                    }
3790

    
3791
                    if (!mouseOff)
3792
                    {
3793
                        SelectionSet.Instance.UnSelect(this);
3794
                    }
3795
                }
3796
                zoomAndPanControl.CaptureMouse();
3797
                e.Handled = true;
3798
            }
3799
        }
3800

    
3801
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3802
        {
3803
            ///mouseButtonDown = e.ChangedButton;
3804
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3805
        }
3806

    
3807
        private void RemoveLineStroke(Point P)
3808
        {
3809
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3810
            if (control != null)
3811
            {
3812
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3813
            }
3814
        }
3815

    
3816
        private void RemovePointStroke(Point P)
3817
        {
3818
            foreach (Stroke hits in inkBoard.Strokes)
3819
            {
3820
                foreach (StylusPoint sty in hits.StylusPoints)
3821
                {
3822

    
3823
                }
3824
                if (hits.HitTest(P))
3825
                {
3826
                    inkBoard.Strokes.Remove(hits);
3827
                    return;
3828
                }
3829
            }
3830
        }
3831

    
3832
        private void StartNewStroke(Point P)
3833
        {
3834
            strokePoints = new StylusPointCollection();
3835
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3836
            strokePoints.Add(segment1Start);
3837
            stroke = new Stroke(strokePoints);
3838

    
3839
            stroke.DrawingAttributes.Color = Colors.Red;
3840
            stroke.DrawingAttributes.Width = 4;
3841
            stroke.DrawingAttributes.Height = 4;
3842

    
3843
            inkBoard.Strokes.Add(stroke);
3844
        }
3845

    
3846
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3847
        {
3848
            ConsolidationMethod();
3849
        }
3850

    
3851
        /// <summary>
3852
        /// execute TeamConsolidationCommand
3853
        /// </summary>
3854
        public void TeamConsolidationMethod()
3855
        {
3856
            this.UpdateMyMarkupList();
3857
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3858
            {
3859
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3860
            }
3861
            else
3862
            {
3863

    
3864
                ViewerDataModel.Instance.IsConsolidate = true;
3865
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3866

    
3867
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3868
                {
3869
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3870
                    {
3871
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3872
                        return;
3873
                    }                    
3874
                }
3875
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3876
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3877
                {
3878
                    MarkupInfoList.Add(item);
3879
                }
3880
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3881
            }
3882
        }
3883

    
3884
        public void ConsolidationMethod()
3885
        {
3886
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3887
            {
3888
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3889
            }
3890
            else
3891
            {
3892
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3893
                foreach (var item in this.gridViewMarkup.SelectedItems)
3894
                {
3895
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3896
                }
3897
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3898
                
3899
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3900
            }
3901
        }
3902

    
3903
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3904
        {
3905
            if (App.ViewInfo != null)
3906
            {
3907
                btnConsolidate = (sender as RadRibbonButton);
3908
                if (!App.ViewInfo.NewCommentPermission)
3909
                {
3910
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3911
                }
3912
            }
3913
        }
3914

    
3915
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3916
        {
3917
            TeamConsolidationMethod();
3918
        }
3919

    
3920
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3921
        {
3922
            btnTeamConsolidate = sender as RadRibbonButton;
3923
            if (App.ViewInfo != null)
3924
            {
3925
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3926
                {
3927
                    if (btnConsolidate != null)
3928
                    {
3929
                        btnConsolidate.Visibility = Visibility.Collapsed;
3930
                    }
3931

    
3932
                    if (!App.ViewInfo.NewCommentPermission)
3933
                    {
3934
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3935
                    }
3936
                }
3937
                else
3938
                {
3939
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3940
                }
3941
            }
3942
        }
3943

    
3944
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3945
        {
3946
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3947
            if (item != null)
3948
            {
3949
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3950

    
3951
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3952
            }
3953
            else
3954
            {
3955
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3956
            }
3957
        }
3958

    
3959
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3960
        {
3961
            btnFinalPDF = sender as RadRibbonButton;
3962
            if (App.ViewInfo != null)
3963
            {
3964
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3965
                {
3966
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3967
                    if (btnConsolidate != null)
3968
                    {
3969
                        btnConsolidate.Visibility = Visibility.Collapsed;
3970
                    }
3971
                }
3972
            }
3973
        }
3974

    
3975
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3976
        {
3977
            UpdateMyMarkupList();
3978

    
3979
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3980
            {
3981
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3982
            }
3983
            else
3984
            {
3985
                ViewerDataModel.Instance.IsConsolidate = true;
3986
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3987
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3988

    
3989
                string project_no = App.ViewInfo.ProjectNO;
3990
                string doc_id = _DocInfo.ID;
3991
                string user_id = App.ViewInfo.UserID;
3992
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3993
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3994
                {
3995
                    markupInfoItems.Add(item);
3996
                }
3997
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3998
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3999
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4000
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4001

    
4002
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4003
                if (item2 != null)
4004
                {
4005
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4006

    
4007
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4008
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4009
                }
4010
                else
4011
                {
4012
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4013
                }
4014
            }
4015
        }
4016

    
4017
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4018
        {
4019
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4020

    
4021
            if (App.ViewInfo != null)
4022
            {
4023
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4024
                {
4025
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4026
                }
4027
            }
4028
        }
4029

    
4030
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4031
        {
4032
            if (CompareMode.IsChecked)
4033
            {
4034
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4035
                {
4036
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4037
                }
4038
                if (ViewerDataModel.Instance.PageNumber == 0)
4039
                {
4040
                    ViewerDataModel.Instance.PageNumber = 1;
4041
                }
4042

    
4043
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4044
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4045
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4046

    
4047
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4048
            }
4049
            else
4050
            {
4051
                da.From = 1;
4052
                da.To = 1;
4053
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4054
                da.AutoReverse = false;
4055
                canvas_compareBorder.Children.Clear();
4056
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4057
            }
4058
        }
4059

    
4060
        private void Sync_Click(object sender, RoutedEventArgs e)
4061
        {
4062
            if (Sync.IsChecked)
4063
            {
4064
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4065
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4066
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4067
            }
4068
        }
4069

    
4070
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4071
        {
4072
            if (UserList.IsChecked)
4073
            {
4074
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4075
            }
4076
            else
4077
            {
4078
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4079
            }
4080
        }
4081

    
4082
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4083
        {
4084

    
4085
            if (BalanceMode.IsChecked)
4086
            {
4087
                ViewerDataModel.Instance.PageBalanceMode = true;
4088
            }
4089
            else
4090
            {
4091
                ViewerDataModel.Instance.PageBalanceMode = false;
4092
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4093
            }
4094
        }
4095

    
4096
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4097
        {
4098
            //초기화
4099
            testPanel2.IsHidden = true;
4100
            ViewerDataModel.Instance.PageBalanceMode = false;
4101
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4102
            ViewerDataModel.Instance.PageNumber = 0;
4103
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4104
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4105
            UserList.IsChecked = false;
4106
            BalanceMode.IsChecked = false;
4107
        }
4108

    
4109
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4110
        {
4111
            if ((sender as System.Windows.Controls.Control).Tag != null)
4112
            {
4113
                //Compare 초기화
4114
                CompareMode.IsChecked = false;
4115
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4116

    
4117
                if (ViewerDataModel.Instance.PageNumber == 0)
4118
                {
4119
                    ViewerDataModel.Instance.PageNumber = 1;
4120
                }
4121

    
4122
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4123
                {
4124
                }
4125
                else
4126
                {
4127
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4128
                }
4129

    
4130
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4131
                {
4132

    
4133
                }
4134
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4135
                {
4136
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4137
                }
4138

    
4139
                if (!testPanel2.IsHidden)
4140
                {
4141
                    if (IsSyncPDFMode)
4142
                    {
4143
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4144
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4145

    
4146
                        if (pdfpath.IsDownloading)
4147
                        {
4148
                            pdfpath.DownloadCompleted += (ex, arg) =>
4149
                            {
4150
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4151
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4152
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4153
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4154
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4155
                            };
4156
                        }
4157
                        else
4158
                        {
4159
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4160
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4161
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4162

    
4163
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4164
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4165
                        }
4166

    
4167
                    }
4168
                    else
4169
                    {
4170
                        string uri = "";
4171

    
4172
                        if (userData.COMPANY != "EXT")
4173
                        {
4174
                            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);
4175
                        }
4176
                        else
4177
                        {
4178
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4179
                        }
4180

    
4181
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4182

    
4183
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4184
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4185
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4186

    
4187
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4188
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4189

    
4190
                        if (defaultBitmapImage_Compare.IsDownloading)
4191
                        {
4192
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4193
                            {
4194
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4195
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4196
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4197

    
4198
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4199
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4200
                            };
4201
                        }
4202
                    }
4203

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

    
4208
                    foreach (var item in gridSelectionRevItem)
4209
                    {
4210
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4211
                        {
4212
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4213
                        });
4214
                    }
4215

    
4216
                    //강인구 추가
4217
                    zoomAndPanControl2.ZoomTo(new Rect
4218
                    {
4219
                        X = 0,
4220
                        Y = 0,
4221
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4222
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4223
                    });
4224

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

    
4227
                }
4228
            }
4229
        }
4230

    
4231
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4232
        {
4233
            if (MarkupMode.IsChecked)
4234
            {
4235
                IsSyncPDFMode = true;
4236

    
4237
                var uri = CurrentRev.TO_VENDOR;
4238

    
4239
                if (ViewerDataModel.Instance.PageNumber == 0)
4240
                {
4241
                    ViewerDataModel.Instance.PageNumber = 1;
4242
                }
4243

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

    
4248
                if (pdfpath.IsDownloading)
4249
                {
4250
                    pdfpath.DownloadCompleted += (ex, arg) =>
4251
                    {
4252
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4253
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4254
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4255
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4256
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4257
                    };
4258
                }
4259
                else
4260
                {
4261
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4262
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4263
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4264

    
4265
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4266
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4267
                }
4268
            }
4269
            else
4270
            {
4271
                IsSyncPDFMode = false;
4272
                string uri = "";
4273
                if (userData.COMPANY != "EXT")
4274
                {
4275
                    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);
4276
                }
4277
                else
4278
                {
4279
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4280
                }
4281

    
4282
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
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
                if (defaultBitmapImage_Compare.IsDownloading)
4289
                {
4290
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4291
                    {
4292
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4293
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4294
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4295
                    };
4296
                }
4297
                zoomAndPanControl2.ApplyTemplate();
4298
                zoomAndPanControl2.UpdateLayout();
4299
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4300
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4301
            }
4302
        }
4303

    
4304
        private void RadButton_Click(object sender, RoutedEventArgs e)
4305
        {
4306
            gridViewHistory_Busy.IsBusy = true;
4307

    
4308
            RadButton instance = sender as RadButton;
4309
            if (instance.CommandParameter != null)
4310
            {
4311
                CurrentRev = instance.CommandParameter as VPRevision;
4312
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4313
                {
4314
                    if (ea.Error == null && ea.Result != null)
4315
                    {
4316
                        testPanel2.IsHidden = false;
4317

    
4318
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4319
                        foreach(var info in ea.Result)
4320
                        {
4321
                            if(info.UserID == App.ViewInfo.UserID)
4322
                            {
4323
                                info.userDelete = true;
4324
                                info.DisplayColor = "FFFF0000";
4325
                            }
4326
                            else
4327
                            {
4328
                                info.userDelete = false;
4329
                            }
4330
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4331
                        }
4332
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4333

    
4334
                        string uri = "";
4335
                        if (userData.COMPANY != "EXT")
4336
                        {
4337
                            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);
4338
                        }
4339
                        else
4340
                        {
4341
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4342
                        }
4343

    
4344
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4345

    
4346
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
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
                        if (defaultBitmapImage_Compare.IsDownloading)
4353
                        {
4354
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4355
                            {
4356
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4357
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4358
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4359
                            };
4360
                        }
4361

    
4362
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4363
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4364
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4365
                        zoomAndPanControl2.ApplyTemplate();
4366
                        zoomAndPanControl2.UpdateLayout();
4367

    
4368
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4369
                        {
4370
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4371
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4372
                        }
4373

    
4374
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4375
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4376
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4377

    
4378
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4379
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4380
                        gridViewHistory_Busy.IsBusy = false;
4381
                    }
4382

    
4383
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4384
                };
4385
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4386
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4387
            }
4388
        }
4389

    
4390
        public void Sync_Event(VPRevision Currnet_Rev)
4391
        {
4392
            CurrentRev = Currnet_Rev;
4393

    
4394
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4395
            {
4396
                if (ea.Error == null && ea.Result != null)
4397
                {
4398
                    testPanel2.IsHidden = false;
4399

    
4400
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4401
                    foreach(var info in ea.Result)
4402
                    {
4403
                        if(info.UserID == App.ViewInfo.UserID)
4404
                        {
4405
                            info.userDelete = true;
4406
                            info.DisplayColor = "FFFF0000";
4407
                        }
4408
                        else
4409
                        {
4410
                            info.userDelete = false;
4411
                        }
4412
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4413
                    }
4414
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4415

    
4416
                    string uri = "";
4417
                    if (userData.COMPANY != "EXT")
4418
                    {
4419
                        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);
4420
                    }
4421
                    else
4422
                    {
4423
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4424
                    }
4425

    
4426
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4427

    
4428
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
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
                    if (defaultBitmapImage_Compare.IsDownloading)
4435
                    {
4436
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4437
                        {
4438
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4439
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4440
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4441
                        };
4442
                    }
4443

    
4444

    
4445
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4446
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4447
                    zoomAndPanControl2.ApplyTemplate();
4448
                    zoomAndPanControl2.UpdateLayout();
4449

    
4450
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4451
                    {
4452
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4453
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4454
                    }
4455
                    //}
4456

    
4457
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4458
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4459
                    gridViewHistory_Busy.IsBusy = false;
4460
                }
4461
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4462

    
4463
            };
4464
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4465
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4466
        }
4467

    
4468
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4469
        {
4470
            if (sender is Image)
4471
            {
4472
                if ((sender as Image).Tag != null)
4473
                {
4474
                    var pdfUrl = (sender as Image).Tag.ToString();
4475
                    System.Diagnostics.Process.Start(pdfUrl);
4476
                }
4477
                else
4478
                {
4479
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4480
                }
4481
            }
4482
        }
4483

    
4484
        private void Create_Symbol(object sender, RoutedEventArgs e)
4485
        {
4486
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4487

    
4488
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4489
            {
4490
                DialogMessage_Alert("Please Select Controls", "Alert");
4491
            }
4492
            else //선택된 것이 있으면
4493
            {
4494
                string MarkupData = "";
4495
                adorner_ = new AdornerFinal();
4496

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

    
4525
        }
4526
        public int symbolselectindex = 0;
4527
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4528
        {
4529
            //Save save = new Save();
4530
            try
4531
            {
4532
                string svgfilename = null;
4533
                if (symbolname != null)
4534
                {
4535
                    if (symbolpng == true || symbolsvg == true)
4536
                    {
4537
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4538
                        string guid = Commons.shortGuid();
4539

    
4540
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4541
                        //Check_Uri.UriCheck();
4542
                        fileUploader.RunCompleted += (ex, arg) =>
4543
                        {
4544
                            filename = arg.Result;
4545
                            if (symbolpng == true)
4546
                            {
4547
                                if (filename != null)
4548
                                { 
4549
                                    if (symbolselectindex == 0)
4550
                                    {
4551
                                        SymbolSave(symbolname, filename, data);
4552
                                    }
4553
                                    else
4554
                                    {
4555
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4556
                                    }
4557
                                    DataBind();
4558
                                }                                
4559
                            }
4560

    
4561
                            if (symbolsvg == true)
4562
                            {
4563
                                try
4564
                                {
4565
                                    var defaultBitmapImage = new BitmapImage();
4566
                                    defaultBitmapImage.BeginInit();
4567
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4568
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4569
                                    Check_Uri.UriCheck(filename);
4570
                                    defaultBitmapImage.UriSource = new Uri(filename);
4571
                                    defaultBitmapImage.EndInit();
4572

    
4573
                                    System.Drawing.Bitmap image;
4574

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

    
4597
                                            StringBuilder svgBuilder = new StringBuilder();
4598
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4599
                                            {
4600
                                                svgBuilder.AppendLine(e2.Data);
4601
                                            };
4602

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

    
4619
                                                DataBind();
4620
                                            };
4621
                                            potrace.WaitForExit();
4622
                                        };
4623
                                    }
4624
                                    else
4625
                                    {
4626
                                        //GC.Collect();
4627
                                    }
4628
                                }
4629
                                catch(Exception ee)
4630
                                {
4631
                                    DialogMessage_Alert("" + ee, "Alert");
4632
                                }
4633
                            }
4634
                        };                                             
4635
                    }
4636
                }
4637
            }
4638
            catch (Exception e)
4639
            {
4640
                //DialogMessage_Alert(e + "", "Alert");
4641
            }            
4642
        }
4643

    
4644
        public void SymbolSave(string Name, string Url, string Data)
4645
        {
4646
            try
4647
            {
4648
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4649
                {
4650
                    ID = Commons.shortGuid(),
4651
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4652
                    NAME = Name,
4653
                    IMAGE_URL = Url,
4654
                    DATA = Data
4655
                };
4656

    
4657
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4658
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4659
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4660
            }
4661
            catch (Exception)
4662
            {
4663
                throw;
4664
            }
4665
        }
4666

    
4667
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4668
        {
4669
            try
4670
            {
4671
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4672
                {
4673
                    ID = Commons.shortGuid(),
4674
                    DEPARTMENT = Department,
4675
                    NAME = Name,
4676
                    IMAGE_URL = Url,
4677
                    DATA = Data
4678
                };
4679
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4680
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4681
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4682
            }
4683
            catch (Exception)
4684
            {
4685
                throw;
4686
            }
4687
        }
4688

    
4689
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4690
        {           
4691
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4692
            DataBind();
4693
        }
4694

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

    
4721
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4722

    
4723
                List<SYMBOL_PUBLIC> symbol_Public;
4724

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

    
4760
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4761
                        _Encoder.Save(fs);
4762
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4763

    
4764
                        byte[] Img_byte = fs.ToArray();
4765

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

    
4787
        public PngBitmapEncoder symImage(string data)
4788
        {
4789

    
4790
            Canvas _canvas = new Canvas();
4791
            _canvas.Background = Brushes.White;
4792
            _canvas.Width = adorner_.BorderSize.Width;
4793
            _canvas.Height = adorner_.BorderSize.Height;
4794
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4795

    
4796
            BitmapEncoder encoder = new PngBitmapEncoder();
4797

    
4798

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

    
4801
            DrawingVisual dv = new DrawingVisual();
4802

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

    
4806
            using (DrawingContext ctx = dv.RenderOpen())
4807
            {
4808
                VisualBrush vb = new VisualBrush(_canvas);
4809
                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)));
4810
            }
4811

    
4812
            try
4813
            {
4814
                renderBitmap.Render(dv);
4815

    
4816
                //GC.Collect();
4817
                GC.WaitForPendingFinalizers();
4818
                //GC.Collect();
4819
                // encode png data
4820
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4821
                // puch rendered bitmap into it
4822
                pngEncoder.Interlace = PngInterlaceOption.Off;
4823
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4824
                return pngEncoder;
4825

    
4826
            }
4827
            catch //(Exception ex)
4828
            {
4829
                return null;
4830
            }
4831

    
4832
        }
4833

    
4834
        public void DialogMessage_Alert(string content, string header)
4835
        {
4836
            var box = new TextBlock();
4837
            box.MinWidth = 400;
4838
            box.FontSize = 11;
4839
            //box.FontSize = 12;
4840
            box.Text = content;
4841
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4842

    
4843
            DialogParameters parameters = new DialogParameters()
4844
            {
4845
                Owner = Application.Current.MainWindow,
4846
                Content = box,
4847
                Header = header,
4848
                Theme = new VisualStudio2013Theme(),
4849
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4850
            };            
4851
            RadWindow.Alert(parameters);
4852
        }
4853

    
4854
        #region 캡쳐 기능
4855

    
4856
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4857
        {
4858
            if (x < 0)
4859
            {
4860
                width += x;
4861
                x = 0;
4862
            }
4863
            if (y < 0)
4864
            {
4865
                height += y;
4866
                y = 0;
4867

    
4868
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4869
            }
4870
            if (x + width > zoomAndPanCanvas.ActualWidth)
4871
            {
4872
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4873
            }
4874
            if (y + height > zoomAndPanCanvas.ActualHeight)
4875
            {
4876
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4877
            }
4878

    
4879
            byte[] pixels = CopyPixels(x, y, width, height);
4880

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

    
4883
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4884
        }
4885

    
4886
        public byte[] CopyPixels(int x, int y, int width, int height)
4887
        {
4888
            byte[] pixels = new byte[width * height * 4];
4889
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4890

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

    
4894
            return pixels;
4895
        }
4896

    
4897
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4898
        {
4899
            DrawingVisual drawingVisual = new DrawingVisual();
4900
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4901

    
4902
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4903
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4904
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4905
            drawingContext.Close();
4906

    
4907
            // 비트맵으로 변환합니다.
4908
            RenderTargetBitmap target =
4909
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4910
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4911

    
4912
            target.Render(drawingVisual);
4913
            return target;
4914
        }
4915

    
4916
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4917
        {
4918
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4919
            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);
4920
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4921
            bmp.UnlockBits(data);
4922
            return bmp;
4923
        }
4924
        public string symbolname = null;
4925
        public bool symbolsvg = true;
4926
        public bool symbolpng = true;
4927

    
4928
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4929
        {
4930
            System.Drawing.Bitmap image = GetBitmap(source);
4931
            //흰색 제거
4932
            //image.MakeTransparent(System.Drawing.Color.White);
4933

    
4934
            var imageStream = new System.IO.MemoryStream();
4935
            byte[] imageBytes = null;
4936
            using (imageStream)
4937
            {
4938
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4939
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4940
                imageStream.Position = 0;
4941
                imageBytes = imageStream.ToArray();
4942
            }
4943

    
4944
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4945

    
4946
            RadWindow CheckPop = new RadWindow();
4947
            //Alert check = new Alert(Msg);
4948

    
4949
            CheckPop = new RadWindow
4950
            {
4951
                MinWidth = 400,
4952
                MinHeight = 100,
4953
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4954
                Header = "Alert",
4955
                Content = symbolPrompt,
4956
                //DialogResult = 
4957
                ResizeMode = System.Windows.ResizeMode.NoResize,
4958
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4959
                IsTopmost = true,
4960
            };
4961
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4962
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4963
            CheckPop.ShowDialog();
4964

    
4965
            /*
4966
            DialogParameters parameters = new DialogParameters()
4967
            {
4968
                Owner = Application.Current.MainWindow,
4969
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4970
                DefaultPromptResultValue = "Custom State",
4971
                Content = "Name :",
4972
                Header = "Insert Custom Symbol Name",
4973
                Theme = new VisualStudio2013Theme(),
4974
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4975
            };            
4976
            RadWindow.Prompt(parameters);
4977
            */
4978
        }
4979

    
4980
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4981
        {
4982
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4983
            KCOMDataModel.DataModel.CHECK_LIST check_;
4984
            string Result = streamToBase64.ImageToBase64(source);
4985
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4986
            string projectno = App.ViewInfo.ProjectNO;
4987
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4988

    
4989
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4990
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4991
            if (Item != null)
4992
            {
4993
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4994
            }
4995
            else
4996
            {
4997
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4998
            }
4999

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

    
5032
        }
5033

    
5034
        public void Set_Capture()
5035
        {
5036
            double x = canvasDrawingMouseDownPoint.X;
5037
            double y = canvasDrawingMouseDownPoint.Y;
5038
            double width = dragCaptureBorder.Width;
5039
            double height = dragCaptureBorder.Height;
5040

    
5041
            if (width > 5 || height > 5)
5042
            {
5043
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5044
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5045
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5046
            }
5047
        }
5048
        #endregion
5049

    
5050
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5051
        {
5052
            multi_Undo_Data = new Multi_Undo_data();
5053

    
5054
            multi_Undo_Data.Markup = control;
5055

    
5056
            if ((control as IShapeControl) != null)
5057
            {
5058
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5059
            }
5060
            if ((control as IDashControl) != null)
5061
            {
5062
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5063
            }
5064
            if ((control as IPath) != null)
5065
            {
5066
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5067
            }
5068
            if ((control as UIElement) != null)
5069
            {
5070
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5071
            }
5072

    
5073
            return multi_Undo_Data;
5074
        }
5075

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

    
5095
        /// <summary>
5096
        /// convert inkcontrol to polygoncontrol
5097
        /// </summary>
5098
        public void ConvertInkControlToPolygon()
5099
        {
5100
            if (inkBoard.Strokes.Count > 0)
5101
            {
5102
                inkBoard.Strokes.ToList().ForEach(stroke =>
5103
                {
5104
                    InkToPath ip = new InkToPath();
5105

    
5106
                    List<Point> inkPointSet = new List<Point>();
5107
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5108

    
5109
                    PolygonControl pc = new PolygonControl()
5110
                    {
5111
                        Angle = 0,
5112
                        PointSet = inkPointSet,
5113
                        ControlType = ControlType.Ink
5114
                    };
5115
                    pc.StartPoint = inkPointSet[0];
5116
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5117
                    pc.LineSize = 3;
5118
                    pc.CommentID = Commons.shortGuid();
5119
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5120

    
5121
                    if (pc.PointSet.Count > 0)
5122
                    {
5123
                        CreateCommand.Instance.Execute(pc);
5124
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5125
                    }
5126
                });
5127
                inkBoard.Strokes.Clear();
5128
            }
5129
        }
5130

    
5131
        /// <summary>
5132
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5133
        /// </summary>
5134
        /// <author>ingu</author>
5135
        /// <date>2018.06.05</date>
5136
        /// <param name="getPoint"></param>
5137
        /// <returns></returns>
5138
        private bool IsGetoutpoint(Point getPoint)
5139
        {
5140
            if (getPoint == new Point())
5141
            {
5142
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5143
                currentControl = null;
5144
                return true;
5145
            }
5146

    
5147
            return false;
5148
        }
5149

    
5150
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5151
        {
5152
            e.Effects = DragDropEffects.Copy;
5153
        }
5154

    
5155
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5156
        {
5157
            e.Effects = DragDropEffects.Copy;
5158
        }
5159

    
5160
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5161
        {
5162
            e.Effects = DragDropEffects.None;
5163
        }
5164

    
5165
        /*
5166
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5167
        {
5168
            try
5169
            {
5170
                if (e.Data.GetDataPresent(typeof(string)))
5171
                {
5172
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5173
                    string dragData = e.Data.GetData(typeof(string)) as string;
5174
                    Move_Symbol(sender, dragData);
5175
                }
5176
            }
5177
            catch (Exception ex)
5178
            {
5179
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5180
            }            
5181
        }
5182
        */
5183
    }
5184
}
클립보드 이미지 추가 (최대 크기: 500 MB)