프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (245 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
            //InitializeComponent();    
240
            this.Loaded += MainMenu_Loaded;
241
        }
242

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

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

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

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

    
270
            return false;
271
        }
272

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

    
296
            return false;
297
        }
298

    
299

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

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

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

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

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

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

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

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

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

    
373
            DeleteItem(item);
374
        }
375

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

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

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

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

    
408
        
409

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

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

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

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

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

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

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

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

    
498
        bool ComingNewBieEnd = false;
499

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

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

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

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

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

    
528

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

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

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

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

    
559
            ConvertInkControlToPolygon();
560

    
561
            SelectionSet.Instance.UnSelect(this);
562
            UpdateMyMarkupList();
563

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

    
567

    
568
            #region 페이지가 벗어난 경우
569

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

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

    
582
            #endregion
583

    
584
            ViewerDataModel.Instance.PageNumber = BalancePoint;
585

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

    
596
            var defaultBitmapImage = new BitmapImage();
597
            defaultBitmapImage.BeginInit();
598
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
599
            defaultBitmapImage.UriSource = new Uri(uri);
600
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
601
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
602
            defaultBitmapImage.EndInit();
603

    
604
            ViewerDataModel.Instance.ImageViewPath = null;            
605

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

    
625
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
626
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
627

    
628

    
629
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
630
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
631
            inkBoard.Width = zoomAndPanCanvas.Width;
632
            inkBoard.Height = zoomAndPanCanvas.Height;
633

    
634

    
635

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

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

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

    
682
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
683
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
684
                    defaultBitmapImage_Compare.BeginInit();
685
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
686
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
687
                    defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
688
                    defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
689
                    defaultBitmapImage_Compare.EndInit();
690

    
691
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
692

    
693
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
694
                    zoomAndPanControl.ZoomTo(new Rect
695
                    {
696
                        X = 0,
697
                        Y = 0,
698
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
699
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
700
                    });
701

    
702
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
703
                    if (defaultBitmapImage_Compare.IsDownloading)
704
                    {
705
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
706
                        {
707
                            defaultBitmapImage_Compare.Freeze();
708
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
709
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
710
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
711
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
712
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
713

    
714
                            zoomAndPanControl.ZoomTo(new Rect
715
                            {
716
                                X = 0,
717
                                Y = 0,
718
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
719
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
720
                            });
721

    
722
                            //defaultBitmapImage_Compare dispose
723
                            defaultBitmapImage_Compare = null;
724
                            GC.Collect();
725
                        };
726
                    }
727
                }
728
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
729
            }
730

    
731
        }
732

    
733

    
734
        
735

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

    
762
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
763
        {
764
            if (e.MiddleButton == MouseButtonState.Pressed)
765
            {
766

    
767
            }
768
            e.Handled = true;
769
            if (e.Delta > 0)
770
            {
771
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
772
                ZoomIn(currentContentMousePoint);
773
            }
774
            else
775
            {
776
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
777
                ZoomOut(currentContentMousePoint);
778
            }
779
        }
780

    
781
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
782
        {
783
            e.Handled = true;
784
            if (e.Delta > 0)
785
            {
786
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
787
                ZoomIn_Sync(currentContentMousePoint);
788
            }
789
            else
790
            {
791
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
792
                ZoomOut_Sync(currentContentMousePoint);
793
            }
794
        }
795

    
796
        #region ZoomIn & ZoomOut
797

    
798
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
799
        {
800
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
801
                zoomAndPanControl.ContentZoomFocusY));
802
        }
803

    
804
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
805
        {
806
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
807
                zoomAndPanControl.ContentZoomFocusY));
808
        }
809

    
810

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

    
824
            if (zoomAndPanControl2 != null && Sync.IsChecked)
825
            {
826
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
827
            }
828
        }
829

    
830
        private void ZoomIn(Point contentZoomCenter)
831
        {
832
            if (zoomAndPanControl.ContentScale > 0.19)
833
            {
834
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
835
            }
836
            else
837
            {
838
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
839
            }
840

    
841
            if (zoomAndPanControl2 != null && Sync.IsChecked)
842
            {
843
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
844
            }
845

    
846
        }
847

    
848
        private void ZoomOut_Sync(Point contentZoomCenter)
849
        {
850
            if (zoomAndPanControl2.ContentScale > 0.39)
851
            {
852
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
853
            }
854
            else
855
            {
856
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
857
            }
858

    
859
            if (Sync.IsChecked)
860
            {
861
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
862
            }
863
        }
864

    
865
        private void ZoomIn_Sync(Point contentZoomCenter)
866
        {
867
            if (zoomAndPanControl2.ContentScale > 0.19)
868
            {
869
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
870
            }
871
            else
872
            {
873
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
874
            }
875

    
876
            if (Sync.IsChecked)
877
            {
878
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
879
            }
880
        }
881

    
882
        private void ZoomOut()
883
        {
884
            zoomAndPanControl.ContentScale -= 0.1;
885
            //if (zoomAndPanControl2 != null)
886
            //{
887
            //    zoomAndPanControl2.ContentScale -= 0.1;
888
            //}
889
        }
890

    
891
        private void ZoomIn()
892
        {
893
            zoomAndPanControl.ContentScale += 0.1;
894
            //if (zoomAndPanControl2 != null)
895
            //{
896
            //    zoomAndPanControl2.ContentScale += 0.1;
897
            //}
898
        }
899

    
900
        #endregion
901

    
902
        private void init()
903
        {
904
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
905
            {
906

    
907
                ControlList.Clear();
908
                listBox.Items.Clear();
909
                selected_item.Clear();
910

    
911
                (item as IMarkupCommonData).IsSelected = false;
912
            }
913

    
914
        }
915

    
916
        private HitTestResultBehavior MyCallback(HitTestResult result)
917
        {
918
            //this.cursor = Cursors.UpArrow;
919
            var element = result.VisualHit;
920
            while (element != null && !(element is CommentUserInfo))
921
                element = VisualTreeHelper.GetParent(element);
922

    
923
            if (element == null)
924
            {
925
                return HitTestResultBehavior.Stop;
926
            }
927
            else
928
            {
929
                if (element is CommentUserInfo)
930
                {
931
                    if (!hitList.Contains(element))
932
                    {
933
                        hitList.Add((CommentUserInfo)element);
934
                    }
935
                    else
936
                    {
937
                        return HitTestResultBehavior.Stop;
938
                    }
939
                }
940
            }
941
            return HitTestResultBehavior.Continue;
942
        }
943

    
944
        public void ReleaseSelectPath()
945
        {
946
            if (SelectionPath == null)
947
            {
948
                SelectionPath = new Path();
949
                SelectionPath.Name = "";
950
            }
951
            if (SelectionPath.Name != "")
952
            {
953
                SelectionPath.Name = "None";
954
            }
955
            SelectionPath.Opacity = 0.01;
956
            SelectionPath.RenderTransform = null;
957
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
958
        }
959

    
960
        #region 컨트롤 초기화 
961
        public void Control_Init(object control)
962
        {
963
            if (L_Size != 0 && (control as IPath) != null)
964
            {
965
                (control as IPath).LineSize = L_Size;
966
                L_Size = 0;
967
            }
968

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

    
1055
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1056
        {
1057
            //Control_Init(e.Source);
1058
        }
1059
        private Window _dragdropWindow = null;
1060

    
1061
        [DllImport("user32.dll")]
1062
        [return: MarshalAs(UnmanagedType.Bool)]
1063
        internal static extern bool GetCursorPos(ref Win32Point pt);
1064

    
1065
        [StructLayout(LayoutKind.Sequential)]
1066
        internal struct Win32Point
1067
        {
1068
            public Int32 X;
1069
            public Int32 Y;
1070
        };
1071
        public string symbol_id = null;
1072
        public long symbol_group_id;
1073
        public int symbol_SelectedIndex;
1074
        public ImageSource symbol_img;
1075
        public string symbol_Data = null;
1076
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1077
        {
1078
            if (this._dragdropWindow != null)
1079
            {
1080
                this._dragdropWindow.Close();
1081
                this._dragdropWindow = null;
1082
            }
1083

    
1084
            symbol_id = id;
1085
            symbol_group_id = group_id;
1086
            symbol_SelectedIndex = SelectedIndex;
1087
            symbol_Data = Data_;
1088
            symbol_img = img;
1089

    
1090
      
1091
            CreateDragDropWindow2(img);
1092
        }
1093

    
1094
        private void CreateDragDropWindow2(ImageSource image)
1095
        {
1096
            this._dragdropWindow = new Window();
1097
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1098
            _dragdropWindow.WindowStyle = WindowStyle.None;
1099
            _dragdropWindow.AllowsTransparency = true;           
1100
            _dragdropWindow.AllowDrop = false;
1101
            _dragdropWindow.Background = null;
1102
            _dragdropWindow.IsHitTestVisible = false;
1103
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1104
            _dragdropWindow.Topmost = true;
1105
            _dragdropWindow.ShowInTaskbar = false;
1106
            
1107
            Rectangle r = new Rectangle();
1108
            r.Width = image.Width;
1109
            r.Height = image.Height;
1110
            r.Opacity = 0.5;            
1111
            r.Fill = new ImageBrush(image);
1112
            this._dragdropWindow.Content = r;
1113

    
1114
            Win32Point w32Mouse = new Win32Point();
1115
            GetCursorPos(ref w32Mouse);
1116

    
1117
            //w32Mouse.X = getCurrentPoint.X;
1118
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1119
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1120
            this._dragdropWindow.Show();
1121
        }
1122

    
1123
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1124
        {
1125
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1126
            {
1127
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1128

    
1129
                Point currentPos = e.GetPosition(rect);
1130

    
1131
                floatingTip.HorizontalOffset = currentPos.X + 20;
1132
                floatingTip.VerticalOffset = currentPos.Y;
1133
            }
1134

    
1135
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1136
            
1137
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1138
            {
1139
                SetCursor();
1140
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1141
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1142

    
1143
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1144
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1145
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1146

    
1147
                if (Sync.IsChecked)
1148
                {
1149
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1150
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1151
                }
1152
            }
1153

    
1154
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1155
            {
1156
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1157
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1158
                SetCursor();
1159

    
1160
                if (currentControl != null)
1161
                {
1162
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1163
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1164
                    //강인구 추가
1165
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1166

    
1167
                    if ((currentControl as IPath) != null)
1168
                    {
1169
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1170
                    }
1171
                    if ((currentControl as LineControl) != null)
1172
                    {
1173
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1174
                    }
1175

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

    
1219
                    switch (controlType)
1220
                    {
1221
                        case (ControlType.Coordinate):
1222
                            {
1223
                                var control = currentControl as CoordinateControl;
1224
                                if (control != null)
1225
                                {
1226
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1227
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1228
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1229
                                }
1230
                            }
1231
                            break;
1232
                        case (ControlType.InsideWhite):
1233
                            {
1234
                                var control = currentControl as InsideWhiteControl;
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
                                    control.Paint = PaintSet.Fill;
1241
                                }
1242
                            }
1243
                            break;
1244
                        case ControlType.OverlapWhite:
1245
                            {
1246
                                var control = currentControl as OverlapWhiteControl;
1247
                                if (control != null)
1248
                                {
1249
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1250
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1251
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1252
                                    control.Paint = PaintSet.Fill;
1253
                                }
1254
                            }
1255
                            break;
1256
                        case ControlType.ClipWhite:
1257
                            {
1258
                                var control = currentControl as ClipWhiteControl;
1259
                                if (control != null)
1260
                                {
1261
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1262
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1263
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1264
                                    control.Paint = PaintSet.Fill;
1265
                                }
1266
                            }
1267
                            break;
1268
                        case ControlType.RectCloud:
1269
                            {
1270
                                var control = currentControl as RectCloudControl;
1271
                                if (control != null)
1272
                                {
1273
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1274
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1275
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1276
                                }
1277
                            }
1278
                            break;
1279
                        case ControlType.SingleLine:
1280
                        case ControlType.CancelLine:
1281
                        case ControlType.ArrowLine:
1282
                        case ControlType.TwinLine:
1283
                        case ControlType.DimLine:
1284
                            {
1285
                                var control = currentControl as LineControl;
1286
                                if (control != null)
1287
                                {
1288
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1289
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1290
                                }
1291
                            }
1292
                            break;
1293

    
1294
                        case ControlType.ArcLine:
1295
                            {
1296
                                var control = currentControl as ArcControl;
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.ArcArrow:
1306
                            {
1307
                                var control = currentControl as ArrowArcControl;
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.ArrowMultiLine:
1317
                            {
1318
                                var control = currentControl as ArrowControl_Multi;
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.Circle:
1328
                            {
1329
                                if (currentControl != null)
1330
                                {
1331
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1332
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1333
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1334
                                }
1335
                            }
1336
                            break;
1337

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

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

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

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

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

    
1482
                                //inkBoard.Strokes.Add(stroke);
1483
                            }
1484
                            break;
1485
                    }
1486
                    return;
1487
                }
1488
            }
1489
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1490
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1491
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1492
            {
1493
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1494

    
1495
                if (isDraggingSelectionRect)
1496
                {
1497
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1498
                    e.Handled = true;
1499
                }
1500
                else if (isLeftMouseButtonDownOnWindow)
1501
                {
1502
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1503
                    double dragDistance = Math.Abs(dragDelta.Length);
1504

    
1505
                    if (dragDistance > DragThreshold)
1506
                    {
1507
                        isDraggingSelectionRect = true;
1508
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1509
                    }
1510

    
1511
                    e.Handled = true;
1512
                }
1513

    
1514
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1515
                {
1516
                }
1517
                else
1518
                {
1519
                    e.Handled = true;
1520
                }
1521
            }
1522
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1523
            { //symbol      
1524
                if(_dragdropWindow != null)
1525
                {
1526
                    Win32Point w32Mouse = new Win32Point();
1527
                    GetCursorPos(ref w32Mouse);
1528

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

    
1553
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1554
        {
1555
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1556
            {
1557
                SetCursor();
1558
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1559
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1560

    
1561
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1562

    
1563
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1564
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1565

    
1566
                if (Sync.IsChecked)
1567
                {
1568
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1569
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1570
                }
1571
            }
1572
        }
1573

    
1574
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1575

    
1576
        private EllipseGeometry hitArea = new EllipseGeometry();
1577

    
1578
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1579
        {
1580
            IsDrawing = false;
1581

    
1582
            if (mouseHandlingMode != MouseHandlingMode.None)
1583
            {
1584
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1585
                {
1586
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1587

    
1588
                    SetCursor();
1589

    
1590
                    switch (controlType)
1591
                    {
1592
                        case ControlType.None:
1593
                            break;
1594
                        case ControlType.Rectangle:
1595
                            {
1596

    
1597
                            }
1598
                            break;
1599
                        case ControlType.PenControl:
1600
                            {
1601

    
1602
                            }
1603
                            break;
1604
                        default:
1605
                            break;
1606
                    }
1607
                }
1608
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1609
                {
1610
                    if (isLeftMouseButtonDownOnWindow)
1611
                    {
1612
                        bool wasDragSelectionApplied = false;
1613

    
1614
                        if (isDraggingSelectionRect)
1615
                        {
1616
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1617
                            {
1618
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1619
                                mouseHandlingMode = MouseHandlingMode.None;
1620
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1621
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1622
                                Set_Symbol_Capture(endPoint);
1623
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1624
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1625
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1626
                            }
1627
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1628
                            {
1629
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1630
                                mouseHandlingMode = MouseHandlingMode.None;
1631
                                Set_Capture();
1632

    
1633
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1634
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1635
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1636
                            }
1637
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1638
                            {
1639
                                ApplyDragSelectionRect();
1640
                            }
1641
                            else
1642
                            {
1643
                                double x = Canvas.GetLeft(dragZoomBorder);
1644
                                double y = Canvas.GetTop(dragZoomBorder);
1645
                                double width = dragZoomBorder.Width;
1646
                                double height = dragZoomBorder.Height;
1647
                                Rect dragRect = new Rect(x, y, width, height);
1648

    
1649
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1650

    
1651
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1652
                            }
1653

    
1654
                            isDraggingSelectionRect = false;
1655
                            e.Handled = true;
1656
                            wasDragSelectionApplied = true;
1657
                        }
1658

    
1659
                        if (isLeftMouseButtonDownOnWindow)
1660
                        {
1661
                            isLeftMouseButtonDownOnWindow = false;
1662
                            this.ReleaseMouseCapture();
1663
                            e.Handled = true;
1664
                        }
1665

    
1666
                        if (!wasDragSelectionApplied)
1667
                        {
1668
                            init();
1669
                        }
1670
                    }
1671
                }
1672
                else if (e.RightButton == MouseButtonState.Pressed)
1673
                {
1674
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1675
                    SetCursor();
1676
                }
1677

    
1678
                zoomAndPanControl.ReleaseMouseCapture();
1679

    
1680

    
1681
                e.Handled = true;
1682
            }
1683
            else
1684
            {
1685
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1686
                SetCursor();
1687
            }
1688

    
1689
            ///mouseButtonDown = MouseButton.Left;
1690
            //controlType = ControlType.SingleLine;
1691
        }
1692

    
1693
        public void Set_Symbol_Capture(Point endPoint)
1694
        {       
1695
            double x = canvasDrawingMouseDownPoint.X;
1696
            double y = canvasDrawingMouseDownPoint.Y;
1697
            if(x > endPoint.X)
1698
            {
1699
                x = endPoint.X;
1700
                y = endPoint.Y;
1701
            }
1702

    
1703
            double width = dragCaptureBorder.Width;
1704
            double height = dragCaptureBorder.Height;
1705

    
1706
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1707

    
1708
            if (x < 0)
1709
            {
1710
                width += x;
1711
                x = 0;
1712
            }
1713
            if (y < 0)
1714
            {
1715
                height += y;
1716
                y = 0;
1717

    
1718
                width = (int)canvasImage.PixelWidth - x;
1719
            }
1720
            if (x + width > canvasImage.PixelWidth)
1721
            {
1722
                width = (int)canvasImage.PixelWidth - x;
1723
            }
1724
            if (y + height > canvasImage.PixelHeight)
1725
            {
1726
                height = (int)canvasImage.PixelHeight - y;
1727
            }
1728
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1729

    
1730
            string uri = "";
1731
            if (userData.COMPANY != "EXT")
1732
            {
1733
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1734
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1735
            }
1736
            else
1737
            {
1738
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1739
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1740
            }
1741

    
1742
            var defaultBitmapImage = new BitmapImage();
1743
            defaultBitmapImage.BeginInit();
1744
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1745
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1746
            defaultBitmapImage.UriSource = new Uri(uri);
1747
            defaultBitmapImage.EndInit();
1748

    
1749
            //GC.Collect();
1750

    
1751
            if (defaultBitmapImage.IsDownloading)
1752
            {
1753
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1754
                {
1755
                    defaultBitmapImage.Freeze();
1756
                    //GC.Collect();
1757
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1758
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1759
                };
1760
            }
1761
        }
1762

    
1763
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1764
        {
1765
            ///mouseButtonDown = MouseButton.Left;
1766
        }
1767

    
1768
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1769
        {
1770
            ///mouseButtonDown = MouseButton.Left;
1771
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1772
        }
1773

    
1774
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1775
        {
1776

    
1777
        }
1778

    
1779
        /// <summary>
1780
        /// select items by dragging
1781
        /// </summary>
1782
        private void ApplyDragSelectionRect()
1783
        {
1784
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1785

    
1786
            double x = Canvas.GetLeft(dragSelectionBorder);
1787
            double y = Canvas.GetTop(dragSelectionBorder);
1788
            double width = dragSelectionBorder.Width;
1789
            double height = dragSelectionBorder.Height;
1790
            Boolean Flag = false;
1791
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1792
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1793

    
1794
            Rect dragRect = new Rect(x, y, width, height);
1795
            ///dragRect.Inflate(width / 10, height / 10);
1796

    
1797
            foreach (var item in Items)
1798
            {
1799
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1800

    
1801
                if (Flag)
1802
                {
1803
                    adornerSet.Add(item);
1804
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1805
                    Control_Style(item);
1806
                }
1807
            }
1808
            if (adornerSet.Count > 0)
1809
            {
1810
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1811
                SelectLayer.Children.Add(final);
1812
            }
1813
        }
1814

    
1815
        private void InitDragSelectionRect(Point pt1, Point pt2)
1816
        {
1817
            //캡쳐 중
1818
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1819
            {
1820
                dragCaptureBorder.Visibility = Visibility.Visible;
1821
            }
1822
            //선택 중
1823
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1824
            {
1825

    
1826
                dragSelectionBorder.Visibility = Visibility.Visible;
1827
            }
1828
            else
1829
            {
1830
                dragZoomBorder.Visibility = Visibility.Visible;
1831
            }
1832
            UpdateDragSelectionRect(pt1, pt2);
1833
        }
1834

    
1835
        /// <summary>
1836
        /// Update the position and size of the rectangle used for drag selection.
1837
        /// </summary>
1838
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1839
        {
1840
            double x, y, width, height;
1841

    
1842
            //
1843
            // Determine x,y,width and height of the rect inverting the points if necessary.
1844
            // 
1845

    
1846
            if (pt2.X < pt1.X)
1847
            {
1848
                x = pt2.X;
1849
                width = pt1.X - pt2.X;
1850
            }
1851
            else
1852
            {
1853
                x = pt1.X;
1854
                width = pt2.X - pt1.X;
1855
            }
1856

    
1857
            if (pt2.Y < pt1.Y)
1858
            {
1859
                y = pt2.Y;
1860
                height = pt1.Y - pt2.Y;
1861
            }
1862
            else
1863
            {
1864
                y = pt1.Y;
1865
                height = pt2.Y - pt1.Y;
1866
            }
1867

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

    
1896
        private void drawingPannelRotate(double angle)
1897
        {
1898
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1899
            rotate.Angle = angle;
1900
            var rotationNum = Math.Abs((rotate.Angle / 90));
1901

    
1902
            if (angle == 90 || angle == 270)
1903
            {
1904
                double emptySize = zoomAndPanCanvas.Width;
1905
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1906
                zoomAndPanCanvas.Height = emptySize;
1907
            }
1908
            if (angle == 0)
1909
            {
1910
                translate.X = 0;
1911
                translate.Y = 0;
1912
            }
1913
            else if (angle == 90)
1914
            {
1915
                translate.X = zoomAndPanCanvas.Width;
1916
                translate.Y = 0;
1917
            }
1918
            else if (angle == 180)
1919
            {
1920
                translate.X = zoomAndPanCanvas.Width;
1921
                translate.Y = zoomAndPanCanvas.Height;
1922
            }
1923
            else
1924
            {
1925
                translate.X = 0;
1926
                translate.Y = zoomAndPanCanvas.Height;
1927
            }
1928

    
1929
            zoomAndPanControl.RotationAngle = rotate.Angle;
1930

    
1931

    
1932
            if (!testPanel2.IsHidden)
1933
            {
1934
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1935
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1936
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1937
            }
1938

    
1939
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1940
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1941
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1942
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1943
            ViewerDataModel.Instance.Angle = rotate.Angle;
1944
        }
1945

    
1946
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1947
        {
1948
            string Data_ = "";
1949

    
1950
            try
1951
            {
1952
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1953
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1954
                if (Data_ != null || Data_ != "")
1955
                {
1956
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1957
                }
1958
                else
1959
                {
1960
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1961
                }
1962

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

    
1989
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1990
                    {
1991
                        PointSet = new List<Point>(),
1992
                        FilePath = Data_,
1993
                        ImageData = img.Source,
1994
                        StartPoint = canvasZoomPanningMouseDownPoint,
1995
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
1996
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
1997
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
1998
                        canvasZoomPanningMouseDownPoint.Y),
1999
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2000
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2001
                    };
2002

    
2003
                    currentControl.PointSet = new List<Point>
2004
                                        {
2005
                                            currentControl.StartPoint,
2006
                                            currentControl.LeftBottomPoint,
2007
                                            currentControl.EndPoint,
2008
                                            currentControl.TopRightPoint,
2009
                                        };
2010
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2011
                    UndoData = new Undo_data()
2012
                    {
2013
                        IsUndo = false,
2014
                        Event = Event_Type.Create,
2015
                        EventTime = DateTime.Now,
2016
                        Markup_List = new List<Multi_Undo_data>()
2017
                    };
2018
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2019
                    {
2020
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2021
                    });
2022

    
2023
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2024
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2025
                    UndoData.Markup_List.Add(multi_Undo_Data);
2026
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2027

    
2028
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2029
                    currentControl.CommentID = Commons.shortGuid();
2030
                    currentControl.SymbolID = id;
2031
                    currentControl.GroupID = group_id;
2032
                    currentControl.ApplyTemplate();
2033
                    currentControl.SetImage();
2034

    
2035
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2036
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2037
                    SelectLayer.Children.Add(final);
2038
                }
2039
            }
2040
            catch (Exception ex)
2041
            {
2042
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2043
            }
2044
        }
2045

    
2046
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2047
        {            
2048
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2049
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2050
            {
2051
                set_option.Value = double.Parse(set_option.ContentText);
2052
            }
2053

    
2054
            ConvertInkControlToPolygon();
2055

    
2056
            ///TODO:
2057
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2058
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2059

    
2060
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2061
            {
2062
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2063
            }
2064
            /// up to here
2065

    
2066
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2067
            {
2068
                if (arrow_text as ArrowTextControl != null)
2069
                {
2070
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2071
                }
2072
            }
2073

    
2074
            //if (currentControl != null)
2075
            {
2076
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2077
                if (text_item_ != null)
2078
                {
2079
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2080
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2081
                    (text_item_ as TextControl).EnableEditing = false;
2082
                    currentControl = null;
2083
                }
2084

    
2085
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2086
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2087
                {
2088
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2089
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2090
                    currentControl = null;
2091
                }
2092
            }
2093

    
2094
            double Ang = 0;                                          
2095
            if (rotate.Angle != 0)
2096
            {
2097
                Ang = 360 - rotate.Angle;
2098
            }
2099

    
2100
            if (e.OriginalSource is System.Windows.Controls.Image)
2101
            {
2102
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2103
            }
2104

    
2105
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2106
            {                
2107
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2108
                if(symbol_id != null)
2109
                {
2110
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2111
                }                
2112
            }
2113

    
2114
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2115
            {
2116
                if (this._dragdropWindow != null)
2117
                {
2118
                    this._dragdropWindow.Close();
2119
                    this._dragdropWindow = null;
2120
                    symbol_id = null;
2121
                }
2122
            }
2123

    
2124
            if (e.LeftButton == MouseButtonState.Pressed)
2125
            {
2126
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2127
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2128

    
2129
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2130
                SetCursor();
2131

    
2132
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2133
            }
2134

    
2135
            if (e.MiddleButton == MouseButtonState.Pressed)
2136
            {
2137
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2138
                cursor = Cursors.SizeAll;
2139
                SetCursor();
2140
            }
2141
            if (e.RightButton == MouseButtonState.Pressed)
2142
            {
2143
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2144
                cursor = Cursors.SizeAll;
2145
                SetCursor();
2146
            }
2147
            else if (e.XButton1 == MouseButtonState.Pressed)
2148
            {
2149
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2150
                {
2151
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2152
                }
2153

    
2154
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2155

    
2156
            }
2157
            else if (e.XButton2 == MouseButtonState.Pressed)
2158
            {
2159
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2160
                {
2161
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2162
                }
2163
            }
2164

    
2165
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2166
            {
2167
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2168
                {
2169
                    if (SelectLayer.Children.Count == 0)
2170
                    {
2171
                        isLeftMouseButtonDownOnWindow = true;
2172
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2173
                    }
2174

    
2175
                    if (controlType == ControlType.None)
2176
                    {
2177
                        isLeftMouseButtonDownOnWindow = true;
2178
                    }
2179
                }
2180

    
2181
                /// 캡쳐 모드 설정
2182
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2183
                {
2184
                    dragCaptureBorder.Visibility = Visibility.Visible;
2185
                    isLeftMouseButtonDownOnWindow = true;
2186
                }
2187

    
2188
                /// 줌 모드 설정
2189
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2190
                {
2191
                    isLeftMouseButtonDownOnWindow = true;
2192
                }
2193

    
2194
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2195
                if (control != null)
2196
                {
2197
                    AdornerFinal final = null;
2198

    
2199
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2200
                    {
2201
                        /// 기존 selection 해제
2202
                        SelectionSet.Instance.UnSelect(this);
2203

    
2204
                        final = new AdornerFinal(control);
2205

    
2206
                        this.Control_Style(control);
2207

    
2208
                        if ((control as IPath) != null)
2209
                        {
2210
                            if ((control as IPath).LineSize != 0)
2211
                            {
2212
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2213
                            }
2214
                        }
2215
                        if ((control as IShapeControl) != null)
2216
                        {
2217
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2218
                            {
2219
                                ViewerDataModel.Instance.checkHatchShape = true;
2220
                            }
2221
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2222
                            {
2223
                                ViewerDataModel.Instance.checkFillShape = true;
2224
                            }
2225
                            else
2226
                            {
2227
                                ViewerDataModel.Instance.checkHatchShape = false;
2228
                                ViewerDataModel.Instance.checkFillShape = false;
2229
                            }
2230
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2231
                        }
2232

    
2233
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2234

    
2235
                        if ((control as TextControl) != null)
2236
                        {
2237
                            if(!((control as TextControl).EnableEditing)) {
2238
                                (control as TextControl).EnableEditing = true;
2239
                            }
2240

    
2241
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2242
                            {
2243
                                ViewerDataModel.Instance.checkTextStyle = true;
2244
                            }
2245
                            else
2246
                            {
2247
                                ViewerDataModel.Instance.checkTextStyle = false;
2248
                            }
2249

    
2250
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2251
                            {
2252
                                ViewerDataModel.Instance.checkTextStyle = true;
2253
                            }
2254
                            else
2255
                            {
2256
                                ViewerDataModel.Instance.checkTextStyle = false;
2257
                            }
2258
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2259
                            {
2260
                                ViewerDataModel.Instance.checkTextWeight = true;
2261
                            }
2262
                            else
2263
                            {
2264
                                ViewerDataModel.Instance.checkTextWeight = false;
2265
                            }
2266
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2267
                            {
2268
                                ViewerDataModel.Instance.checkUnderLine = true;
2269
                            }
2270
                            else
2271
                            {
2272
                                ViewerDataModel.Instance.checkUnderLine = false;
2273
                            }
2274
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2275
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2276

    
2277
                        }
2278
                        else if ((control as ArrowTextControl) != null)
2279
                        {
2280
                            if (!((control as ArrowTextControl).EnableEditing))
2281
                            {
2282
                                (control as ArrowTextControl).EnableEditing = true;
2283
                            }
2284
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2285
                            {
2286
                                ViewerDataModel.Instance.checkTextStyle = true;
2287
                            }
2288
                            else
2289
                            {
2290
                                ViewerDataModel.Instance.checkTextStyle = false;
2291
                            }
2292

    
2293
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2294
                            {
2295
                                ViewerDataModel.Instance.checkTextStyle = true;
2296
                            }
2297
                            else
2298
                            {
2299
                                ViewerDataModel.Instance.checkTextStyle = false;
2300
                            }
2301
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2302
                            {
2303
                                ViewerDataModel.Instance.checkTextWeight = true;
2304
                            }
2305
                            else
2306
                            {
2307
                                ViewerDataModel.Instance.checkTextWeight = false;
2308
                            }
2309
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2310
                            {
2311
                                ViewerDataModel.Instance.checkUnderLine = true;
2312
                            }
2313
                            else
2314
                            {
2315
                                ViewerDataModel.Instance.checkUnderLine = false;
2316
                            }
2317
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2318
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2319
                        }
2320
                        else if ((control as RectCloudControl) != null)
2321
                        {
2322
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2323
                        }
2324
                        else if ((control as CloudControl) != null)
2325
                        {
2326
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2327
                        }
2328
                    }
2329
                    else
2330
                    {
2331
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2332
                        SelectionSet.Instance.UnSelect(this);
2333
                        comment.Add(control);
2334

    
2335
                        Control_Style(control);
2336

    
2337
                        final = new AdornerFinal(comment);
2338
                    }
2339

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

    
2383
                switch (controlType)
2384
                {
2385
                    case ControlType.Coordinate:
2386
                        {
2387
                            if (e.LeftButton == MouseButtonState.Pressed)
2388
                            {
2389
                                if (currentControl is CoordinateControl)
2390
                                {
2391
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2392
                                    {
2393
                                        return;
2394
                                    }
2395

    
2396
                                    CreateCommand.Instance.Execute(currentControl);
2397

    
2398
                                    currentControl = null;
2399
                                    this.cursor = Cursors.Arrow;
2400
                                }
2401
                                else
2402
                                {
2403
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2404
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2405
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2406
                                    {
2407
                                        currentControl = null;
2408
                                        this.cursor = Cursors.Arrow;
2409
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2410
                                        return;
2411
                                    }
2412
                                    else
2413
                                    {
2414
                                        currentControl = new CoordinateControl
2415
                                        {
2416
                                            Background = new SolidColorBrush(Colors.Black),
2417
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2418
                                            ControlType = ControlType.Coordinate
2419
                                        };
2420

    
2421
                                        currentControl.CommentID = Commons.shortGuid();
2422
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2423
                                        currentControl.IsNew = true;
2424

    
2425
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2426

    
2427
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2428
                                    }
2429
                                }
2430
                            }
2431
                        }
2432
                        break;
2433
                    case ControlType.InsideWhite:
2434
                        {
2435
                            if (e.LeftButton == MouseButtonState.Pressed)
2436
                            {
2437
                                if (currentControl is InsideWhiteControl)
2438
                                {
2439
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2440
                                    {
2441
                                        return;
2442
                                    }
2443

    
2444
                                    CreateCommand.Instance.Execute(currentControl);
2445

    
2446
                                    currentControl = null;
2447
                                    this.cursor = Cursors.Arrow;
2448
                                }
2449
                                else
2450
                                {
2451
                                    currentControl = new InsideWhiteControl
2452
                                    {
2453
                                        Background = new SolidColorBrush(Colors.Black),
2454
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2455
                                        ControlType = ControlType.InsideWhite
2456
                                    };
2457

    
2458
                                    currentControl.CommentID = Commons.shortGuid();
2459
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2460
                                    currentControl.IsNew = true;
2461
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2462

    
2463
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2464
                                }
2465
                            }
2466
                        }
2467
                        break;
2468
                    case ControlType.OverlapWhite:
2469
                        {
2470
                            if (e.LeftButton == MouseButtonState.Pressed)
2471
                            {
2472
                                if (currentControl is OverlapWhiteControl)
2473
                                {
2474
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2475
                                    {
2476
                                        return;
2477
                                    }
2478

    
2479
                                    CreateCommand.Instance.Execute(currentControl);
2480

    
2481
                                    currentControl = null;
2482
                                    this.cursor = Cursors.Arrow;
2483
                                }
2484
                                else
2485
                                {
2486
                                    currentControl = new OverlapWhiteControl
2487
                                    {
2488
                                        Background = new SolidColorBrush(Colors.Black),
2489
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2490
                                        ControlType = ControlType.OverlapWhite
2491
                                    };
2492

    
2493
                                    currentControl.CommentID = Commons.shortGuid();
2494
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2495
                                    currentControl.IsNew = true;
2496
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2497

    
2498
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2499
                                }
2500
                            }
2501
                        }
2502
                        break;
2503
                    case ControlType.ClipWhite:
2504
                        {
2505
                            if (e.LeftButton == MouseButtonState.Pressed)
2506
                            {
2507
                                if (currentControl is ClipWhiteControl)
2508
                                {
2509
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2510
                                    {
2511
                                        return;
2512
                                    }
2513

    
2514
                                    CreateCommand.Instance.Execute(currentControl);
2515

    
2516
                                    currentControl = null;
2517
                                    this.cursor = Cursors.Arrow;
2518
                                }
2519
                                else
2520
                                {
2521
                                    currentControl = new ClipWhiteControl
2522
                                    {
2523
                                        Background = new SolidColorBrush(Colors.Black),
2524
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2525
                                        ControlType = ControlType.ClipWhite
2526
                                    };
2527

    
2528
                                    currentControl.CommentID = Commons.shortGuid();
2529
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2530
                                    currentControl.IsNew = true;
2531
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2532

    
2533
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2534
                                }
2535
                            }
2536
                        }
2537
                        break;
2538
                    case ControlType.Rectangle:
2539
                        {
2540
                            if (e.LeftButton == MouseButtonState.Pressed)
2541
                            {
2542
                                if (currentControl is RectangleControl)
2543
                                {
2544
                                    //20180906 LJY TEST IsRotationDrawingEnable
2545
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2546
                                    {
2547
                                        return;
2548
                                    }
2549

    
2550
                                    CreateCommand.Instance.Execute(currentControl);
2551
                                    currentControl = null;
2552
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2553
                                }
2554
                                else
2555
                                {
2556
                                    currentControl = new RectangleControl
2557
                                    {
2558
                                        Background = new SolidColorBrush(Colors.Black),
2559
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2560
                                        ControlType = ControlType.Rectangle
2561
                                    };
2562

    
2563
                                    currentControl.CommentID = Commons.shortGuid();
2564
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2565
                                    currentControl.IsNew = true;
2566
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2567

    
2568
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2569
                                }
2570
                            }
2571
                        }
2572
                        break;
2573
                    case ControlType.RectCloud:
2574
                        {
2575
                            if (e.LeftButton == MouseButtonState.Pressed)
2576
                            {
2577
                                if (currentControl is RectCloudControl)
2578
                                {
2579
                                    //20180906 LJY TEST IsRotationDrawingEnable
2580
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2581
                                    {
2582
                                        return;
2583
                                    }
2584

    
2585
                                    CreateCommand.Instance.Execute(currentControl);
2586

    
2587
                                    currentControl = null;
2588
                                
2589
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2590
                                }
2591
                                else
2592
                                {
2593
                                    currentControl = new RectCloudControl
2594
                                    {
2595
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2596
                                        ControlType = ControlType.RectCloud,
2597
                                        Background = new SolidColorBrush(Colors.Black)
2598
                                    };
2599

    
2600
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2601
                                    currentControl.CommentID = Commons.shortGuid();
2602
                                    currentControl.IsNew = true;
2603
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2604
                                }
2605
                            }
2606
                        }
2607
                        break;
2608
                    case ControlType.Circle:
2609
                        {
2610
                            if (e.LeftButton == MouseButtonState.Pressed)
2611
                            {
2612
                                if (currentControl is CircleControl)
2613
                                {
2614
                                    //20180906 LJY TEST IsRotationDrawingEnable
2615
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2616
                                    {
2617
                                        return;
2618
                                    }
2619

    
2620
                                    CreateCommand.Instance.Execute(currentControl);
2621

    
2622
                                    currentControl = null;
2623
                                }
2624
                                else
2625
                                {
2626
                                    currentControl = new CircleControl
2627
                                    {
2628
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2629
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2630
                                        Background = new SolidColorBrush(Colors.Black)
2631
                                    };
2632

    
2633
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2634
                                    currentControl.CommentID = Commons.shortGuid();
2635
                                    currentControl.IsNew = true;
2636
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2637
                                }
2638
                            }
2639
                        }
2640
                        break;
2641
                    case ControlType.Triangle:
2642
                        {
2643
                            if (e.LeftButton == MouseButtonState.Pressed)
2644
                            {
2645
                                if (currentControl is TriControl)
2646
                                {
2647
                                    var content = currentControl as TriControl;
2648
                                    if (content.MidPoint == new Point(0, 0))
2649
                                    {
2650
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2651
                                    }
2652
                                    else
2653
                                    {
2654
                                        //20180906 LJY TEST IsRotationDrawingEnable
2655
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2656
                                        {
2657
                                            return;
2658
                                        }
2659

    
2660
                                        CreateCommand.Instance.Execute(currentControl);
2661

    
2662
                                        currentControl = null;
2663
                                    }
2664
                                }
2665
                                else
2666
                                {
2667
                                    currentControl = new TriControl
2668
                                    {
2669
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2670
                                        Background = new SolidColorBrush(Colors.Black),
2671
                                    };
2672

    
2673
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2674
                                    currentControl.CommentID = Commons.shortGuid();
2675
                                    currentControl.IsNew = true;
2676
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2677
                                }
2678
                            }
2679
                        }
2680
                        break;
2681
                    case ControlType.CancelLine:
2682
                    case ControlType.SingleLine:
2683
                    case ControlType.ArrowLine:
2684
                    case ControlType.TwinLine:
2685
                    case ControlType.DimLine:
2686
                        {
2687
                            if (e.LeftButton == MouseButtonState.Pressed)
2688
                            {
2689
                                if (currentControl is LineControl)
2690
                                {
2691
                                    //20180906 LJY TEST IsRotationDrawingEnable
2692
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2693
                                    {
2694
                                        return;
2695
                                    }
2696

    
2697
                                    CreateCommand.Instance.Execute(currentControl);
2698
                                    currentControl = null;
2699
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2700
                                }
2701
                                else
2702
                                {
2703
                                    currentControl = new LineControl
2704
                                    {
2705
                                        ControlType = this.controlType,
2706
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2707
                                        Background = new SolidColorBrush(Colors.Black)
2708
                                    };
2709

    
2710
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2711
                                    currentControl.CommentID = Commons.shortGuid();
2712
                                    currentControl.IsNew = true;
2713
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2714
                                    this.MainAngle.Visibility = Visibility.Visible;
2715
                                }
2716
                            }
2717
                        }
2718
                        break;
2719
                    case ControlType.PolygonControl:
2720
                        {
2721
                            if (currentControl is PolygonControl)
2722
                            {
2723
                                var control = currentControl as PolygonControl;
2724

    
2725
                                if (e.RightButton == MouseButtonState.Pressed)
2726
                                {
2727
                                    control.IsCompleted = true;
2728
                                }
2729

    
2730
                                if (!control.IsCompleted)
2731
                                {
2732
                                    control.PointSet.Add(control.EndPoint);
2733
                                }
2734
                                else
2735
                                {
2736
                                    //20180906 LJY TEST IsRotationDrawingEnable
2737
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2738
                                    {
2739
                                        return;
2740
                                    }
2741

    
2742
                                    var firstPoint = control.PointSet.First();
2743
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2744
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2745
                                    control.PointSet.Add(firstPoint);
2746

    
2747
                                    control.ApplyOverViewData();
2748

    
2749
                                    CreateCommand.Instance.Execute(currentControl);
2750
                                    control.UpdateControl();
2751
                                    currentControl = null;
2752
                                }
2753
                            }
2754
                            else
2755
                            {
2756
                                if (e.LeftButton == MouseButtonState.Pressed)
2757
                                {
2758
                                    currentControl = new PolygonControl
2759
                                    {
2760
                                        PointSet = new List<Point>(),
2761
                                    };
2762

    
2763
                                    var polygonControl = (currentControl as PolygonControl);
2764
                                    currentControl.CommentID = Commons.shortGuid();
2765
                                    currentControl.IsNew = true;
2766
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2767
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2768
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2769
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2770
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2771
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2772
                                    polygonControl.ApplyTemplate();
2773
                                    polygonControl.Visibility = Visibility.Visible;
2774
                                }
2775
                            }
2776
                        }
2777
                        break;
2778
                    case ControlType.ChainLine:
2779
                        {
2780
                            if (currentControl is PolygonControl)
2781
                            {
2782
                                var control = currentControl as PolygonControl;
2783

    
2784
                                if (e.RightButton == MouseButtonState.Pressed)
2785
                                {
2786
                                    //20180906 LJY TEST IsRotationDrawingEnable
2787
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2788
                                    {
2789
                                        return;
2790
                                    }
2791

    
2792
                                    CreateCommand.Instance.Execute(currentControl);
2793

    
2794
                                    currentControl = null;
2795
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2796
                                    return;
2797
                                }
2798

    
2799
                                if (!control.IsCompleted)
2800
                                {
2801
                                    control.PointSet.Add(control.EndPoint);
2802
                                    this.MainAngle.Visibility = Visibility.Visible;
2803
                                }
2804
                            }
2805
                            else
2806
                            {
2807
                                if (e.LeftButton == MouseButtonState.Pressed)
2808
                                {
2809
                                    MainAngle.Visibility = Visibility.Visible;
2810
                                    currentControl = new PolygonControl
2811
                                    {
2812
                                        PointSet = new List<Point>(),
2813
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2814
                                        ControlType = ControlType.ChainLine,
2815
                                        DashSize = ViewerDataModel.Instance.DashSize,
2816
                                        LineSize = ViewerDataModel.Instance.LineSize,
2817
                                        //PointC = new StylusPointSet()
2818
                                    };
2819

    
2820
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2821
                                    //{
2822
                                        var polygonControl = (currentControl as PolygonControl);
2823
                                        currentControl.CommentID = Commons.shortGuid();
2824
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2825
                                        currentControl.IsNew = true;
2826
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2827
                                        //currentControl.OnApplyTemplate();
2828
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2829
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2830
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2831
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2832
                                    //}
2833
                                }
2834
                            }
2835
                        }
2836
                        break;
2837
                    case ControlType.ArcLine:
2838
                        {
2839
                            if (e.LeftButton == MouseButtonState.Pressed)
2840
                            {
2841
                                if (currentControl is ArcControl)
2842
                                {
2843
                                    //20180906 LJY TEST IsRotationDrawingEnable
2844
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2845
                                    {
2846
                                        return;
2847
                                    }
2848

    
2849
                                    CreateCommand.Instance.Execute(currentControl);
2850

    
2851
                                    currentControl = null;
2852
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2853
                                }
2854
                                else
2855
                                {
2856
                                    currentControl = new ArcControl
2857
                                    {
2858
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2859
                                        Background = new SolidColorBrush(Colors.Black)
2860
                                    };
2861
                                    currentControl.CommentID = Commons.shortGuid();
2862
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2863
                                    currentControl.IsNew = true;
2864
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2865
                                    this.MainAngle.Visibility = Visibility.Visible;
2866
                                }
2867
                            }
2868
                            else if (e.RightButton == MouseButtonState.Pressed)
2869
                            {
2870
                                if (currentControl != null)
2871
                                {
2872
                                    (currentControl as ArcControl).setClock();
2873
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2874
                                }
2875
                            }
2876
                        }
2877
                        break;
2878
                    case ControlType.ArcArrow:
2879
                        {
2880
                            if (e.LeftButton == MouseButtonState.Pressed)
2881
                            {
2882
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2883
                                //{
2884
                                if (currentControl is ArrowArcControl)
2885
                                {
2886
                                    //20180906 LJY TEST IsRotationDrawingEnable
2887
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2888
                                    {
2889
                                        return;
2890
                                    }
2891

    
2892
                                    CreateCommand.Instance.Execute(currentControl);
2893

    
2894
                                    currentControl = null;
2895
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2896
                                }
2897
                                else
2898
                                {
2899
                                    currentControl = new ArrowArcControl
2900
                                    {
2901
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2902
                                        Background = new SolidColorBrush(Colors.Black)
2903
                                    };
2904
                                    currentControl.CommentID = Commons.shortGuid();
2905
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2906
                                    currentControl.IsNew = true;
2907
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2908
                                    this.MainAngle.Visibility = Visibility.Visible;
2909
                                }
2910
                                //}
2911
                            }
2912
                            else if (e.RightButton == MouseButtonState.Pressed)
2913
                            {
2914
                                if (currentControl != null)
2915
                                {
2916
                                    (currentControl as ArrowArcControl).setClock();
2917
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2918
                                    //(currentControl as ArcControl).ApplyTemplate();
2919
                                }
2920
                            }
2921
                        }
2922
                        break;
2923
                    case ControlType.ArrowMultiLine:
2924
                        {
2925
                            if (e.LeftButton == MouseButtonState.Pressed)
2926
                            {
2927
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2928
                                //{
2929

    
2930
                                    if (currentControl is ArrowControl_Multi)
2931
                                    {
2932
                                        var content = currentControl as ArrowControl_Multi;
2933
                                        if (content.MiddlePoint == new Point(0, 0))
2934
                                        {
2935
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2936
                                            {
2937
                                                content.MiddlePoint = content.EndPoint;
2938
                                            }
2939
                                            else
2940
                                            {
2941
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2942
                                            }
2943
                                        }
2944
                                        else
2945
                                        {
2946
                                            //20180906 LJY TEST IsRotationDrawingEnable
2947
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2948
                                            {
2949
                                                return;
2950
                                            }
2951

    
2952
                                            CreateCommand.Instance.Execute(currentControl);
2953

    
2954
                                            currentControl = null;
2955
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2956
                                        }
2957
                                    }
2958
                                    else
2959
                                    {
2960
                                        currentControl = new ArrowControl_Multi
2961
                                        {
2962
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2963
                                            Background = new SolidColorBrush(Colors.Black)
2964
                                        };
2965
                                        currentControl.CommentID = Commons.shortGuid();
2966
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2967
                                        currentControl.IsNew = true;
2968
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2969
                                        this.MainAngle.Visibility = Visibility.Visible;
2970
                                    }
2971
                                //}
2972
                            }
2973
                        }
2974
                        break;
2975
                    case ControlType.PolygonCloud:
2976
                        {
2977
                            if (currentControl is CloudControl)
2978
                            {
2979
                                var control = currentControl as CloudControl;
2980
                                if (e.RightButton == MouseButtonState.Pressed)
2981
                                {
2982
                                    control.IsCompleted = true;
2983
                                }
2984

    
2985
                                if (!control.IsCompleted)
2986
                                {
2987
                                    control.PointSet.Add(control.EndPoint);
2988
                                }
2989
                                else
2990
                                {
2991
                                    //20180906 LJY TEST IsRotationDrawingEnable
2992
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2993
                                    {
2994
                                        return;
2995
                                    }
2996

    
2997
                                    CreateCommand.Instance.Execute(currentControl);
2998

    
2999
                                    control.isTransOn = true;
3000
                                    var firstPoint = control.PointSet.First();
3001

    
3002
                                    control.PointSet.Add(firstPoint);
3003
                                    control.DrawingCloud();
3004
                                    control.ApplyOverViewData();
3005

    
3006
                                    currentControl = null;
3007
                                }
3008
                            }
3009
                            else
3010
                            {
3011
                                if (e.LeftButton == MouseButtonState.Pressed)
3012
                                {
3013
                                    currentControl = new CloudControl
3014
                                    {
3015
                                        PointSet = new List<Point>(),
3016
                                        PointC = new StylusPointSet()
3017
                                    };
3018

    
3019
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3020
                                    //{
3021
                                        var polygonControl = (currentControl as CloudControl);
3022
                                        currentControl.CommentID = Commons.shortGuid();
3023
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3024
                                        currentControl.IsNew = true;
3025
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3026

    
3027
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3028
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3029
                                    
3030
                                    //}
3031
                                }
3032
                            }
3033
                        }
3034
                        break;
3035
                    case ControlType.ImgControl:
3036
                        {
3037
                            if (e.LeftButton == MouseButtonState.Pressed)
3038
                            {
3039
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3040
                                //{
3041
                                    if (currentControl is ImgControl)
3042
                                    {
3043
                                        //20180906 LJY TEST IsRotationDrawingEnable
3044
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3045
                                        {
3046
                                            return;
3047
                                        }
3048

    
3049
                                        CreateCommand.Instance.Execute(currentControl);
3050
                                        controlType = ControlType.ImgControl;
3051
                                        currentControl = null;
3052
                                    }
3053
                                    else
3054
                                    {
3055
                                        
3056
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3057
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3058
                                        {
3059
                                            Image img = new Image();
3060
                                            if (filename.Contains(".svg"))
3061
                                            {
3062
                                                byte[] imageData = null;
3063
                                                DrawingImage image = null;
3064
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3065
                                                {
3066
                                                    imageData = web.DownloadData(new Uri(filename));
3067
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3068
                                                    image = SvgReader.Load(stream);
3069
                                                }
3070
                                                img.Source = image;
3071
                                            }
3072
                                            else
3073
                                            {
3074
                                                img.Source = new BitmapImage(new Uri(filename));
3075
                                            }
3076

    
3077
                                            currentControl = new ImgControl
3078
                                            {
3079
                                                    Background = new SolidColorBrush(Colors.Black),
3080
                                                    PointSet = new List<Point>(),
3081
                                                    FilePath = filename,
3082
                                                    ImageData = img.Source,
3083
                                                    StartPoint = canvasDrawingMouseDownPoint,
3084
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3085
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3086
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3087
                                                    ControlType = ControlType.ImgControl
3088
                                                };
3089

    
3090
                                        
3091
                                                currentControl.CommentID = Commons.shortGuid();                                            
3092
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3093
                                                currentControl.IsNew = true;
3094
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3095

    
3096
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3097
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3098
                                        }
3099
                                    }
3100
                                //}
3101
                            }
3102
                        }
3103
                        break;
3104
                    case ControlType.Date:
3105
                        {
3106
                            if (e.LeftButton == MouseButtonState.Pressed)
3107
                            {
3108
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3109
                                //{
3110
                                    if (currentControl is DateControl)
3111
                                    {
3112
                                        //20180906 LJY TEST IsRotationDrawingEnable
3113
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3114
                                        {
3115
                                            return;
3116
                                        }
3117

    
3118
                                        CreateCommand.Instance.Execute(currentControl);
3119
                                        currentControl = null;
3120

    
3121
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3122
                                        {
3123
                                            controlType = ControlType.None;
3124
                                            IsSwingMode = false;
3125
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3126
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3127
                                            mouseHandlingMode = MouseHandlingMode.None;
3128
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3129
                                            txtBatch.Visibility = Visibility.Collapsed;
3130

    
3131
                                        }
3132
                                    }
3133
                                    else
3134
                                    {
3135
                                        currentControl = new DateControl
3136
                                        {
3137
                                            StartPoint = canvasDrawingMouseDownPoint,
3138
                                            Background = new SolidColorBrush(Colors.Black)
3139
                                        };
3140
                                        currentControl.CommentID = Commons.shortGuid();
3141
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3142
                                        currentControl.IsNew = true;
3143
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3144

    
3145
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3146
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3147
                                }
3148
                                //}
3149
                            }
3150
                        }
3151
                        break;
3152
                    case ControlType.TextControl:
3153
                        {
3154
                            if (e.LeftButton == MouseButtonState.Pressed)
3155
                            {
3156
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3157
                                {
3158
                                    currentControl = new TextControl
3159
                                    {
3160
                                        ControlType = controlType
3161
                                    };
3162
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3163
                                    currentControl.CommentID = Commons.shortGuid();
3164
                                    currentControl.IsNew = true;
3165
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3166
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3167
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3168

    
3169
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3170
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3171
                                    
3172
                                    (currentControl as TextControl).ControlType_No = 0;
3173
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3174
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3175
                                    (currentControl as TextControl).ApplyTemplate();
3176
                                    (currentControl as TextControl).Base_TextBox.Focus();
3177

    
3178
                                    CreateCommand.Instance.Execute(currentControl);
3179
                                }
3180
                            }
3181
                        }
3182
                        break;
3183
                    case ControlType.TextBorder:
3184
                        {
3185
                            if (e.LeftButton == MouseButtonState.Pressed)
3186
                            {
3187
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3188
                                {
3189
                                    currentControl = new TextControl
3190
                                    {
3191
                                        ControlType = controlType
3192
                                    };
3193

    
3194
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3195
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3196
                                    currentControl.CommentID = Commons.shortGuid();
3197
                                    currentControl.IsNew = true;
3198
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3199
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3200
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3201
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3202
                                    
3203
                                    (currentControl as TextControl).ControlType_No = 1;
3204
                                    (currentControl as TextControl).Angle = Ang;
3205
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3206
                                    (currentControl as TextControl).ApplyTemplate();
3207
                                    (currentControl as TextControl).Base_TextBox.Focus();
3208
                                    CreateCommand.Instance.Execute(currentControl);
3209
                                }
3210
                            }
3211
                        }
3212
                        break;
3213
                    case ControlType.TextCloud:
3214
                        {
3215
                            if (e.LeftButton == MouseButtonState.Pressed)
3216
                            {
3217
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3218
                                {
3219
                                    currentControl = new TextControl
3220
                                    {
3221
                                        ControlType = controlType
3222
                                    };
3223

    
3224
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3225
                                    currentControl.CommentID = Commons.shortGuid();
3226
                                    currentControl.IsNew = true;
3227
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3228
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3229

    
3230
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3231
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3232
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3233

    
3234
                                    (currentControl as TextControl).Angle = Ang;
3235
                                    (currentControl as TextControl).ControlType_No = 2;
3236
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3237
                                    (currentControl as TextControl).ApplyTemplate();
3238
                                    (currentControl as TextControl).Base_TextBox.Focus();
3239
                                    CreateCommand.Instance.Execute(currentControl);
3240
                                    //currentControl = null;
3241
                                }
3242
                            }
3243
                        }
3244
                        break;
3245
                    case ControlType.ArrowTextControl:
3246
                         {
3247
                            if (e.LeftButton == MouseButtonState.Pressed)
3248
                            {
3249
                                if (currentControl is ArrowTextControl)
3250
                                {
3251
                                    //20180906 LJY TEST IsRotationDrawingEnable
3252
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3253
                                    {
3254
                                        return;
3255
                                    }
3256

    
3257
                                    CreateCommand.Instance.Execute(currentControl);
3258

    
3259
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3260
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3261
                                    (currentControl as ArrowTextControl).IsNew = false;
3262
                                    currentControl = null;
3263
                                }
3264
                                else
3265
                                {
3266
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3267
                                    //{
3268
                                        currentControl = new ArrowTextControl();
3269
                                        currentControl.CommentID = Commons.shortGuid();
3270
                                        currentControl.IsNew = true;
3271
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3272
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3273

    
3274
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3275
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3276
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3277
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3278
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3279

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

    
3283
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3284
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3285
                                        this.MainAngle.Visibility = Visibility.Visible;
3286

    
3287
                                    
3288
                                    //}
3289
                                }
3290
                            }
3291
                        }
3292
                        break;
3293
                    case ControlType.ArrowTransTextControl:
3294
                        {
3295
                            if (e.LeftButton == MouseButtonState.Pressed)
3296
                            {
3297
                                if (currentControl is ArrowTextControl)
3298
                                {
3299
                                    //20180906 LJY TEST IsRotationDrawingEnable
3300
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3301
                                    {
3302
                                        return;
3303
                                    }
3304

    
3305
                                    CreateCommand.Instance.Execute(currentControl);
3306
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3307
                                    currentControl.IsNew = false;
3308
                                    currentControl = null;
3309
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3310
                                }
3311
                                else
3312
                                {
3313
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3314
                                    //{
3315
                                    currentControl = new ArrowTextControl()
3316
                                    {
3317
                                        ControlType = ControlType.ArrowTransTextControl
3318
                                    };
3319
                                    currentControl.CommentID = Commons.shortGuid();
3320
                                    currentControl.IsNew = true;
3321
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3322
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3323
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3324
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3325
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3326
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3327
                                    (currentControl as ArrowTextControl).isFixed = true;
3328
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3329

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

    
3333
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3334
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3335
                                    (currentControl as ArrowTextControl).isTrans = true;
3336
                                }
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.ArrowTextBorderControl:
3341
                         {
3342
                            if (e.LeftButton == MouseButtonState.Pressed)
3343
                            {
3344
                                if (currentControl is ArrowTextControl)
3345
                                {
3346
                                    //20180906 LJY TEST IsRotationDrawingEnable
3347
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3348
                                    {
3349
                                        return;
3350
                                    }
3351

    
3352
                                    CreateCommand.Instance.Execute(currentControl);
3353
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3354
                                    currentControl.IsNew = false;
3355
                                    currentControl = null;
3356
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3357
                                }
3358
                                else
3359
                                {
3360
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3361
                                    //{
3362
                                        currentControl = new ArrowTextControl()
3363
                                        {
3364
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3365
                                        };
3366
                                        currentControl.CommentID = Commons.shortGuid();
3367
                                        currentControl.IsNew = true;
3368
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3369
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3370

    
3371
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3372

    
3373
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3374

    
3375
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3376
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3377
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3378

    
3379
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3380
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3381
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3382
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3383
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3384
                                    //}
3385
                                }
3386
                            }
3387
                        }
3388
                        break;
3389
                    case ControlType.ArrowTransTextBorderControl:
3390
                        {
3391
                            if (e.LeftButton == MouseButtonState.Pressed)
3392
                            {
3393
                                if (currentControl is ArrowTextControl)
3394
                                {
3395
                                    //20180906 LJY TEST IsRotationDrawingEnable
3396
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3397
                                    {
3398
                                        return;
3399
                                    }
3400
                                    CreateCommand.Instance.Execute(currentControl);
3401
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3402
                                    currentControl.IsNew = false;
3403
                                    currentControl = null;
3404
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3405
                                }
3406
                                else
3407
                                {
3408
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3409
                                    //{
3410
                                    
3411

    
3412
                                    currentControl = new ArrowTextControl()
3413
                                    {
3414
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3415
                                        ControlType = ControlType.ArrowTransTextBorderControl
3416

    
3417
                                    };
3418
                                        currentControl.CommentID = Commons.shortGuid();
3419
                                        currentControl.IsNew = true;
3420
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3421
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3422

    
3423
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3424

    
3425
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3426
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3427
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3428
                                        (currentControl as ArrowTextControl).isFixed = true;
3429
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3430
                                     
3431
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3432
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3433
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3434

    
3435
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3436
                                        this.MainAngle.Visibility = Visibility.Visible;
3437
                                    
3438
                                    //20180911 LJY
3439
                                        (currentControl as ArrowTextControl).isTrans = true;
3440
                                    
3441

    
3442
                                    //}
3443
                                }
3444
                            }
3445
                        }
3446
                        break;
3447
                    case ControlType.ArrowTextCloudControl:
3448
                        {
3449
                            if (e.LeftButton == MouseButtonState.Pressed)
3450
                            {
3451
                                if (currentControl is ArrowTextControl)
3452
                                {
3453
                                    //20180906 LJY TEST IsRotationDrawingEnable
3454
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3455
                                    {
3456
                                        return;
3457
                                    }
3458
                                    CreateCommand.Instance.Execute(currentControl);
3459
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3460
                                    currentControl.IsNew = false;
3461
                                    currentControl = null;
3462
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3463
                                }
3464
                                else
3465
                                {
3466
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3467
                                    //{
3468
                                        currentControl = new ArrowTextControl()
3469
                                        {
3470
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3471
                                        };
3472
                                        currentControl.CommentID = Commons.shortGuid();
3473
                                        currentControl.IsNew = true;
3474
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3475
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3476

    
3477
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3478
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3479
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3480
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3481
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3482

    
3483
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3484
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3485
                                    
3486
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3487
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3488
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3489
                                    //}
3490
                                }
3491
                            }
3492
                        }
3493
                        break;
3494
                    case ControlType.ArrowTransTextCloudControl:
3495
                        {
3496
                            if (e.LeftButton == MouseButtonState.Pressed)
3497
                            {
3498
                                if (currentControl is ArrowTextControl)
3499
                                {
3500
                                    //20180906 LJY TEST IsRotationDrawingEnable
3501
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3502
                                    {
3503
                                        return;
3504
                                    }
3505
                                    CreateCommand.Instance.Execute(currentControl);
3506
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3507
                                    currentControl.IsNew = false;
3508
                                    currentControl = null;
3509
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3510
                                }
3511
                                else
3512
                                {
3513
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3514
                                    //{
3515
                                        currentControl = new ArrowTextControl()
3516
                                        {
3517
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3518
                                            ControlType = ControlType.ArrowTransTextCloudControl
3519

    
3520
                                        };
3521
                                        currentControl.CommentID = Commons.shortGuid();
3522
                                        currentControl.IsNew = true; 
3523
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3524
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3525
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3526

    
3527
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3528
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3529
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3530
                                        (currentControl as ArrowTextControl).isFixed = true;
3531
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3532

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

    
3536
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3537
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3538
                                        this.MainAngle.Visibility = Visibility.Visible;  
3539
                                    
3540
                                    //20180911 LJY
3541
                                        (currentControl as ArrowTextControl).isTrans = true;
3542
                                    //}
3543
                                }
3544
                            }
3545
                        }
3546
                        break;
3547
                    //강인구 추가
3548
                    case ControlType.Sign:
3549
                        {
3550
                            if (e.LeftButton == MouseButtonState.Pressed)
3551
                            {
3552
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3553
                                //{
3554
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3555

    
3556
                                    if (_sign == null)
3557
                                    {
3558
                                        txtBatch.Visibility = Visibility.Collapsed;
3559
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3560
                                        controlType = ControlType.None;
3561

    
3562
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3563
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3564
                                        return;
3565
                                    }
3566

    
3567
                                    if (currentControl is SignControl)
3568
                                    {
3569
                                        //20180906 LJY TEST IsRotationDrawingEnable
3570
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3571
                                        {
3572
                                            return;
3573
                                        }
3574

    
3575
                                        CreateCommand.Instance.Execute(currentControl);
3576
                                        currentControl = null;
3577
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3578
                                        {
3579
                                            txtBatch.Text = "Place Date";
3580
                                            controlType = ControlType.Date;
3581
                                        }
3582
                                    }
3583
                                    else
3584
                                    {
3585
                                        currentControl = new SignControl
3586
                                        {
3587
                                            Background = new SolidColorBrush(Colors.Black),
3588
                                            UserNumber = App.ViewInfo.UserID,
3589
                                            ProjectNO = App.ViewInfo.ProjectNO,
3590
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3591
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3592
                                            ControlType = ControlType.Sign
3593
                                        };
3594

    
3595
                                        currentControl.CommentID = Commons.shortGuid();
3596
                                        currentControl.IsNew = true;
3597
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3598
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3599

    
3600
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3601
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3602
                                }
3603
                                //}
3604
                            }
3605
                        }
3606
                        break;
3607
                    case ControlType.Mark:
3608
                        {
3609
                            if (e.LeftButton == MouseButtonState.Pressed)
3610
                            {
3611
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3612
                                //{
3613
                                    if (currentControl is RectangleControl)
3614
                                    {
3615
                                        //20180906 LJY TEST IsRotationDrawingEnable
3616
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3617
                                        {
3618
                                            return;
3619
                                        }
3620

    
3621
                                        CreateCommand.Instance.Execute(currentControl);
3622
                                        (currentControl as RectangleControl).ApplyOverViewData();
3623
                                        currentControl = null;
3624
                                    
3625
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3626

    
3627
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3628
                                        {
3629
                                            txtBatch.Text = "Place Signature";
3630
                                            controlType = ControlType.Sign;
3631
                                        }
3632
                                    }
3633
                                    else
3634
                                    {
3635
                                        currentControl = new RectangleControl
3636
                                        {
3637
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3638
                                            Background = new SolidColorBrush(Colors.Black),
3639
                                            ControlType = ControlType.Mark ,
3640
                                            Paint = PaintSet.Fill
3641
                                        };
3642

    
3643
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3644
                                        currentControl.CommentID = Commons.shortGuid();
3645
                                        currentControl.IsNew = true;
3646
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3647
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3648
                                    }
3649
                                //}
3650
                            }
3651
                        }
3652
                        break;
3653
                    case ControlType.Symbol:
3654
                        {
3655
                            if (e.LeftButton == MouseButtonState.Pressed)
3656
                            {
3657
                                if (currentControl is SymControl)
3658
                                {
3659
                                    //20180906 LJY TEST IsRotationDrawingEnable
3660
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3661
                                    {
3662
                                        return;
3663
                                    }
3664
                                    CreateCommand.Instance.Execute(currentControl);
3665
                                    currentControl = null;
3666
                                
3667
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3668
                                }
3669
                                else
3670
                                {
3671
                                    currentControl = new SymControl
3672
                                    {
3673
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3674
                                        Background = new SolidColorBrush(Colors.Black),
3675
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3676
                                        ControlType = ControlType.Symbol
3677
                                    };
3678

    
3679
                                    currentControl.IsNew = true;
3680
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3681
                                    currentControl.CommentID = Commons.shortGuid();
3682
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3683

    
3684
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3685
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3686
                                }
3687
                                //}
3688
                            }
3689
                        }
3690
                        break;
3691
                    case ControlType.Stamp:
3692
                        {
3693
                            if (e.LeftButton == MouseButtonState.Pressed)
3694
                            {
3695
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3696
                                //{
3697
                                    if (currentControl is SymControlN)
3698
                                    {
3699
                                        //20180906 LJY TEST IsRotationDrawingEnable
3700
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3701
                                        {
3702
                                            return;
3703
                                        }
3704

    
3705
                                        CreateCommand.Instance.Execute(currentControl);
3706
                                        currentControl = null;
3707
                                   
3708

    
3709
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3710
                                    }
3711
                                    else
3712
                                    {
3713
                                        currentControl = new SymControlN
3714
                                        {
3715
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3716
                                            Background = new SolidColorBrush(Colors.Black),
3717
                                            STAMP = App.SystemInfo.STAMP,
3718
                                            ControlType = ControlType.Stamp
3719
                                        };
3720

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

    
3769
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3770
                            if (over != null)
3771
                            {
3772
                                mouseOff = true;
3773
                            }
3774
                        }
3775
                    }
3776

    
3777
                    if (!mouseOff)
3778
                    {
3779
                        SelectionSet.Instance.UnSelect(this);
3780
                    }
3781
                }
3782
                zoomAndPanControl.CaptureMouse();
3783
                e.Handled = true;
3784
            }
3785
        }
3786

    
3787
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3788
        {
3789
            ///mouseButtonDown = e.ChangedButton;
3790
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3791
        }
3792

    
3793
        private void RemoveLineStroke(Point P)
3794
        {
3795
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3796
            if (control != null)
3797
            {
3798
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3799
            }
3800
        }
3801

    
3802
        private void RemovePointStroke(Point P)
3803
        {
3804
            foreach (Stroke hits in inkBoard.Strokes)
3805
            {
3806
                foreach (StylusPoint sty in hits.StylusPoints)
3807
                {
3808

    
3809
                }
3810
                if (hits.HitTest(P))
3811
                {
3812
                    inkBoard.Strokes.Remove(hits);
3813
                    return;
3814
                }
3815
            }
3816
        }
3817

    
3818
        private void StartNewStroke(Point P)
3819
        {
3820
            strokePoints = new StylusPointCollection();
3821
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3822
            strokePoints.Add(segment1Start);
3823
            stroke = new Stroke(strokePoints);
3824

    
3825
            stroke.DrawingAttributes.Color = Colors.Red;
3826
            stroke.DrawingAttributes.Width = 4;
3827
            stroke.DrawingAttributes.Height = 4;
3828

    
3829
            inkBoard.Strokes.Add(stroke);
3830

    
3831
        }
3832

    
3833
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3834
        {
3835
            ConsolidationMethod();
3836
        }
3837

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

    
3851
                ViewerDataModel.Instance.IsConsolidate = true;
3852
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3853

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

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

    
3890
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3891
        {
3892
            if (App.ViewInfo != null)
3893
            {
3894
                btnConsolidate = (sender as RadRibbonButton);
3895
                if (!App.ViewInfo.NewCommentPermission)
3896
                {
3897
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3898
                }
3899
            }
3900
        }
3901

    
3902
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3903
        {
3904
            TeamConsolidationMethod();
3905
        }
3906

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

    
3919
                    if (!App.ViewInfo.NewCommentPermission)
3920
                    {
3921
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3922
                    }
3923
                }
3924
                else
3925
                {
3926
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3927
                }
3928
            }
3929
        }
3930

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

    
3938
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3939
            }
3940
            else
3941
            {
3942
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3943
            }
3944
        }
3945

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

    
3962
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3963
        {
3964
            UpdateMyMarkupList();
3965

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

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

    
3989
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3990
                if (item2 != null)
3991
                {
3992
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3993

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

    
4004
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4005
        {
4006
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4007

    
4008
            if (App.ViewInfo != null)
4009
            {
4010
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4011
                {
4012
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4013
                }
4014
            }
4015
        }
4016

    
4017
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4018
        {
4019
            if (CompareMode.IsChecked)
4020
            {
4021
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4022
                {
4023
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4024
                }
4025
                if (ViewerDataModel.Instance.PageNumber == 0)
4026
                {
4027
                    ViewerDataModel.Instance.PageNumber = 1;
4028
                }
4029

    
4030
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4031
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4032
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4033

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

    
4047
        private void Sync_Click(object sender, RoutedEventArgs e)
4048
        {
4049
            if (Sync.IsChecked)
4050
            {
4051
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4052
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4053
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4054
            }
4055
        }
4056

    
4057
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4058
        {
4059
            if (UserList.IsChecked)
4060
            {
4061
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4062
            }
4063
            else
4064
            {
4065
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4066
            }
4067
        }
4068

    
4069
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4070
        {
4071

    
4072
            if (BalanceMode.IsChecked)
4073
            {
4074
                ViewerDataModel.Instance.PageBalanceMode = true;
4075
            }
4076
            else
4077
            {
4078
                ViewerDataModel.Instance.PageBalanceMode = false;
4079
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4080
            }
4081
        }
4082

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

    
4096
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4097
        {
4098
            if ((sender as System.Windows.Controls.Control).Tag != null)
4099
            {
4100
                //Compare 초기화
4101
                CompareMode.IsChecked = false;
4102
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4103

    
4104
                if (ViewerDataModel.Instance.PageNumber == 0)
4105
                {
4106
                    ViewerDataModel.Instance.PageNumber = 1;
4107
                }
4108

    
4109
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4110
                {
4111
                }
4112
                else
4113
                {
4114
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4115
                }
4116

    
4117
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4118
                {
4119

    
4120
                }
4121
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4122
                {
4123
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4124
                }
4125

    
4126
                if (!testPanel2.IsHidden)
4127
                {
4128
                    if (IsSyncPDFMode)
4129
                    {
4130
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4131
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4132

    
4133
                        if (pdfpath.IsDownloading)
4134
                        {
4135
                            pdfpath.DownloadCompleted += (ex, arg) =>
4136
                            {
4137
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4138
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4139
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4140
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4141
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4142
                            };
4143
                        }
4144
                        else
4145
                        {
4146
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4147
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4148
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4149

    
4150
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4151
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4152
                        }
4153

    
4154
                    }
4155
                    else
4156
                    {
4157
                        string uri = "";
4158

    
4159
                        if (userData.COMPANY != "EXT")
4160
                        {
4161
                            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);
4162
                        }
4163
                        else
4164
                        {
4165
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4166
                        }
4167

    
4168
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4169

    
4170
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4171
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4172
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4173

    
4174
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4175
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4176

    
4177
                        if (defaultBitmapImage_Compare.IsDownloading)
4178
                        {
4179
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4180
                            {
4181
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4182
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4183
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4184

    
4185
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4186
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4187
                            };
4188
                        }
4189
                    }
4190

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

    
4195
                    foreach (var item in gridSelectionRevItem)
4196
                    {
4197
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4198
                        {
4199
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4200
                        });
4201
                    }
4202

    
4203
                    //강인구 추가
4204
                    zoomAndPanControl2.ZoomTo(new Rect
4205
                    {
4206
                        X = 0,
4207
                        Y = 0,
4208
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4209
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4210
                    });
4211

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

    
4214
                }
4215
            }
4216
        }
4217

    
4218
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4219
        {
4220
            if (MarkupMode.IsChecked)
4221
            {
4222
                IsSyncPDFMode = true;
4223

    
4224
                var uri = CurrentRev.TO_VENDOR;
4225

    
4226
                if (ViewerDataModel.Instance.PageNumber == 0)
4227
                {
4228
                    ViewerDataModel.Instance.PageNumber = 1;
4229
                }
4230

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

    
4235
                if (pdfpath.IsDownloading)
4236
                {
4237
                    pdfpath.DownloadCompleted += (ex, arg) =>
4238
                    {
4239
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4240
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4241
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4242
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4243
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4244
                    };
4245
                }
4246
                else
4247
                {
4248
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4249
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4250
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4251

    
4252
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4253
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4254
                }
4255
            }
4256
            else
4257
            {
4258
                IsSyncPDFMode = false;
4259
                string uri = "";
4260
                if (userData.COMPANY != "EXT")
4261
                {
4262
                    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);
4263
                }
4264
                else
4265
                {
4266
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4267
                }
4268

    
4269
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4270

    
4271
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4272
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4273
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4274

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

    
4291
        private void RadButton_Click(object sender, RoutedEventArgs e)
4292
        {
4293
            gridViewHistory_Busy.IsBusy = true;
4294

    
4295
            RadButton instance = sender as RadButton;
4296
            if (instance.CommandParameter != null)
4297
            {
4298
                CurrentRev = instance.CommandParameter as VPRevision;
4299
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4300
                {
4301
                    if (ea.Error == null && ea.Result != null)
4302
                    {
4303
                        testPanel2.IsHidden = false;
4304

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

    
4321
                        string uri = "";
4322
                        if (userData.COMPANY != "EXT")
4323
                        {
4324
                            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);
4325
                        }
4326
                        else
4327
                        {
4328
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4329
                        }
4330

    
4331
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4332

    
4333
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4334

    
4335
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4336
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4337
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4338

    
4339
                        if (defaultBitmapImage_Compare.IsDownloading)
4340
                        {
4341
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4342
                            {
4343
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4344
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4345
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4346
                            };
4347
                        }
4348

    
4349
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4350
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4351
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4352
                        zoomAndPanControl2.ApplyTemplate();
4353
                        zoomAndPanControl2.UpdateLayout();
4354

    
4355
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4356
                        {
4357
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4358
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4359
                        }
4360

    
4361
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4362
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4363
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4364

    
4365
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4366
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4367
                        gridViewHistory_Busy.IsBusy = false;
4368
                    }
4369

    
4370
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4371
                };
4372
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4373
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4374
            }
4375
        }
4376

    
4377
        public void Sync_Event(VPRevision Currnet_Rev)
4378
        {
4379
            CurrentRev = Currnet_Rev;
4380

    
4381
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4382
            {
4383
                if (ea.Error == null && ea.Result != null)
4384
                {
4385
                    testPanel2.IsHidden = false;
4386

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

    
4403
                    string uri = "";
4404
                    if (userData.COMPANY != "EXT")
4405
                    {
4406
                        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);
4407
                    }
4408
                    else
4409
                    {
4410
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4411
                    }
4412

    
4413
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4414

    
4415
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4416

    
4417
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4418
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4419
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4420

    
4421
                    if (defaultBitmapImage_Compare.IsDownloading)
4422
                    {
4423
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4424
                        {
4425
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4426
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4427
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4428
                        };
4429
                    }
4430

    
4431

    
4432
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4433
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4434
                    zoomAndPanControl2.ApplyTemplate();
4435
                    zoomAndPanControl2.UpdateLayout();
4436

    
4437
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4438
                    {
4439
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4440
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4441
                    }
4442
                    //}
4443

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

    
4450
            };
4451
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4452
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4453
        }
4454

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

    
4471
        private void Create_Symbol(object sender, RoutedEventArgs e)
4472
        {
4473
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4474

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

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

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

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

    
4548
                            if (symbolsvg == true)
4549
                            {
4550
                                try
4551
                                {
4552
                                    var defaultBitmapImage = new BitmapImage();
4553
                                    defaultBitmapImage.BeginInit();
4554
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4555
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4556
                                    Check_Uri.UriCheck(filename);
4557
                                    defaultBitmapImage.UriSource = new Uri(filename);
4558
                                    defaultBitmapImage.EndInit();
4559

    
4560
                                    System.Drawing.Bitmap image;
4561

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

    
4584
                                            StringBuilder svgBuilder = new StringBuilder();
4585
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4586
                                            {
4587
                                                svgBuilder.AppendLine(e2.Data);
4588
                                            };
4589

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

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

    
4631
        public void SymbolSave(string Name, string Url, string Data)
4632
        {
4633
            try
4634
            {
4635
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4636
                {
4637
                    ID = Commons.shortGuid(),
4638
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4639
                    NAME = Name,
4640
                    IMAGE_URL = Url,
4641
                    DATA = Data
4642
                };
4643

    
4644
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4645
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4646
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4647
            }
4648
            catch (Exception)
4649
            {
4650
                throw;
4651
            }
4652
        }
4653

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

    
4676
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4677
        {           
4678
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4679
            DataBind();
4680
        }
4681

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

    
4708
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4709

    
4710
                List<SYMBOL_PUBLIC> symbol_Public;
4711

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

    
4747
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4748
                        _Encoder.Save(fs);
4749
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4750

    
4751
                        byte[] Img_byte = fs.ToArray();
4752

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

    
4774
        public PngBitmapEncoder symImage(string data)
4775
        {
4776

    
4777
            Canvas _canvas = new Canvas();
4778
            _canvas.Background = Brushes.White;
4779
            _canvas.Width = adorner_.BorderSize.Width;
4780
            _canvas.Height = adorner_.BorderSize.Height;
4781
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4782

    
4783
            BitmapEncoder encoder = new PngBitmapEncoder();
4784

    
4785

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

    
4788
            DrawingVisual dv = new DrawingVisual();
4789

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

    
4793
            using (DrawingContext ctx = dv.RenderOpen())
4794
            {
4795
                VisualBrush vb = new VisualBrush(_canvas);
4796
                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)));
4797
            }
4798

    
4799
            try
4800
            {
4801
                renderBitmap.Render(dv);
4802

    
4803
                //GC.Collect();
4804
                GC.WaitForPendingFinalizers();
4805
                //GC.Collect();
4806
                // encode png data
4807
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4808
                // puch rendered bitmap into it
4809
                pngEncoder.Interlace = PngInterlaceOption.Off;
4810
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4811
                return pngEncoder;
4812

    
4813
            }
4814
            catch //(Exception ex)
4815
            {
4816
                return null;
4817
            }
4818

    
4819
        }
4820

    
4821
        public void DialogMessage_Alert(string content, string header)
4822
        {
4823
            var box = new TextBlock();
4824
            box.MinWidth = 400;
4825
            box.FontSize = 11;
4826
            //box.FontSize = 12;
4827
            box.Text = content;
4828
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4829

    
4830
            DialogParameters parameters = new DialogParameters()
4831
            {
4832
                Owner = Application.Current.MainWindow,
4833
                Content = box,
4834
                Header = header,
4835
                Theme = new VisualStudio2013Theme(),
4836
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4837
            };            
4838
            RadWindow.Alert(parameters);
4839
        }
4840

    
4841
        #region 캡쳐 기능
4842

    
4843
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4844
        {
4845
            if (x < 0)
4846
            {
4847
                width += x;
4848
                x = 0;
4849
            }
4850
            if (y < 0)
4851
            {
4852
                height += y;
4853
                y = 0;
4854

    
4855
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4856
            }
4857
            if (x + width > zoomAndPanCanvas.ActualWidth)
4858
            {
4859
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4860
            }
4861
            if (y + height > zoomAndPanCanvas.ActualHeight)
4862
            {
4863
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4864
            }
4865

    
4866
            byte[] pixels = CopyPixels(x, y, width, height);
4867

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

    
4870
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4871
        }
4872

    
4873
        public byte[] CopyPixels(int x, int y, int width, int height)
4874
        {
4875
            byte[] pixels = new byte[width * height * 4];
4876
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4877

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

    
4881
            return pixels;
4882
        }
4883

    
4884
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4885
        {
4886
            DrawingVisual drawingVisual = new DrawingVisual();
4887
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4888

    
4889
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4890
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4891
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4892
            drawingContext.Close();
4893

    
4894
            // 비트맵으로 변환합니다.
4895
            RenderTargetBitmap target =
4896
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4897
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4898

    
4899
            target.Render(drawingVisual);
4900
            return target;
4901
        }
4902

    
4903
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4904
        {
4905
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4906
            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);
4907
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4908
            bmp.UnlockBits(data);
4909
            return bmp;
4910
        }
4911
        public string symbolname = null;
4912
        public bool symbolsvg = true;
4913
        public bool symbolpng = true;
4914

    
4915
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4916
        {
4917
            System.Drawing.Bitmap image = GetBitmap(source);
4918
            //흰색 제거
4919
            //image.MakeTransparent(System.Drawing.Color.White);
4920

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

    
4931
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4932

    
4933
            RadWindow CheckPop = new RadWindow();
4934
            //Alert check = new Alert(Msg);
4935

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

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

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

    
4976
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4977
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4978
            if (Item != null)
4979
            {
4980
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4981
            }
4982
            else
4983
            {
4984
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4985
            }
4986

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

    
5019
        }
5020

    
5021
        public void Set_Capture()
5022
        {
5023
            double x = canvasDrawingMouseDownPoint.X;
5024
            double y = canvasDrawingMouseDownPoint.Y;
5025
            double width = dragCaptureBorder.Width;
5026
            double height = dragCaptureBorder.Height;
5027

    
5028
            if (width > 5 || height > 5)
5029
            {
5030
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5031
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5032
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5033
            }
5034
        }
5035
        #endregion
5036

    
5037
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5038
        {
5039
            multi_Undo_Data = new Multi_Undo_data();
5040

    
5041
            multi_Undo_Data.Markup = control;
5042

    
5043
            if ((control as IShapeControl) != null)
5044
            {
5045
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5046
            }
5047
            if ((control as IDashControl) != null)
5048
            {
5049
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5050
            }
5051
            if ((control as IPath) != null)
5052
            {
5053
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5054
            }
5055
            if ((control as UIElement) != null)
5056
            {
5057
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5058
            }
5059

    
5060
            return multi_Undo_Data;
5061
        }
5062

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

    
5082
        /// <summary>
5083
        /// convert inkcontrol to polygoncontrol
5084
        /// </summary>
5085
        public void ConvertInkControlToPolygon()
5086
        {
5087
            if (inkBoard.Strokes.Count > 0)
5088
            {
5089
                inkBoard.Strokes.ToList().ForEach(stroke =>
5090
                {
5091
                    InkToPath ip = new InkToPath();
5092

    
5093
                    List<Point> inkPointSet = new List<Point>();
5094
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5095

    
5096
                    PolygonControl pc = new PolygonControl()
5097
                    {
5098
                        Angle = 0,
5099
                        PointSet = inkPointSet,
5100
                        ControlType = ControlType.Ink
5101
                    };
5102
                    pc.StartPoint = inkPointSet[0];
5103
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5104
                    pc.LineSize = 3;
5105
                    pc.CommentID = Commons.shortGuid();
5106
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5107

    
5108
                    if (pc.PointSet.Count > 0)
5109
                    {
5110
                        CreateCommand.Instance.Execute(pc);
5111
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5112
                    }
5113
                });
5114
                inkBoard.Strokes.Clear();
5115
            }
5116
        }
5117

    
5118
        /// <summary>
5119
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5120
        /// </summary>
5121
        /// <author>ingu</author>
5122
        /// <date>2018.06.05</date>
5123
        /// <param name="getPoint"></param>
5124
        /// <returns></returns>
5125
        private bool IsGetoutpoint(Point getPoint)
5126
        {
5127
            if (getPoint == new Point())
5128
            {
5129
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5130
                currentControl = null;
5131
                return true;
5132
            }
5133

    
5134
            return false;
5135
        }
5136

    
5137
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5138
        {
5139
            e.Effects = DragDropEffects.Copy;
5140
        }
5141

    
5142
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5143
        {
5144
            e.Effects = DragDropEffects.Copy;
5145
        }
5146

    
5147
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5148
        {
5149
            e.Effects = DragDropEffects.None;
5150
        }
5151

    
5152
        /*
5153
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5154
        {
5155
            try
5156
            {
5157
                if (e.Data.GetDataPresent(typeof(string)))
5158
                {
5159
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5160
                    string dragData = e.Data.GetData(typeof(string)) as string;
5161
                    Move_Symbol(sender, dragData);
5162
                }
5163
            }
5164
            catch (Exception ex)
5165
            {
5166
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5167
            }            
5168
        }
5169
        */
5170
    }
5171
}
클립보드 이미지 추가 (최대 크기: 500 MB)