프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 7b8f5809

이력 | 보기 | 이력해설 | 다운로드 (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
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
385

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

    
399
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
400
                {
401
                    this.SymbolPane.Visibility = Visibility.Collapsed;
402
                    this.FavoritePane.Visibility = Visibility.Collapsed;
403
                    this.drawingRotateCanvas.IsHitTestVisible = false;
404
                }
405
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
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
            SetCommentPages(true);            
549
        }
550

    
551
        /// <summary>
552
        /// start page changing
553
        ///  - save controls if page is modified
554
        ///  - starting download page image
555
        /// </summary>
556
        /// <param name="sender"></param>
557
        /// <param name="e"></param>
558
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
559
        {
560
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
561

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

    
565
            #region 페이지가 벗어난 경우
566

    
567
            if (BalancePoint < 1)
568
            {
569
                BalancePoint = 1;
570
                ViewerDataModel.Instance.PageBalanceNumber = 0;
571
            }
572

    
573
            if (pageNavigator.PageCount < BalancePoint)
574
            {
575
                BalancePoint = pageNavigator.PageCount;
576
                ViewerDataModel.Instance.PageBalanceNumber = 0;
577
            }
578

    
579
            #endregion
580

    
581
            ViewerDataModel.Instance.PageNumber = BalancePoint;
582

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

    
593
            var defaultBitmapImage = new BitmapImage();
594
            defaultBitmapImage.BeginInit();
595
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
596
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
597
            defaultBitmapImage.UriSource = new Uri(uri);
598
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
599
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
600
            defaultBitmapImage.EndInit();
601

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

    
622
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
623
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
624

    
625

    
626
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
627
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
628
            inkBoard.Width = zoomAndPanCanvas.Width;
629
            inkBoard.Height = zoomAndPanCanvas.Height;
630

    
631

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

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

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

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

    
687
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
688

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

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

    
710
                            zoomAndPanControl.ZoomTo(new Rect
711
                            {
712
                                X = 0,
713
                                Y = 0,
714
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
715
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
716
                            });
717

    
718
                            //defaultBitmapImage_Compare dispose
719
                            defaultBitmapImage_Compare = null;
720
                            GC.Collect();
721
                        };
722
                    }
723
                }
724
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
725
            }
726

    
727
        }
728

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

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

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

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

    
789
        #region ZoomIn & ZoomOut
790

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

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

    
803

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

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

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

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

    
839
        }
840

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

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

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

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

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

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

    
893
        #endregion
894

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

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

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

    
907
        }
908

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

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

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

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

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

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

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

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

    
1075

    
1076
               if (this._dragdropWindow != null)
1077
               {
1078
                   this._dragdropWindow.Close();
1079
                   this._dragdropWindow = null;
1080
               }
1081

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

    
1088

    
1089
               CreateDragDropWindow2(img);
1090
              
1091
    }
1092

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1293
                        case ControlType.ArcLine:
1294
                            {
1295
                                var control = currentControl as ArcControl;
1296
                                if (control != null)
1297
                                {
1298
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1299
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1300
                                }
1301
                            }
1302
                            break;
1303

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

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

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

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

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

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

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

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

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

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

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

    
1510
                    e.Handled = true;
1511
                }
1512

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

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

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

    
1562
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1563

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

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

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

    
1577
        private EllipseGeometry hitArea = new EllipseGeometry();
1578

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

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

    
1589
                    SetCursor();
1590

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

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

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

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

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

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

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

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

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

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

    
1679
                zoomAndPanControl.ReleaseMouseCapture();
1680

    
1681

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

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

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

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

    
1707
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1708

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

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

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

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

    
1750
            //GC.Collect();
1751

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

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

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

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

    
1778
        }
1779

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1930
            zoomAndPanControl.RotationAngle = rotate.Angle;
1931

    
1932

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

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

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

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

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

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

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

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

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

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

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

    
2055
            ConvertInkControlToPolygon();
2056

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

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

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

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

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

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

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

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

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

    
2131
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2132
                SetCursor();
2133

    
2134
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2135
            }
2136

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

    
2156
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2157

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

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

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

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

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

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

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

    
2206
                        final = new AdornerFinal(control);
2207

    
2208
                        this.Control_Style(control);
2209

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

    
2235
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2236

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

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

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

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

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

    
2337
                        Control_Style(control);
2338

    
2339
                        final = new AdornerFinal(comment);
2340
                    }
2341

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

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

    
2398
                                    CreateCommand.Instance.Execute(currentControl);
2399

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

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

    
2427
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2428

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

    
2446
                                    CreateCommand.Instance.Execute(currentControl);
2447

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

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

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

    
2481
                                    CreateCommand.Instance.Execute(currentControl);
2482

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

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

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

    
2516
                                    CreateCommand.Instance.Execute(currentControl);
2517

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

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

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

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

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

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

    
2587
                                    CreateCommand.Instance.Execute(currentControl);
2588

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

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

    
2622
                                    CreateCommand.Instance.Execute(currentControl);
2623

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

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

    
2662
                                        CreateCommand.Instance.Execute(currentControl);
2663

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

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

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

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

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

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

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

    
2749
                                    control.ApplyOverViewData();
2750

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

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

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

    
2794
                                    CreateCommand.Instance.Execute(currentControl);
2795

    
2796
                                    currentControl = null;
2797
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2798
                                    return;
2799
                                }
2800

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

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

    
2851
                                    CreateCommand.Instance.Execute(currentControl);
2852

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

    
2894
                                    CreateCommand.Instance.Execute(currentControl);
2895

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

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

    
2954
                                            CreateCommand.Instance.Execute(currentControl);
2955

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

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

    
2999
                                    CreateCommand.Instance.Execute(currentControl);
3000

    
3001
                                    control.isTransOn = true;
3002
                                    var firstPoint = control.PointSet.First();
3003

    
3004
                                    control.PointSet.Add(firstPoint);
3005
                                    control.DrawingCloud();
3006
                                    control.ApplyOverViewData();
3007

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

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

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

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

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

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

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

    
3120
                                        CreateCommand.Instance.Execute(currentControl);
3121
                                        currentControl = null;
3122

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

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

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

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

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

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

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

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

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

    
3259
                                    CreateCommand.Instance.Execute(currentControl);
3260

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

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

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

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

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

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

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

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

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

    
3373
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3374

    
3375
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3376

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

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

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

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

    
3425
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3426

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3707
                                        CreateCommand.Instance.Execute(currentControl);
3708
                                        currentControl = null;
3709
                                   
3710

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

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

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

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

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

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

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

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

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

    
3827
            stroke.DrawingAttributes.Color = Colors.Red;
3828
            stroke.DrawingAttributes.Width = 4;
3829
            stroke.DrawingAttributes.Height = 4;
3830

    
3831
            inkBoard.Strokes.Add(stroke);
3832
        }
3833

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4215
                }
4216
            }
4217
        }
4218

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

    
4225
                var uri = CurrentRev.TO_VENDOR;
4226

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4432

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

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

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

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

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

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

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

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

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

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

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

    
4561
                                    System.Drawing.Bitmap image;
4562

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

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

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

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

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

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

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

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

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

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

    
4711
                List<SYMBOL_PUBLIC> symbol_Public;
4712

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

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

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

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

    
4775
        public PngBitmapEncoder symImage(string data)
4776
        {
4777

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

    
4784
            BitmapEncoder encoder = new PngBitmapEncoder();
4785

    
4786

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

    
4789
            DrawingVisual dv = new DrawingVisual();
4790

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

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

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

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

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

    
4820
        }
4821

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

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

    
4842
        #region 캡쳐 기능
4843

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

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

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

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

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

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

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

    
4882
            return pixels;
4883
        }
4884

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

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

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

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

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

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

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

    
4932
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4933

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

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

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

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

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

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

    
5020
        }
5021

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

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

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

    
5042
            multi_Undo_Data.Markup = control;
5043

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

    
5061
            return multi_Undo_Data;
5062
        }
5063

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

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

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

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

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

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

    
5135
            return false;
5136
        }
5137

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

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

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

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