프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 025ebf74

이력 | 보기 | 이력해설 | 다운로드 (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
                App.splashString(ISplashMessage.MAINMENU_1);
390
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
391
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
392
                imageViewer_Compare = new Image();
393
                ViewerDataModel.Instance.Capture_Opacity = 0;
394
                da.From = 0.8;
395
                da.To = 0;
396
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
397
                da.AutoReverse = true;
398
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
399

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

    
410
        
411

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

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

    
427
            ////GC.Collect();
428
        }
429
        
430
        /// <summary>
431
        /// update my markuplist
432
        ///  - update existing markup data if already exist
433
        ///  - add new markup data if control is new
434
        /// </summary>
435
        public void UpdateMyMarkupList()
436
        {
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
            
554
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
555
            {            
556
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
557
            }
558
            
559
            ViewerDataModel.Instance.UndoDataList.Clear();
560

    
561
            ConvertInkControlToPolygon();
562

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

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

    
569

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

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

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

    
584
            #endregion
585

    
586
            ViewerDataModel.Instance.PageNumber = BalancePoint;
587

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

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

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

    
627
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
628
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
629

    
630

    
631
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
632
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
633
            inkBoard.Width = zoomAndPanCanvas.Width;
634
            inkBoard.Height = zoomAndPanCanvas.Height;
635

    
636

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

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

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

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

    
692
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
693

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

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

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

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

    
732
        }
733

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

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

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

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

    
794
        #region ZoomIn & ZoomOut
795

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

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

    
808

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

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

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

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

    
844
        }
845

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

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

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

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

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

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

    
898
        #endregion
899

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

    
905
                ControlList.Clear();
906
                listBox.Items.Clear();
907
                selected_item.Clear();
908

    
909
                (item as IMarkupCommonData).IsSelected = false;
910
            }
911

    
912
        }
913

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

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

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

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

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

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

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

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

    
1080

    
1081
               if (this._dragdropWindow != null)
1082
               {
1083
                   this._dragdropWindow.Close();
1084
                   this._dragdropWindow = null;
1085
               }
1086

    
1087
               symbol_id = id;
1088
               symbol_group_id = group_id;
1089
               symbol_SelectedIndex = SelectedIndex;
1090
               symbol_Data = Data_;
1091
               symbol_img = img;
1092

    
1093

    
1094
               CreateDragDropWindow2(img);
1095
              
1096
    }
1097

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

    
1118
            Win32Point w32Mouse = new Win32Point();
1119
            GetCursorPos(ref w32Mouse);
1120

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

    
1133
                Point currentPos = e.GetPosition(rect);
1134

    
1135
                floatingTip.HorizontalOffset = currentPos.X + 20;
1136
                floatingTip.VerticalOffset = currentPos.Y;
1137
            }
1138

    
1139
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1140
            
1141
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1142
            {
1143
                SetCursor();
1144
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1145
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1146

    
1147
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1148
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1149
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1150

    
1151
                if (Sync.IsChecked)
1152
                {
1153
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1154
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1155
                }
1156
            }
1157

    
1158
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1159
            {
1160
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1161
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1162
                SetCursor();
1163

    
1164
                if (currentControl != null)
1165
                {
1166
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1167
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1168
                    //강인구 추가
1169
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1170

    
1171
                    if ((currentControl as IPath) != null)
1172
                    {
1173
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1174
                    }
1175
                    if ((currentControl as LineControl) != null)
1176
                    {
1177
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1178
                    }
1179

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1509
                    if (dragDistance > DragThreshold)
1510
                    {
1511
                        isDraggingSelectionRect = true;
1512
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1513
                    }
1514

    
1515
                    e.Handled = true;
1516
                }
1517

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

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

    
1559
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1560
        {
1561
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1562
            {
1563
                SetCursor();
1564
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1565
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1566

    
1567
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1568

    
1569
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1570
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1571

    
1572
                if (Sync.IsChecked)
1573
                {
1574
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1575
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1576
                }
1577
            }
1578
        }
1579

    
1580
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1581

    
1582
        private EllipseGeometry hitArea = new EllipseGeometry();
1583

    
1584
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1585
        {
1586
            IsDrawing = false;
1587

    
1588
            if (mouseHandlingMode != MouseHandlingMode.None)
1589
            {
1590
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1591
                {
1592
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1593

    
1594
                    SetCursor();
1595

    
1596
                    switch (controlType)
1597
                    {
1598
                        case ControlType.None:
1599
                            break;
1600
                        case ControlType.Rectangle:
1601
                            {
1602

    
1603
                            }
1604
                            break;
1605
                        case ControlType.PenControl:
1606
                            {
1607

    
1608
                            }
1609
                            break;
1610
                        default:
1611
                            break;
1612
                    }
1613
                }
1614
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1615
                {
1616
                    if (isLeftMouseButtonDownOnWindow)
1617
                    {
1618
                        bool wasDragSelectionApplied = false;
1619

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

    
1639
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1640
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1641
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1642
                            }
1643
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1644
                            {
1645
                                ApplyDragSelectionRect();
1646
                            }
1647
                            else
1648
                            {
1649
                                double x = Canvas.GetLeft(dragZoomBorder);
1650
                                double y = Canvas.GetTop(dragZoomBorder);
1651
                                double width = dragZoomBorder.Width;
1652
                                double height = dragZoomBorder.Height;
1653
                                Rect dragRect = new Rect(x, y, width, height);
1654

    
1655
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1656

    
1657
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1658
                            }
1659

    
1660
                            isDraggingSelectionRect = false;
1661
                            e.Handled = true;
1662
                            wasDragSelectionApplied = true;
1663
                        }
1664

    
1665
                        if (isLeftMouseButtonDownOnWindow)
1666
                        {
1667
                            isLeftMouseButtonDownOnWindow = false;
1668
                            this.ReleaseMouseCapture();
1669
                            e.Handled = true;
1670
                        }
1671

    
1672
                        if (!wasDragSelectionApplied)
1673
                        {
1674
                            init();
1675
                        }
1676
                    }
1677
                }
1678
                else if (e.RightButton == MouseButtonState.Pressed)
1679
                {
1680
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1681
                    SetCursor();
1682
                }
1683

    
1684
                zoomAndPanControl.ReleaseMouseCapture();
1685

    
1686

    
1687
                e.Handled = true;
1688
            }
1689
            else
1690
            {
1691
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1692
                SetCursor();
1693
            }
1694

    
1695
            ///mouseButtonDown = MouseButton.Left;
1696
            //controlType = ControlType.SingleLine;
1697
        }
1698

    
1699
        public void Set_Symbol_Capture(Point endPoint)
1700
        {       
1701
            double x = canvasDrawingMouseDownPoint.X;
1702
            double y = canvasDrawingMouseDownPoint.Y;
1703
            if(x > endPoint.X)
1704
            {
1705
                x = endPoint.X;
1706
                y = endPoint.Y;
1707
            }
1708

    
1709
            double width = dragCaptureBorder.Width;
1710
            double height = dragCaptureBorder.Height;
1711

    
1712
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1713

    
1714
            if (x < 0)
1715
            {
1716
                width += x;
1717
                x = 0;
1718
            }
1719
            if (y < 0)
1720
            {
1721
                height += y;
1722
                y = 0;
1723

    
1724
                width = (int)canvasImage.PixelWidth - x;
1725
            }
1726
            if (x + width > canvasImage.PixelWidth)
1727
            {
1728
                width = (int)canvasImage.PixelWidth - x;
1729
            }
1730
            if (y + height > canvasImage.PixelHeight)
1731
            {
1732
                height = (int)canvasImage.PixelHeight - y;
1733
            }
1734
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1735

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

    
1748
            var defaultBitmapImage = new BitmapImage();
1749
            defaultBitmapImage.BeginInit();
1750
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1751
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1752
            defaultBitmapImage.UriSource = new Uri(uri);
1753
            defaultBitmapImage.EndInit();
1754

    
1755
            //GC.Collect();
1756

    
1757
            if (defaultBitmapImage.IsDownloading)
1758
            {
1759
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1760
                {
1761
                    defaultBitmapImage.Freeze();
1762
                    //GC.Collect();
1763
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1764
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1765
                };
1766
            }
1767
        }
1768

    
1769
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1770
        {
1771
            ///mouseButtonDown = MouseButton.Left;
1772
        }
1773

    
1774
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1775
        {
1776
            ///mouseButtonDown = MouseButton.Left;
1777
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1778
        }
1779

    
1780
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1781
        {
1782

    
1783
        }
1784

    
1785
        /// <summary>
1786
        /// select items by dragging
1787
        /// </summary>
1788
        private void ApplyDragSelectionRect()
1789
        {
1790
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1791

    
1792
            double x = Canvas.GetLeft(dragSelectionBorder);
1793
            double y = Canvas.GetTop(dragSelectionBorder);
1794
            double width = dragSelectionBorder.Width;
1795
            double height = dragSelectionBorder.Height;
1796
            Boolean Flag = false;
1797
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1798
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1799

    
1800
            Rect dragRect = new Rect(x, y, width, height);
1801
            ///dragRect.Inflate(width / 10, height / 10);
1802

    
1803
            foreach (var item in Items)
1804
            {
1805
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1806

    
1807
                if (Flag)
1808
                {
1809
                    adornerSet.Add(item);
1810
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1811
                    Control_Style(item);
1812
                }
1813
            }
1814
            if (adornerSet.Count > 0)
1815
            {
1816
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1817
                SelectLayer.Children.Add(final);
1818
            }
1819
        }
1820

    
1821
        private void InitDragSelectionRect(Point pt1, Point pt2)
1822
        {
1823
            //캡쳐 중
1824
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1825
            {
1826
                dragCaptureBorder.Visibility = Visibility.Visible;
1827
            }
1828
            //선택 중
1829
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1830
            {
1831

    
1832
                dragSelectionBorder.Visibility = Visibility.Visible;
1833
            }
1834
            else
1835
            {
1836
                dragZoomBorder.Visibility = Visibility.Visible;
1837
            }
1838
            UpdateDragSelectionRect(pt1, pt2);
1839
        }
1840

    
1841
        /// <summary>
1842
        /// Update the position and size of the rectangle used for drag selection.
1843
        /// </summary>
1844
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1845
        {
1846
            double x, y, width, height;
1847

    
1848
            //
1849
            // Determine x,y,width and height of the rect inverting the points if necessary.
1850
            // 
1851

    
1852
            if (pt2.X < pt1.X)
1853
            {
1854
                x = pt2.X;
1855
                width = pt1.X - pt2.X;
1856
            }
1857
            else
1858
            {
1859
                x = pt1.X;
1860
                width = pt2.X - pt1.X;
1861
            }
1862

    
1863
            if (pt2.Y < pt1.Y)
1864
            {
1865
                y = pt2.Y;
1866
                height = pt1.Y - pt2.Y;
1867
            }
1868
            else
1869
            {
1870
                y = pt1.Y;
1871
                height = pt2.Y - pt1.Y;
1872
            }
1873

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

    
1902
        private void drawingPannelRotate(double angle)
1903
        {
1904
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1905
            rotate.Angle = angle;
1906
            var rotationNum = Math.Abs((rotate.Angle / 90));
1907

    
1908
            if (angle == 90 || angle == 270)
1909
            {
1910
                double emptySize = zoomAndPanCanvas.Width;
1911
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1912
                zoomAndPanCanvas.Height = emptySize;
1913
            }
1914
            if (angle == 0)
1915
            {
1916
                translate.X = 0;
1917
                translate.Y = 0;
1918
            }
1919
            else if (angle == 90)
1920
            {
1921
                translate.X = zoomAndPanCanvas.Width;
1922
                translate.Y = 0;
1923
            }
1924
            else if (angle == 180)
1925
            {
1926
                translate.X = zoomAndPanCanvas.Width;
1927
                translate.Y = zoomAndPanCanvas.Height;
1928
            }
1929
            else
1930
            {
1931
                translate.X = 0;
1932
                translate.Y = zoomAndPanCanvas.Height;
1933
            }
1934

    
1935
            zoomAndPanControl.RotationAngle = rotate.Angle;
1936

    
1937

    
1938
            if (!testPanel2.IsHidden)
1939
            {
1940
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1941
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1942
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1943
            }
1944

    
1945
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1946
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1947
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1948
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1949
            ViewerDataModel.Instance.Angle = rotate.Angle;
1950
        }
1951

    
1952
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1953
        {
1954
            string Data_ = "";
1955

    
1956
            try
1957
            {
1958
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1959
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1960
                if (Data_ != null || Data_ != "")
1961
                {
1962
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1963
                }
1964
                else
1965
                {
1966
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1967
                }
1968

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

    
1995
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1996
                    {
1997
                        PointSet = new List<Point>(),
1998
                        FilePath = Data_,
1999
                        ImageData = img.Source,
2000
                        StartPoint = canvasZoomPanningMouseDownPoint,
2001
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2002
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2003
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2004
                        canvasZoomPanningMouseDownPoint.Y),
2005
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2006
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2007
                    };
2008

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

    
2029
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2030
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2031
                    UndoData.Markup_List.Add(multi_Undo_Data);
2032
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2033

    
2034
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2035
                    currentControl.CommentID = Commons.shortGuid();
2036
                    currentControl.SymbolID = id;
2037
                    currentControl.GroupID = group_id;
2038
                    currentControl.ApplyTemplate();
2039
                    currentControl.SetImage();
2040

    
2041
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2042
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2043
                    SelectLayer.Children.Add(final);
2044
                }
2045
            }
2046
            catch (Exception ex)
2047
            {
2048
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2049
            }
2050
        }
2051

    
2052
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2053
        {            
2054
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2055
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2056
            {
2057
                set_option.Value = double.Parse(set_option.ContentText);
2058
            }
2059

    
2060
            ConvertInkControlToPolygon();
2061

    
2062
            ///TODO:
2063
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2064
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2065

    
2066
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2067
            {
2068
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2069
            }
2070
            /// up to here
2071

    
2072
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2073
            {
2074
                if (arrow_text as ArrowTextControl != null)
2075
                {
2076
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2077
                }
2078
            }
2079

    
2080
            //if (currentControl != null)
2081
            {
2082
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2083
                if (text_item_ != null)
2084
                {
2085
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2086
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2087
                    (text_item_ as TextControl).EnableEditing = false;
2088
                    currentControl = null;
2089
                }
2090

    
2091
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2092
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2093
                {
2094
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2095
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2096
                    currentControl = null;
2097
                }
2098
            }
2099

    
2100
            double Ang = 0;                                          
2101
            if (rotate.Angle != 0)
2102
            {
2103
                Ang = 360 - rotate.Angle;
2104
            }
2105

    
2106
            if (e.OriginalSource is System.Windows.Controls.Image)
2107
            {
2108
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2109
            }
2110
            /*
2111
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2112
            {                
2113
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2114
                if(symbol_id != null)
2115
                {
2116
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2117
                }                
2118
            }
2119

    
2120
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2121
            {
2122
                if (this._dragdropWindow != null)
2123
                {
2124
                    this._dragdropWindow.Close();
2125
                    this._dragdropWindow = null;
2126
                    symbol_id = null;
2127
                }
2128
            }
2129
            */
2130

    
2131
            if (e.LeftButton == MouseButtonState.Pressed)
2132
            {
2133
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2134
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2135

    
2136
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2137
                SetCursor();
2138

    
2139
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2140
            }
2141

    
2142
            if (e.MiddleButton == MouseButtonState.Pressed)
2143
            {
2144
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2145
                cursor = Cursors.SizeAll;
2146
                SetCursor();
2147
            }
2148
            if (e.RightButton == MouseButtonState.Pressed)
2149
            {
2150
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2151
                cursor = Cursors.SizeAll;
2152
                SetCursor();
2153
            }
2154
            else if (e.XButton1 == MouseButtonState.Pressed)
2155
            {
2156
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2157
                {
2158
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2159
                }
2160

    
2161
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2162

    
2163
            }
2164
            else if (e.XButton2 == MouseButtonState.Pressed)
2165
            {
2166
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2167
                {
2168
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2169
                }
2170
            }
2171

    
2172
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2173
            {
2174
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2175
                {
2176
                    if (SelectLayer.Children.Count == 0)
2177
                    {
2178
                        isLeftMouseButtonDownOnWindow = true;
2179
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2180
                    }
2181

    
2182
                    if (controlType == ControlType.None)
2183
                    {
2184
                        isLeftMouseButtonDownOnWindow = true;
2185
                    }
2186
                }
2187

    
2188
                /// 캡쳐 모드 설정
2189
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2190
                {
2191
                    dragCaptureBorder.Visibility = Visibility.Visible;
2192
                    isLeftMouseButtonDownOnWindow = true;
2193
                }
2194

    
2195
                /// 줌 모드 설정
2196
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2197
                {
2198
                    isLeftMouseButtonDownOnWindow = true;
2199
                }
2200

    
2201
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2202
                if (control != null)
2203
                {
2204
                    AdornerFinal final = null;
2205

    
2206
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2207
                    {
2208
                        /// 기존 selection 해제
2209
                        SelectionSet.Instance.UnSelect(this);
2210

    
2211
                        final = new AdornerFinal(control);
2212

    
2213
                        this.Control_Style(control);
2214

    
2215
                        if ((control as IPath) != null)
2216
                        {
2217
                            if ((control as IPath).LineSize != 0)
2218
                            {
2219
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2220
                            }
2221
                        }
2222
                        if ((control as IShapeControl) != null)
2223
                        {
2224
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2225
                            {
2226
                                ViewerDataModel.Instance.checkHatchShape = true;
2227
                            }
2228
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2229
                            {
2230
                                ViewerDataModel.Instance.checkFillShape = true;
2231
                            }
2232
                            else
2233
                            {
2234
                                ViewerDataModel.Instance.checkHatchShape = false;
2235
                                ViewerDataModel.Instance.checkFillShape = false;
2236
                            }
2237
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2238
                        }
2239

    
2240
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2241

    
2242
                        if ((control as TextControl) != null)
2243
                        {
2244
                            if(!((control as TextControl).EnableEditing)) {
2245
                                (control as TextControl).EnableEditing = true;
2246
                            }
2247

    
2248
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2249
                            {
2250
                                ViewerDataModel.Instance.checkTextStyle = true;
2251
                            }
2252
                            else
2253
                            {
2254
                                ViewerDataModel.Instance.checkTextStyle = false;
2255
                            }
2256

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

    
2284
                        }
2285
                        else if ((control as ArrowTextControl) != null)
2286
                        {
2287
                            if (!((control as ArrowTextControl).EnableEditing))
2288
                            {
2289
                                (control as ArrowTextControl).EnableEditing = true;
2290
                            }
2291
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2292
                            {
2293
                                ViewerDataModel.Instance.checkTextStyle = true;
2294
                            }
2295
                            else
2296
                            {
2297
                                ViewerDataModel.Instance.checkTextStyle = false;
2298
                            }
2299

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

    
2342
                        Control_Style(control);
2343

    
2344
                        final = new AdornerFinal(comment);
2345
                    }
2346

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

    
2390
                switch (controlType)
2391
                {
2392
                    case ControlType.Coordinate:
2393
                        {
2394
                            if (e.LeftButton == MouseButtonState.Pressed)
2395
                            {
2396
                                if (currentControl is CoordinateControl)
2397
                                {
2398
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2399
                                    {
2400
                                        return;
2401
                                    }
2402

    
2403
                                    CreateCommand.Instance.Execute(currentControl);
2404

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

    
2428
                                        currentControl.CommentID = Commons.shortGuid();
2429
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2430
                                        currentControl.IsNew = true;
2431

    
2432
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2433

    
2434
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2435
                                    }
2436
                                }
2437
                            }
2438
                        }
2439
                        break;
2440
                    case ControlType.InsideWhite:
2441
                        {
2442
                            if (e.LeftButton == MouseButtonState.Pressed)
2443
                            {
2444
                                if (currentControl is InsideWhiteControl)
2445
                                {
2446
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2447
                                    {
2448
                                        return;
2449
                                    }
2450

    
2451
                                    CreateCommand.Instance.Execute(currentControl);
2452

    
2453
                                    currentControl = null;
2454
                                    this.cursor = Cursors.Arrow;
2455
                                }
2456
                                else
2457
                                {
2458
                                    currentControl = new InsideWhiteControl
2459
                                    {
2460
                                        Background = new SolidColorBrush(Colors.Black),
2461
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2462
                                        ControlType = ControlType.InsideWhite
2463
                                    };
2464

    
2465
                                    currentControl.CommentID = Commons.shortGuid();
2466
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2467
                                    currentControl.IsNew = true;
2468
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2469

    
2470
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2471
                                }
2472
                            }
2473
                        }
2474
                        break;
2475
                    case ControlType.OverlapWhite:
2476
                        {
2477
                            if (e.LeftButton == MouseButtonState.Pressed)
2478
                            {
2479
                                if (currentControl is OverlapWhiteControl)
2480
                                {
2481
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2482
                                    {
2483
                                        return;
2484
                                    }
2485

    
2486
                                    CreateCommand.Instance.Execute(currentControl);
2487

    
2488
                                    currentControl = null;
2489
                                    this.cursor = Cursors.Arrow;
2490
                                }
2491
                                else
2492
                                {
2493
                                    currentControl = new OverlapWhiteControl
2494
                                    {
2495
                                        Background = new SolidColorBrush(Colors.Black),
2496
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2497
                                        ControlType = ControlType.OverlapWhite
2498
                                    };
2499

    
2500
                                    currentControl.CommentID = Commons.shortGuid();
2501
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2502
                                    currentControl.IsNew = true;
2503
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2504

    
2505
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2506
                                }
2507
                            }
2508
                        }
2509
                        break;
2510
                    case ControlType.ClipWhite:
2511
                        {
2512
                            if (e.LeftButton == MouseButtonState.Pressed)
2513
                            {
2514
                                if (currentControl is ClipWhiteControl)
2515
                                {
2516
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2517
                                    {
2518
                                        return;
2519
                                    }
2520

    
2521
                                    CreateCommand.Instance.Execute(currentControl);
2522

    
2523
                                    currentControl = null;
2524
                                    this.cursor = Cursors.Arrow;
2525
                                }
2526
                                else
2527
                                {
2528
                                    currentControl = new ClipWhiteControl
2529
                                    {
2530
                                        Background = new SolidColorBrush(Colors.Black),
2531
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2532
                                        ControlType = ControlType.ClipWhite
2533
                                    };
2534

    
2535
                                    currentControl.CommentID = Commons.shortGuid();
2536
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2537
                                    currentControl.IsNew = true;
2538
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2539

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

    
2557
                                    CreateCommand.Instance.Execute(currentControl);
2558
                                    currentControl = null;
2559
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2560
                                }
2561
                                else
2562
                                {
2563
                                    currentControl = new RectangleControl
2564
                                    {
2565
                                        Background = new SolidColorBrush(Colors.Black),
2566
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2567
                                        ControlType = ControlType.Rectangle
2568
                                    };
2569

    
2570
                                    currentControl.CommentID = Commons.shortGuid();
2571
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2572
                                    currentControl.IsNew = true;
2573
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2574

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

    
2592
                                    CreateCommand.Instance.Execute(currentControl);
2593

    
2594
                                    currentControl = null;
2595
                                
2596
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2597
                                }
2598
                                else
2599
                                {
2600
                                    currentControl = new RectCloudControl
2601
                                    {
2602
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2603
                                        ControlType = ControlType.RectCloud,
2604
                                        Background = new SolidColorBrush(Colors.Black)
2605
                                    };
2606

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

    
2627
                                    CreateCommand.Instance.Execute(currentControl);
2628

    
2629
                                    currentControl = null;
2630
                                }
2631
                                else
2632
                                {
2633
                                    currentControl = new CircleControl
2634
                                    {
2635
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2636
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2637
                                        Background = new SolidColorBrush(Colors.Black)
2638
                                    };
2639

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

    
2667
                                        CreateCommand.Instance.Execute(currentControl);
2668

    
2669
                                        currentControl = null;
2670
                                    }
2671
                                }
2672
                                else
2673
                                {
2674
                                    currentControl = new TriControl
2675
                                    {
2676
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2677
                                        Background = new SolidColorBrush(Colors.Black),
2678
                                    };
2679

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

    
2704
                                    CreateCommand.Instance.Execute(currentControl);
2705
                                    currentControl = null;
2706
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2707
                                }
2708
                                else
2709
                                {
2710
                                    currentControl = new LineControl
2711
                                    {
2712
                                        ControlType = this.controlType,
2713
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2714
                                        Background = new SolidColorBrush(Colors.Black)
2715
                                    };
2716

    
2717
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2718
                                    currentControl.CommentID = Commons.shortGuid();
2719
                                    currentControl.IsNew = true;
2720
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2721
                                    this.MainAngle.Visibility = Visibility.Visible;
2722
                                }
2723
                            }
2724
                        }
2725
                        break;
2726
                    case ControlType.PolygonControl:
2727
                        {
2728
                            if (currentControl is PolygonControl)
2729
                            {
2730
                                var control = currentControl as PolygonControl;
2731

    
2732
                                if (e.RightButton == MouseButtonState.Pressed)
2733
                                {
2734
                                    control.IsCompleted = true;
2735
                                }
2736

    
2737
                                if (!control.IsCompleted)
2738
                                {
2739
                                    control.PointSet.Add(control.EndPoint);
2740
                                }
2741
                                else
2742
                                {
2743
                                    //20180906 LJY TEST IsRotationDrawingEnable
2744
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2745
                                    {
2746
                                        return;
2747
                                    }
2748

    
2749
                                    var firstPoint = control.PointSet.First();
2750
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2751
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2752
                                    control.PointSet.Add(firstPoint);
2753

    
2754
                                    control.ApplyOverViewData();
2755

    
2756
                                    CreateCommand.Instance.Execute(currentControl);
2757
                                    control.UpdateControl();
2758
                                    currentControl = null;
2759
                                }
2760
                            }
2761
                            else
2762
                            {
2763
                                if (e.LeftButton == MouseButtonState.Pressed)
2764
                                {
2765
                                    currentControl = new PolygonControl
2766
                                    {
2767
                                        PointSet = new List<Point>(),
2768
                                    };
2769

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

    
2791
                                if (e.RightButton == MouseButtonState.Pressed)
2792
                                {
2793
                                    //20180906 LJY TEST IsRotationDrawingEnable
2794
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2795
                                    {
2796
                                        return;
2797
                                    }
2798

    
2799
                                    CreateCommand.Instance.Execute(currentControl);
2800

    
2801
                                    currentControl = null;
2802
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2803
                                    return;
2804
                                }
2805

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

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

    
2856
                                    CreateCommand.Instance.Execute(currentControl);
2857

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

    
2899
                                    CreateCommand.Instance.Execute(currentControl);
2900

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

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

    
2959
                                            CreateCommand.Instance.Execute(currentControl);
2960

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

    
2992
                                if (!control.IsCompleted)
2993
                                {
2994
                                    control.PointSet.Add(control.EndPoint);
2995
                                }
2996
                                else
2997
                                {
2998
                                    //20180906 LJY TEST IsRotationDrawingEnable
2999
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3000
                                    {
3001
                                        return;
3002
                                    }
3003

    
3004
                                    CreateCommand.Instance.Execute(currentControl);
3005

    
3006
                                    control.isTransOn = true;
3007
                                    var firstPoint = control.PointSet.First();
3008

    
3009
                                    control.PointSet.Add(firstPoint);
3010
                                    control.DrawingCloud();
3011
                                    control.ApplyOverViewData();
3012

    
3013
                                    currentControl = null;
3014
                                }
3015
                            }
3016
                            else
3017
                            {
3018
                                if (e.LeftButton == MouseButtonState.Pressed)
3019
                                {
3020
                                    currentControl = new CloudControl
3021
                                    {
3022
                                        PointSet = new List<Point>(),
3023
                                        PointC = new StylusPointSet()
3024
                                    };
3025

    
3026
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3027
                                    //{
3028
                                        var polygonControl = (currentControl as CloudControl);
3029
                                        currentControl.CommentID = Commons.shortGuid();
3030
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3031
                                        currentControl.IsNew = true;
3032
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3033

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

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

    
3084
                                            currentControl = new ImgControl
3085
                                            {
3086
                                                    Background = new SolidColorBrush(Colors.Black),
3087
                                                    PointSet = new List<Point>(),
3088
                                                    FilePath = filename,
3089
                                                    ImageData = img.Source,
3090
                                                    StartPoint = canvasDrawingMouseDownPoint,
3091
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3092
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3093
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3094
                                                    ControlType = ControlType.ImgControl
3095
                                                };
3096

    
3097
                                        
3098
                                                currentControl.CommentID = Commons.shortGuid();                                            
3099
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3100
                                                currentControl.IsNew = true;
3101
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3102

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

    
3125
                                        CreateCommand.Instance.Execute(currentControl);
3126
                                        currentControl = null;
3127

    
3128
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3129
                                        {
3130
                                            controlType = ControlType.None;
3131
                                            IsSwingMode = false;
3132
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3133
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3134
                                            mouseHandlingMode = MouseHandlingMode.None;
3135
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3136
                                            txtBatch.Visibility = Visibility.Collapsed;
3137

    
3138
                                        }
3139
                                    }
3140
                                    else
3141
                                    {
3142
                                        currentControl = new DateControl
3143
                                        {
3144
                                            StartPoint = canvasDrawingMouseDownPoint,
3145
                                            Background = new SolidColorBrush(Colors.Black)
3146
                                        };
3147
                                        currentControl.CommentID = Commons.shortGuid();
3148
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3149
                                        currentControl.IsNew = true;
3150
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3151

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

    
3176
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3177
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3178
                                    
3179
                                    (currentControl as TextControl).ControlType_No = 0;
3180
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3181
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3182
                                    (currentControl as TextControl).ApplyTemplate();
3183
                                    (currentControl as TextControl).Base_TextBox.Focus();
3184

    
3185
                                    CreateCommand.Instance.Execute(currentControl);
3186
                                }
3187
                            }
3188
                        }
3189
                        break;
3190
                    case ControlType.TextBorder:
3191
                        {
3192
                            if (e.LeftButton == MouseButtonState.Pressed)
3193
                            {
3194
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3195
                                {
3196
                                    currentControl = new TextControl
3197
                                    {
3198
                                        ControlType = controlType
3199
                                    };
3200

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

    
3231
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3232
                                    currentControl.CommentID = Commons.shortGuid();
3233
                                    currentControl.IsNew = true;
3234
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3235
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3236

    
3237
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3238
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3239
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3240

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

    
3264
                                    CreateCommand.Instance.Execute(currentControl);
3265

    
3266
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3267
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3268
                                    (currentControl as ArrowTextControl).IsNew = false;
3269
                                    currentControl = null;
3270
                                }
3271
                                else
3272
                                {
3273
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3274
                                    //{
3275
                                        currentControl = new ArrowTextControl();
3276
                                        currentControl.CommentID = Commons.shortGuid();
3277
                                        currentControl.IsNew = true;
3278
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3279
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3280

    
3281
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3282
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3283
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3284
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3285
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3286

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

    
3290
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3291
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3292
                                        this.MainAngle.Visibility = Visibility.Visible;
3293

    
3294
                                    
3295
                                    //}
3296
                                }
3297
                            }
3298
                        }
3299
                        break;
3300
                    case ControlType.ArrowTransTextControl:
3301
                        {
3302
                            if (e.LeftButton == MouseButtonState.Pressed)
3303
                            {
3304
                                if (currentControl is ArrowTextControl)
3305
                                {
3306
                                    //20180906 LJY TEST IsRotationDrawingEnable
3307
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3308
                                    {
3309
                                        return;
3310
                                    }
3311

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

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

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

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

    
3378
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3379

    
3380
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3381

    
3382
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3383
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3384
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3385

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

    
3419
                                    currentControl = new ArrowTextControl()
3420
                                    {
3421
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3422
                                        ControlType = ControlType.ArrowTransTextBorderControl
3423

    
3424
                                    };
3425
                                        currentControl.CommentID = Commons.shortGuid();
3426
                                        currentControl.IsNew = true;
3427
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3428
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3429

    
3430
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3431

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

    
3442
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3443
                                        this.MainAngle.Visibility = Visibility.Visible;
3444
                                    
3445
                                    //20180911 LJY
3446
                                        (currentControl as ArrowTextControl).isTrans = true;
3447
                                    
3448

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

    
3484
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3485
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3486
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3487
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3488
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3489

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

    
3527
                                        };
3528
                                        currentControl.CommentID = Commons.shortGuid();
3529
                                        currentControl.IsNew = true; 
3530
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3531
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3532
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3533

    
3534
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3535
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3536
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3537
                                        (currentControl as ArrowTextControl).isFixed = true;
3538
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3539

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

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

    
3563
                                    if (_sign == null)
3564
                                    {
3565
                                        txtBatch.Visibility = Visibility.Collapsed;
3566
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3567
                                        controlType = ControlType.None;
3568

    
3569
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3570
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3571
                                        return;
3572
                                    }
3573

    
3574
                                    if (currentControl is SignControl)
3575
                                    {
3576
                                        //20180906 LJY TEST IsRotationDrawingEnable
3577
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3578
                                        {
3579
                                            return;
3580
                                        }
3581

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

    
3602
                                        currentControl.CommentID = Commons.shortGuid();
3603
                                        currentControl.IsNew = true;
3604
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3605
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3606

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

    
3628
                                        CreateCommand.Instance.Execute(currentControl);
3629
                                        (currentControl as RectangleControl).ApplyOverViewData();
3630
                                        currentControl = null;
3631
                                    
3632
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3633

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

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

    
3686
                                    currentControl.IsNew = true;
3687
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3688
                                    currentControl.CommentID = Commons.shortGuid();
3689
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3690

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

    
3712
                                        CreateCommand.Instance.Execute(currentControl);
3713
                                        currentControl = null;
3714
                                   
3715

    
3716
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3717
                                    }
3718
                                    else
3719
                                    {
3720
                                        currentControl = new SymControlN
3721
                                        {
3722
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3723
                                            Background = new SolidColorBrush(Colors.Black),
3724
                                            STAMP = App.SystemInfo.STAMP,
3725
                                            ControlType = ControlType.Stamp
3726
                                        };
3727

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

    
3776
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3777
                            if (over != null)
3778
                            {
3779
                                mouseOff = true;
3780
                            }
3781
                        }
3782
                    }
3783

    
3784
                    if (!mouseOff)
3785
                    {
3786
                        SelectionSet.Instance.UnSelect(this);
3787
                    }
3788
                }
3789
                zoomAndPanControl.CaptureMouse();
3790
                e.Handled = true;
3791
            }
3792
        }
3793

    
3794
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3795
        {
3796
            ///mouseButtonDown = e.ChangedButton;
3797
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3798
        }
3799

    
3800
        private void RemoveLineStroke(Point P)
3801
        {
3802
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3803
            if (control != null)
3804
            {
3805
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3806
            }
3807
        }
3808

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

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

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

    
3832
            stroke.DrawingAttributes.Color = Colors.Red;
3833
            stroke.DrawingAttributes.Width = 4;
3834
            stroke.DrawingAttributes.Height = 4;
3835

    
3836
            inkBoard.Strokes.Add(stroke);
3837
        }
3838

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4165
                        if (userData.COMPANY != "EXT")
4166
                        {
4167
                            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);
4168
                        }
4169
                        else
4170
                        {
4171
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4172
                        }
4173

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

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

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

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

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

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

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

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

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

    
4220
                }
4221
            }
4222
        }
4223

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

    
4230
                var uri = CurrentRev.TO_VENDOR;
4231

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

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

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

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

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

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

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

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

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

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

    
4327
                        string uri = "";
4328
                        if (userData.COMPANY != "EXT")
4329
                        {
4330
                            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);
4331
                        }
4332
                        else
4333
                        {
4334
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4335
                        }
4336

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

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

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

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

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

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

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

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

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

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

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

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

    
4409
                    string uri = "";
4410
                    if (userData.COMPANY != "EXT")
4411
                    {
4412
                        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);
4413
                    }
4414
                    else
4415
                    {
4416
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4417
                    }
4418

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

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

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

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

    
4437

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

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

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

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

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

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

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

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

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

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

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

    
4566
                                    System.Drawing.Bitmap image;
4567

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

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

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

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

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

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

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

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

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

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

    
4716
                List<SYMBOL_PUBLIC> symbol_Public;
4717

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

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

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

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

    
4780
        public PngBitmapEncoder symImage(string data)
4781
        {
4782

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

    
4789
            BitmapEncoder encoder = new PngBitmapEncoder();
4790

    
4791

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

    
4794
            DrawingVisual dv = new DrawingVisual();
4795

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

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

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

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

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

    
4825
        }
4826

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

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

    
4847
        #region 캡쳐 기능
4848

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

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

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

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

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

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

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

    
4887
            return pixels;
4888
        }
4889

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

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

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

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

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

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

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

    
4937
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4938

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

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

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

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

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

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

    
5025
        }
5026

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

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

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

    
5047
            multi_Undo_Data.Markup = control;
5048

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

    
5066
            return multi_Undo_Data;
5067
        }
5068

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

    
5088
        /// <summary>
5089
        /// convert inkcontrol to polygoncontrol
5090
        /// </summary>
5091
        public void ConvertInkControlToPolygon()
5092
        {
5093
            if (inkBoard.Strokes.Count > 0)
5094
            {
5095
                inkBoard.Strokes.ToList().ForEach(stroke =>
5096
                {
5097
                    InkToPath ip = new InkToPath();
5098

    
5099
                    List<Point> inkPointSet = new List<Point>();
5100
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5101

    
5102
                    PolygonControl pc = new PolygonControl()
5103
                    {
5104
                        Angle = 0,
5105
                        PointSet = inkPointSet,
5106
                        ControlType = ControlType.Ink
5107
                    };
5108
                    pc.StartPoint = inkPointSet[0];
5109
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5110
                    pc.LineSize = 3;
5111
                    pc.CommentID = Commons.shortGuid();
5112
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5113

    
5114
                    if (pc.PointSet.Count > 0)
5115
                    {
5116
                        CreateCommand.Instance.Execute(pc);
5117
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5118
                    }
5119
                });
5120
                inkBoard.Strokes.Clear();
5121
            }
5122
        }
5123

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

    
5140
            return false;
5141
        }
5142

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

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

    
5153
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5154
        {
5155
            e.Effects = DragDropEffects.None;
5156
        }
5157

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