프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 7211e0c2

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

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

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

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

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

    
271
            return false;
272
        }
273

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

    
297
            return false;
298
        }
299

    
300

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

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

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

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

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

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

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

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

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

    
409
        
410

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

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

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

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

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

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

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

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

    
500
        bool ComingNewBieEnd = false;
501

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

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

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

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

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

    
530

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

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

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

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

    
561
            ConvertInkControlToPolygon();
562

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

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

    
569

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

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

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

    
584
            #endregion
585

    
586
            ViewerDataModel.Instance.PageNumber = BalancePoint;
587

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

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

    
606
            ViewerDataModel.Instance.ImageViewPath = null;
607

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

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

    
632

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

    
638

    
639

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

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

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

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

    
695
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
696

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

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

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

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

    
735
        }
736

    
737

    
738
        
739

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

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

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

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

    
800
        #region ZoomIn & ZoomOut
801

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

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

    
814

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

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

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

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

    
850
        }
851

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

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

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

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

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

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

    
904
        #endregion
905

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

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

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

    
918
        }
919

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

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

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

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

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

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

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

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

    
1086

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

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

    
1099

    
1100
               CreateDragDropWindow2(img);
1101
              
1102
    }
1103

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1521
                    e.Handled = true;
1522
                }
1523

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

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

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

    
1573
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1574

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

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

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

    
1588
        private EllipseGeometry hitArea = new EllipseGeometry();
1589

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

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

    
1600
                    SetCursor();
1601

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

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

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

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

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

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

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

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

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

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

    
1690
                zoomAndPanControl.ReleaseMouseCapture();
1691

    
1692

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

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

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

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

    
1718
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1719

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

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

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

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

    
1761
            //GC.Collect();
1762

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

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

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

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

    
1789
        }
1790

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1941
            zoomAndPanControl.RotationAngle = rotate.Angle;
1942

    
1943

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

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

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

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

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

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

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

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

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

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

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

    
2066
            ConvertInkControlToPolygon();
2067

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2217
                        final = new AdornerFinal(control);
2218

    
2219
                        this.Control_Style(control);
2220

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

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

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

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

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

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

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

    
2348
                        Control_Style(control);
2349

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

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

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

    
2409
                                    CreateCommand.Instance.Execute(currentControl);
2410

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

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

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

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

    
2457
                                    CreateCommand.Instance.Execute(currentControl);
2458

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

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

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

    
2492
                                    CreateCommand.Instance.Execute(currentControl);
2493

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

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

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

    
2527
                                    CreateCommand.Instance.Execute(currentControl);
2528

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

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

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

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

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

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

    
2598
                                    CreateCommand.Instance.Execute(currentControl);
2599

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

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

    
2633
                                    CreateCommand.Instance.Execute(currentControl);
2634

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

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

    
2673
                                        CreateCommand.Instance.Execute(currentControl);
2674

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

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

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

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

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

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

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

    
2760
                                    control.ApplyOverViewData();
2761

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

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

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

    
2805
                                    CreateCommand.Instance.Execute(currentControl);
2806

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

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

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

    
2862
                                    CreateCommand.Instance.Execute(currentControl);
2863

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

    
2905
                                    CreateCommand.Instance.Execute(currentControl);
2906

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

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

    
2965
                                            CreateCommand.Instance.Execute(currentControl);
2966

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

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

    
3010
                                    CreateCommand.Instance.Execute(currentControl);
3011

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3270
                                    CreateCommand.Instance.Execute(currentControl);
3271

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4226
                }
4227
            }
4228
        }
4229

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

    
4236
                var uri = CurrentRev.TO_VENDOR;
4237

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

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

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

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

    
4281
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4282

    
4283
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4284
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4285
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4286

    
4287
                if (defaultBitmapImage_Compare.IsDownloading)
4288
                {
4289
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4290
                    {
4291
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4292
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4293
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4294
                    };
4295
                }
4296
                zoomAndPanControl2.ApplyTemplate();
4297
                zoomAndPanControl2.UpdateLayout();
4298
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4299
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4300
            }
4301
        }
4302

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

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

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

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

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

    
4345
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4346

    
4347
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4348
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4349
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4350

    
4351
                        if (defaultBitmapImage_Compare.IsDownloading)
4352
                        {
4353
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4354
                            {
4355
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4356
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4357
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4358
                            };
4359
                        }
4360

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

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

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

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

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

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

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

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

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

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

    
4427
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4428

    
4429
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4430
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4431
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4432

    
4433
                    if (defaultBitmapImage_Compare.IsDownloading)
4434
                    {
4435
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4436
                        {
4437
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4438
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4439
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4440
                        };
4441
                    }
4442

    
4443

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

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

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

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

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

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

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

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

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

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

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

    
4572
                                    System.Drawing.Bitmap image;
4573

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

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

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

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

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

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

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

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

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

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

    
4722
                List<SYMBOL_PUBLIC> symbol_Public;
4723

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

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

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

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

    
4786
        public PngBitmapEncoder symImage(string data)
4787
        {
4788

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

    
4795
            BitmapEncoder encoder = new PngBitmapEncoder();
4796

    
4797

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

    
4800
            DrawingVisual dv = new DrawingVisual();
4801

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

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

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

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

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

    
4831
        }
4832

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

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

    
4853
        #region 캡쳐 기능
4854

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

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

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

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

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

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

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

    
4893
            return pixels;
4894
        }
4895

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

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

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

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

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

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

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

    
4943
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4944

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

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

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

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

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

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

    
5031
        }
5032

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

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

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

    
5053
            multi_Undo_Data.Markup = control;
5054

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

    
5072
            return multi_Undo_Data;
5073
        }
5074

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

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

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

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

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

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

    
5146
            return false;
5147
        }
5148

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

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

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

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