프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (259 KB)

1 787a4489 KangIngu

2 2b9b3656 taeseongkim
using IKCOM;
3
using KCOM.Common;
4
using KCOM.Controls;
5
using KCOM.Events;
6
using KCOMDataModel.DataModel;
7
using MarkupToPDF.Common;
8
using MarkupToPDF.Controls.Cad;
9 787a4489 KangIngu
using MarkupToPDF.Controls.Common;
10 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Etc;
11 787a4489 KangIngu
using MarkupToPDF.Controls.Line;
12 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Parsing;
13 787a4489 KangIngu
using MarkupToPDF.Controls.Polygon;
14
using MarkupToPDF.Controls.Shape;
15
using MarkupToPDF.Controls.Text;
16 2b9b3656 taeseongkim
using Svg2Xaml;
17 787a4489 KangIngu
using System;
18
using System.Collections.Generic;
19 2b9b3656 taeseongkim
using System.Diagnostics;
20 787a4489 KangIngu
using System.Linq;
21 2b9b3656 taeseongkim
using System.Reflection;
22
using System.Runtime.InteropServices;
23 787a4489 KangIngu
using System.Text;
24 2b9b3656 taeseongkim
using System.Threading;
25
using System.Threading.Tasks;
26
using System.Web;
27 787a4489 KangIngu
using System.Windows;
28
using System.Windows.Controls;
29 2b9b3656 taeseongkim
using System.Windows.Ink;
30 787a4489 KangIngu
using System.Windows.Input;
31
using System.Windows.Media;
32
using System.Windows.Media.Imaging;
33
using System.Windows.Shapes;
34 6707a5c7 ljiyeon
using System.Windows.Threading;
35 2b9b3656 taeseongkim
using Telerik.Windows.Controls;
36 fddb48f7 ljiyeon
using Telerik.Windows.Data;
37 2b9b3656 taeseongkim
using static KCOM.TempFile;
38 787a4489 KangIngu
39
namespace KCOM.Views
40
{
41
    public static class ControlExtensions
42
    {
43
        public static T Clone<T>(this T controlToClone)
44
            where T : System.Windows.Controls.Control
45
        {
46
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
47
48
            T instance = Activator.CreateInstance<T>();
49
50
            foreach (PropertyInfo propInfo in controlProperties)
51
            {
52
                if (propInfo.CanWrite)
53
                {
54
                    if (propInfo.Name != "WindowTarget")
55
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
56
                }
57
            }
58
            return instance;
59
        }
60
    }
61
62 a0bab669 KangIngu
    public class MyConsole
63
    {
64
        private readonly System.Threading.ManualResetEvent _readLineSignal;
65
        private string _lastLine;
66
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73
74
        private void OnKeyUp(object sender, KeyEventArgs e)
75
        {
76
            // this is always fired on UI thread
77
            if (e.Key == Key.Enter)
78
            {
79
                // quick and dirty, but that is not relevant to your question
80
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
81
                // now, when you detected that user typed a line, set signal
82
                _readLineSignal.Set();
83
            }
84
        }
85
86
        public TextBox Gui { get; private set; }
87
88
        public string ReadLine()
89
        {
90
            // that should always be called from non-ui thread
91
            if (Gui.Dispatcher.CheckAccess())
92
                throw new Exception("Cannot be called on UI thread");
93
            // reset signal
94
            _readLineSignal.Reset();
95
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
96
            _readLineSignal.WaitOne();
97
            // we got signalled - return line user typed.
98
            return _lastLine;
99
        }
100
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112
113 787a4489 KangIngu
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119
        public CommentUserInfo currentControl { get; set; }
120
        public ControlType controlType { get; set; }
121 e6a9ddaf humkyung
        private Move move = new Move();
122 787a4489 KangIngu
        private double[] rotateValue = { 0, 90, 180, 270 };
123
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
124
        private static readonly double DragThreshold = 5;
125 eb2b9248 KangIngu
        private System.Windows.Input.Cursor cursor { get; set; }
126 c7fde400 taeseongkim
127
        /// <summary>
128
        ///  문서의 마우스 위치
129
        /// </summary>
130
        public Point CanvasDrawingMouseDownPoint;
131
132 787a4489 KangIngu
        public string filename { get; set; }
133
        private Point canvasZoomPanningMouseDownPoint;
134
        public Point getCurrentPoint;
135
        private Point canvasZoommovingMouseDownPoint;
136
        List<object> ControlList = new List<object>();
137
        private ListBox listBox = new ListBox();
138
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
139
        private bool isDraggingSelectionRect = false;
140
        DrawingAttributes inkDA = new DrawingAttributes();
141
        private VPRevision CurrentRev { get; set; }
142
        public RadRibbonButton btnConsolidate { get; set; }
143
        public RadRibbonButton btnFinalPDF { get; set; }
144
        public RadRibbonButton btnTeamConsolidate { get; set; }
145 80458c15 ljiyeon
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
146
147 787a4489 KangIngu
        public string Filename_ { get; set; }
148
        public double L_Size = 0;
149
        public AdornerFinal adorner_;
150
        public Multi_Undo_data multi_Undo_Data;
151 5ce56a3a KangIngu
        public string Symbol_ID = "";
152 787a4489 KangIngu
        /// <summary>
153
        /// Set to 'true' when the left mouse-button is down.
154
        /// </summary>
155 9f473fb7 KangIngu
        public bool isLeftMouseButtonDownOnWindow = false;
156 787a4489 KangIngu
157
        public InkPresenter _InkBoard = null;
158
        Stroke stroke;
159
        Boolean IsDrawing = false;
160
        StylusPointCollection strokePoints;
161 53880c83 ljiyeon
        //StylusPointCollection erasePoints;
162 787a4489 KangIngu
        RenderTargetBitmap canvasImage;
163
        Point Sync_Offset_Point;
164
165
        //강인구 테스트
166
        private Path _SelectionPath { get; set; }
167
        public Path SelectionPath
168
        {
169
            get
170
            {
171
                return _SelectionPath;
172
            }
173
            set
174
            {
175
                if (_SelectionPath != value)
176
                {
177
                    _SelectionPath = value;
178
                    RaisePropertyChanged("SelectionPath");
179
180
                }
181
            }
182
        }
183
184
        private System.Windows.Controls.Image _imageViewer { get; set; }
185
        public System.Windows.Controls.Image imageViewer
186
        {
187
            get
188
            {
189
                if (_imageViewer == null)
190
                {
191
                    _imageViewer = new System.Windows.Controls.Image();
192
                    return _imageViewer;
193
                }
194
                else
195
                {
196
                    return _imageViewer;
197
                }
198
            }
199
            set
200
            {
201
                if (_imageViewer != value)
202
                {
203
                    _imageViewer = value;
204
                }
205
            }
206
        }
207
208
        public bool IsSyncPDFMode { get; set; }
209
210
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
211
        public System.Windows.Controls.Image imageViewer_Compare
212
        {
213
            get
214
            {
215
                if (_imageViewer_Compare == null)
216
                {
217
                    _imageViewer_Compare = new System.Windows.Controls.Image();
218
                    return _imageViewer_Compare;
219
                }
220
                else
221
                {
222
                    return _imageViewer_Compare;
223
                }
224
            }
225
            set
226
            {
227
                if (_imageViewer_Compare != value)
228
                {
229
                    _imageViewer_Compare = value;
230
                }
231
            }
232
        }
233
234
        #endregion
235 90e7968d ljiyeon
236 787a4489 KangIngu
        public MainMenu()
237
        {
238 f65e6c02 taeseongkim
            //App.splashString(ISplashMessage.MAINMENU_0);            
239
           InitializeComponent();
240
241 dea506e2 taeseongkim
            //List<testItem> testItems = new List<testItem>
242
            //{
243
            //    new testItem{Title = "test1"},
244
            //    new testItem{Title = "test2"},
245
            //    new testItem{Title = "test3"},
246
            //    new testItem{Title = "test4"},
247
            //};
248 f65e6c02 taeseongkim
249 dea506e2 taeseongkim
            //lstSymbolPrivate.ItemsSource = testItems;
250 f65e6c02 taeseongkim
251 90e7968d ljiyeon
            this.Loaded += MainMenu_Loaded;
252 787a4489 KangIngu
        }
253 6707a5c7 ljiyeon
254
        public class TempDt
255
        {
256
            public int PageNumber { get; set; }
257
            public string CommentID { get; set; }
258
            public string ConvertData { get; set; }
259
            public int DATA_TYPE { get; set; }
260
            public string MarkupInfoID { get; set; }
261
            public int IsUpdate { get; set; }
262
        }
263
264
        List<TempDt> tempDtList = new List<TempDt>();
265 90e7968d ljiyeon
266 787a4489 KangIngu
        private void SetCursor()
267
        {
268
            this.Cursor = cursor;
269
        }
270
271 69f41aab humkyung
        /// <summary>
272
        /// get image url
273
        /// </summary>
274
        /// <author>humkyung</author>
275
        /// <param name="sDocumentID"></param>
276
        /// <returns></returns>
277 6dcbe4a7 humkyung
        public string GetImageURL(string sDocumentID, int iPageNo)
278 69f41aab humkyung
        {
279
            string uri = string.Empty;
280
281
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
282
            if (userData.COMPANY != "EXT")
283
            {
284
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
285
            }
286
            else
287
            {
288
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
289
            }
290
291
            return uri;
292
        }
293
294 52827a4c djkim
        /// <summary>
295
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
296
        /// </summary>
297
        /// <returns></returns>
298
        public string GetOriginalPDFURL()
299
        {
300
            string uri = string.Empty;
301
            string sDocumentID = this._DocItem.DOCUMENT_ID;
302
            string filename = string.Empty;
303
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
304
            {
305
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
306
            }
307
            else
308
            {
309
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
310
            }
311 0f26a9aa taeseongkim
312 52827a4c djkim
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
313
            if (userData.COMPANY != "EXT")
314
            {
315
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
316
            }
317
            else
318
            {
319
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
320
            }
321
            uri = uri.Replace(".png", "");
322
            return uri;
323
        }
324 0f26a9aa taeseongkim
325 787a4489 KangIngu
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
326
        {
327
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
328 ca40e004 ljiyeon
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
329
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
330
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
331 787a4489 KangIngu
            {
332
                return true;
333
            }
334
335
            return false;
336
        }
337
338 ca40e004 ljiyeon
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
339
        {
340
            if (rotate.Angle == 90 || rotate.Angle == 270)
341
            {
342
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
343
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
344
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
345
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
346
                {
347
                    return true;
348
                }
349
            }
350
            else
351
            {
352
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
353
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
354
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
355
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
356
                {
357
                    return true;
358
                }
359 90e7968d ljiyeon
            }
360 ca40e004 ljiyeon
361
            return false;
362
        }
363
364 787a4489 KangIngu
        public void DeleteItem(MarkupInfoItem item)
365
        {
366
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
367
            {
368 4eb052e4 ljiyeon
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
369 787a4489 KangIngu
370 4eb052e4 ljiyeon
            
371 787a4489 KangIngu
            ViewerDataModel.Instance._markupInfoList.Remove(item);
372
373
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
374
            {
375
                ViewerDataModel.Instance.MarkupControls.Remove(a);
376
            });
377
378
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
379
            {
380
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
381 39f0624f ljiyeon
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
382 4eb052e4 ljiyeon
                null, Event_Type.Delete, a.CommentID, null);
383 787a4489 KangIngu
            });
384
385 d62c0439 humkyung
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
386 787a4489 KangIngu
            {
387 d62c0439 humkyung
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
388 6707a5c7 ljiyeon
                //임시파일에서도 삭제
389 4eb052e4 ljiyeon
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
390 787a4489 KangIngu
            });
391
392
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
393 bb3a236d ljiyeon
394 787a4489 KangIngu
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
395
            {
396
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
397
                {
398 24678e06 humkyung
                    var infoId = Commons.shortGuid();
399 787a4489 KangIngu
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
400
                    {
401
                        CreateTime = DateTime.Now,
402
                        Depatment = userData.DEPARTMENT,
403 992a98b4 KangIngu
                        UpdateTime = DateTime.Now,
404 787a4489 KangIngu
                        DisplayColor = "#FFFF0000",
405
                        UserID = userData.ID,
406
                        UserName = userData.NAME,
407
                        PageCount = 1,
408
                        Description = "",
409
                        MarkupInfoID = infoId,
410
                        MarkupList = null,
411 24678e06 humkyung
                        MarkupVersionID = Commons.shortGuid(),
412 787a4489 KangIngu
                        Consolidate = 0,
413
                        PartConsolidate = 0,
414
                        userDelete = true,
415
                        AvoidConsolidate = 0,
416
                        IsPreviewUser = true
417
                    };
418
                    App.Custom_ViewInfoId = infoId;
419
                }
420
            }
421 0f065e57 ljiyeon
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
422 4eb052e4 ljiyeon
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
423 787a4489 KangIngu
        }
424
425 959b3ef2 humkyung
        /// <summary>
426
        /// delete selected comments
427
        /// </summary>
428
        /// <param name="sender"></param>
429
        /// <param name="e"></param>
430 787a4489 KangIngu
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
431
        {
432 d7e20d2d taeseongkim
            //정말 삭제 하시겠습니까?
433 17202508 ljiyeon
            DialogParameters parameters = new DialogParameters()
434 c35e49f5 ljiyeon
            {
435 17202508 ljiyeon
                Owner = Application.Current.MainWindow,
436 3d4d6da9 ljiyeon
                Content = new TextBlock()
437
                { 
438
                    MinWidth = 400,
439
                    FontSize = 11,
440 d7e20d2d taeseongkim
                    Text = "Are you sure you want to delete?",
441 3d4d6da9 ljiyeon
                    TextWrapping = System.Windows.TextWrapping.Wrap
442
                },
443 17202508 ljiyeon
                Header = "Confirm",
444
                Theme = new VisualStudio2013Theme(),
445
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
446
                OkButtonContent = "Yes",
447
                CancelButtonContent = "No",
448
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
449
                {
450
                    if(wc.DialogResult == true)
451
                    {
452
                        //선택된 어도너가 있을시 삭제가 되지 않음
453
                        SelectionSet.Instance.UnSelect(this);
454 787a4489 KangIngu
455 17202508 ljiyeon
                        Button content = (sender as Button);
456
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
457 787a4489 KangIngu
458 17202508 ljiyeon
                        DeleteItem(item);
459
                    }
460
                }
461
            };
462
            RadWindow.Confirm(parameters);
463 787a4489 KangIngu
        }
464
465
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
466
467 6707a5c7 ljiyeon
        private static Timer timer;
468
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
469 787a4489 KangIngu
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
470 90e7968d ljiyeon
        {
471 f65e6c02 taeseongkim
            //InitializeComponent();            
472 90e7968d ljiyeon
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
473
474 787a4489 KangIngu
            if (App.ParameterMode)
475 6707a5c7 ljiyeon
            {
476 f7caaaaf ljiyeon
                App.splashString(ISplashMessage.MAINMENU_1);
477 6707a5c7 ljiyeon
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
478 afaa7c92 djkim
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
479 6707a5c7 ljiyeon
                imageViewer_Compare = new Image();
480
                ViewerDataModel.Instance.Capture_Opacity = 0;
481
                da.From = 0.8;
482
                da.To = 0;
483
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
484
                da.AutoReverse = true;
485 e0204db0 djkim
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
486
487
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
488 90e7968d ljiyeon
                {
489 e0204db0 djkim
                    this.SymbolPane.Visibility = Visibility.Collapsed;
490
                    this.FavoritePane.Visibility = Visibility.Collapsed;
491
                    this.drawingRotateCanvas.IsHitTestVisible = false;
492 90e7968d ljiyeon
                }
493 8411f02d ljiyeon
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
494 6707a5c7 ljiyeon
            }
495 6af42ff0 taeseongkim
496 90e7968d ljiyeon
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
497 6af42ff0 taeseongkim
498 ccf944bb ljiyeon
        }
499
500 6af42ff0 taeseongkim
        private async Task DownloadOriginalFileAsync()
501
        {
502
            try
503
            {
504
                using (System.Net.WebClient client = new System.Net.WebClient())
505
                {
506
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
507
                    string downloadurl = GetOriginalPDFURL();
508
                    
509
                    // canceltoken을 위해서 상위에 선언
510
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
511
512
                    client.DownloadProgressChanged += (snd, evt) =>
513
                    {
514
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
515
516
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
517
                    };
518
519
                    await task;
520
521
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
522
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
523
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
524
                }
525
            }
526
            catch (Exception ex)
527
            {
528
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
529
            }
530
        }
531 afaa7c92 djkim
532 6707a5c7 ljiyeon
        private void timercallback(Object o)
533 ccf944bb ljiyeon
        {
534 6707a5c7 ljiyeon
            Stopwatch sw = new Stopwatch();
535
            sw.Start();
536 3b484ebb ljiyeon
            TempFile.TempFileAdd();
537 6707a5c7 ljiyeon
            sw.Stop();
538 ccf944bb ljiyeon
539 90e7968d ljiyeon
            Dispatcher.InvokeAsync(new Action(delegate
540 ccf944bb ljiyeon
            {
541 6707a5c7 ljiyeon
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
542
                {
543
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
544
                }
545
            }));
546 ccf944bb ljiyeon
547 90e7968d ljiyeon
            ////GC.Collect();
548 6707a5c7 ljiyeon
        }
549 077896be humkyung
        
550 d62c0439 humkyung
        /// <summary>
551
        /// update my markuplist
552
        ///  - update existing markup data if already exist
553
        ///  - add new markup data if control is new
554
        /// </summary>
555
        public void UpdateMyMarkupList()
556 787a4489 KangIngu
        {
557 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
558 787a4489 KangIngu
559 d62c0439 humkyung
            /// add or update markup list
560
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
561 787a4489 KangIngu
            {
562 d62c0439 humkyung
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
563 90e7968d ljiyeon
564 d62c0439 humkyung
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
565
                if (exist != null) //신규 추가 된 코멘트
566
                {
567
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
568 6707a5c7 ljiyeon
                    {
569 d62c0439 humkyung
                        exist.Data = root.ConvertData;
570
                        exist.IsUpdate = true;
571 6707a5c7 ljiyeon
                    }
572 d62c0439 humkyung
                }
573
                else if (root.CommentID != null)
574
                {
575
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
576 6707a5c7 ljiyeon
                    {
577 d62c0439 humkyung
                        ID = control.CommentID,
578
                        Data = root.ConvertData,
579
                        Data_Type = root.DATA_TYPE,
580
                        MarkupInfoID = App.Custom_ViewInfoId,
581
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
582
                        Symbol_ID = control.SymbolID,
583 c0977e97 djkim
                        //Group_ID = control.GroupID,
584 d62c0439 humkyung
                    });
585 787a4489 KangIngu
                }
586
            }
587
588 0585d5cc taeseongkim
            if(this.pageNavigator.CurrentPage != null)
589
            { 
590
                /// delete markup list
591
                int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
592 6b6e937c taeseongkim
593 0585d5cc taeseongkim
                var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
594
                              where (markup.PageNumber == iPageNo) 
595
                              && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
596
                              select markup).ToList();
597 6b6e937c taeseongkim
598 0585d5cc taeseongkim
                foreach (var markup in deleted)
599
                {
600
                    ViewerDataModel.Instance.MyMarkupList.Remove(markup);
601
                }
602
            }
603
            else
604 6b6e937c taeseongkim
            {
605 0585d5cc taeseongkim
                System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
606 6b6e937c taeseongkim
            }
607 0585d5cc taeseongkim
608 d62c0439 humkyung
            /// up to here
609 6707a5c7 ljiyeon
610 129ca191 humkyung
            //if (modified)
611
            //{
612
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
613
            //    {
614
            //        ComingNewBieEnd = true;
615
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
616
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
617
            //        gridViewMarkup.ItemsSource = null;
618
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
619
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
620
621
            //        GroupDescriptor descriptor = new GroupDescriptor();
622
            //        descriptor.Member = "Depatment";
623
            //        descriptor.DisplayContent = "DEPT";
624
            //        descriptor.SortDirection = ListSortDirection.Ascending;
625
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
626
            //    }
627
            //}
628 787a4489 KangIngu
        }
629
630 cdfb57ff taeseongkim
        DispatcherTimer renderTesttimer;
631
632 cb5c7f06 humkyung
        /// <summary>
633
        /// start page changing
634
        ///  - save controls if page is modified
635
        ///  - starting download page image
636
        /// </summary>
637
        /// <param name="sender"></param>
638
        /// <param name="e"></param>
639 cdfb57ff taeseongkim
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
640 548c696e ljiyeon
        {
641 72424099 taeseongkim
            await Task.Delay(10);
642 d7e20d2d taeseongkim
643 72424099 taeseongkim
            // 마크업 로드
644
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
645
            await MarkupLoadAsync(e.PageNumber);
646 e8557bd7 taeseongkim
647 dea506e2 taeseongkim
            // 페이지 이미지 변경
648 d7e20d2d taeseongkim
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
649
        }
650
651
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
652
        { 
653 787a4489 KangIngu
            CompareMode.IsChecked = false;
654 d7e20d2d taeseongkim
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
655 f4ec4218 taeseongkim
           
656 787a4489 KangIngu
            #region 페이지가 벗어난 경우
657
658
            if (BalancePoint < 1)
659
            {
660
                BalancePoint = 1;
661
                ViewerDataModel.Instance.PageBalanceNumber = 0;
662
            }
663
664
            if (pageNavigator.PageCount < BalancePoint)
665
            {
666
                BalancePoint = pageNavigator.PageCount;
667
                ViewerDataModel.Instance.PageBalanceNumber = 0;
668
            }
669
670
            #endregion
671
672
            ViewerDataModel.Instance.PageNumber = BalancePoint;
673
674 d7e20d2d taeseongkim
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
675
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
676 cdfb57ff taeseongkim
            var contentScale = zoomAndPanControl.ContentScale;
677 8614f701 taeseongkim
678 92442e4a taeseongkim
            #region 페이지 이미지 로딩 수정
679 8a9f6742 djkim
680 dea506e2 taeseongkim
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
681 d7e20d2d taeseongkim
       
682 d48260a2 djkim
            ScaleImage(pageWidth, pageHeight);
683
684
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
685
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
686
687
            zoomAndPanCanvas.Width = pageWidth;
688
            zoomAndPanCanvas.Height = pageHeight;
689
690
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
691
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
692
693
            inkBoard.Width = pageWidth;
694
            inkBoard.Height = pageHeight;
695 cdfb57ff taeseongkim
696
            #endregion
697 90e7968d ljiyeon
698 787a4489 KangIngu
            if (!testPanel2.IsHidden)
699
            {
700 548c696e ljiyeon
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
701 787a4489 KangIngu
                //PDF모드일때 잠시 대기(강인구)
702
                if (IsSyncPDFMode)
703
                {
704
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
705
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
706
707 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
708 787a4489 KangIngu
                    if (pdfpath.IsDownloading)
709
                    {
710
                        pdfpath.DownloadCompleted += (ex, arg) =>
711
                        {
712 548c696e ljiyeon
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
713 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
714
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
715
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
716
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
717
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
718
                        };
719
                    }
720
                    else
721
                    {
722 548c696e ljiyeon
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
723 787a4489 KangIngu
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
724
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
725
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
726
727
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
728
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
729
                    }
730
                }
731
                else
732
                {
733 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
734 69f41aab humkyung
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
735 a1716fa5 KangIngu
736 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
737 16f1ded9 ljiyeon
                    var defaultBitmapImage_Compare = new BitmapImage();
738 bb4e3ec4 djkim
                    defaultBitmapImage_Compare.BeginInit();
739 94b7c12c djkim
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
740 bb4e3ec4 djkim
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
741
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
742 94b7c12c djkim
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
743
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
744 bb4e3ec4 djkim
                    defaultBitmapImage_Compare.EndInit();
745 787a4489 KangIngu
746 bb4e3ec4 djkim
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
747 787a4489 KangIngu
748 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
749 787a4489 KangIngu
                    zoomAndPanControl.ZoomTo(new Rect
750
                    {
751
                        X = 0,
752
                        Y = 0,
753
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
754
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
755
                    });
756
757 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
758 787a4489 KangIngu
                    if (defaultBitmapImage_Compare.IsDownloading)
759
                    {
760
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
761
                        {
762 bb4e3ec4 djkim
                            defaultBitmapImage_Compare.Freeze();
763 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
764
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
765
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
766 94b7c12c djkim
                            ComparePanel.UpdateLayout();
767 787a4489 KangIngu
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
768
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
769
770
                            zoomAndPanControl.ZoomTo(new Rect
771
                            {
772
                                X = 0,
773
                                Y = 0,
774
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
775
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
776
                            });
777 bb4e3ec4 djkim
778
                            //defaultBitmapImage_Compare dispose
779
                            defaultBitmapImage_Compare = null;
780
                            GC.Collect();
781 787a4489 KangIngu
                        };
782
                    }
783
                }
784
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
785
            }
786
787 f4ec4218 taeseongkim
            SearchFocusBorder.Visibility = Visibility.Collapsed;
788
789 d7e20d2d taeseongkim
            this.pageNavigator.ChangePage(changePageNumber);
790 cdfb57ff taeseongkim
        }
791
792 3ffd4b2d humkyung
        /// <summary>
793
        /// called after page is changed
794
        /// </summary>
795
        /// <param name="sender"></param>
796
        /// <param name="e"></param>
797 a1142a6b taeseongkim
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
798 3ffd4b2d humkyung
        {
799 a1142a6b taeseongkim
            //if (zoomAndPanCanvas.Width.IsNaN())
800
            //{
801 d7e20d2d taeseongkim
802
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
803 a1142a6b taeseongkim
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
804
                );
805
            //}
806 3ffd4b2d humkyung
807 d7e20d2d taeseongkim
808
            var instanceMain = ViewerDataModel.Instance.SystemMain;
809
810
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
811
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
812
813
            instanceMain.dzTopMenu.rotateOffSet = 0;
814
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
815
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
816
817
            /// 페이지의 모든 마크업을 로드한 후 호출
818
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
819
            ViewerDataModel.Instance.LoadPageMarkup();
820
        }
821
822 72424099 taeseongkim
        private async Task MarkupLoadAsync(int pageNumber)
823 ac4f1e13 taeseongkim
        {
824
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
825
            stopwatch.Start();
826
827 3ffd4b2d humkyung
            /// 컨트롤을 새로 생성한다.
828
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
829
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
830 e8557bd7 taeseongkim
831 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
832
833 d7e20d2d taeseongkim
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
834 3ffd4b2d humkyung
            { 
835 5ee1c547 송근호
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
836 3ffd4b2d humkyung
                if (info != null)
837
                {
838
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
839
                    if (info.UserID == App.ViewInfo.UserID)
840
                    {
841 ac4f1e13 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
842 3ffd4b2d humkyung
                                        markup.MarkupInfoID, markup.ID);
843
                        control.Visibility = Visibility.Hidden;
844
                    }
845
                    else
846
                    {
847 ac4f1e13 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
848 3ffd4b2d humkyung
                                                                markup.MarkupInfoID, markup.ID);
849
                        control.Visibility = Visibility.Hidden;
850
                    }
851
                }
852
            };
853
            /// up to here
854
855 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
856
857 3ffd4b2d humkyung
            /// fire selection event
858
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
859
            this.gridViewMarkup.UnselectAll();
860
            this.gridViewMarkup.Select(gridSelectionItem);
861
862
            if (!testPanel2.IsHidden)
863
            {
864
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
865
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
866
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
867
868
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
869
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
870
871
872
                foreach (var item in gridSelectionRevItem)
873
                {
874 ac4f1e13 taeseongkim
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
875
876
                    foreach (var markupitem in markupitems)
877 3ffd4b2d humkyung
                    {
878 ac4f1e13 taeseongkim
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
879
                    }
880 3ffd4b2d humkyung
                }
881
            }
882 ac4f1e13 taeseongkim
883 f65e6c02 taeseongkim
            SetCommentPages();
884 3ffd4b2d humkyung
        }
885
886 f65e6c02 taeseongkim
        public void SetCommentPages()
887 787a4489 KangIngu
        {
888 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
889 787a4489 KangIngu
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
890
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
891 ed3740c4 djkim
            {
892
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
893
                if(item.MarkupList != null)
894 787a4489 KangIngu
                {
895 ed3740c4 djkim
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
896
                    instance.UserName = item.UserName;
897
                    instance.Depart = item.Depatment;
898
                    instance.MarkupInfoID = item.MarkupInfoID;
899
                    instance.IsSelected = true;
900
                    instance.isConSolidation = item.Consolidate;
901
                    instance.SetColor = item.DisplayColor;
902
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
903
                    {
904
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
905
                    }
906
                    else
907
                    {
908
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
909
                    }
910
                    _pages.Add(instance);
911
                }                   
912
            }
913
            
914
            this.pageNavigator.SetCommentList(_pages.ToList());
915
        }
916
917
        public void MarkupitemViewUpdate(string markupinfo_id)
918
        {
919
            //db에 업데이트 한 list 를 view 에 업데이트
920
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
921
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
922
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
923
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
924
            if (dbinfo.MarkupList.Count > 0)
925
            {
926
                if (viewinfo.MarkupList != null)
927
                {
928
                    viewinfo.MarkupList.Clear();
929
                    viewinfo.MarkupList = null;
930 e05fe8ab djkim
                }
931 ed3740c4 djkim
                viewinfo.MarkupList = new List<MarkupItem>();
932
                foreach (var item in dbinfo.MarkupList)
933 e05fe8ab djkim
                {
934 ed3740c4 djkim
                    viewinfo.MarkupList.Add(item);
935 e05fe8ab djkim
                }
936 787a4489 KangIngu
            }
937
        }
938
939 a1142a6b taeseongkim
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
940 787a4489 KangIngu
        {
941 f06cce07 taeseongkim
            var instance = ViewerDataModel.Instance;
942
943 a1142a6b taeseongkim
            if(instance.IsWheelPageChanage)
944 787a4489 KangIngu
            {
945 a1142a6b taeseongkim
                return;
946
            }
947
948
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
949
            {
950
       
951
                int changePage = 0;
952
                
953 f87dfb18 taeseongkim
                if (e.Delta > 0)
954
                {
955 a1142a6b taeseongkim
                    if (0 < instance.ContentOffsetY)
956 f06cce07 taeseongkim
                    {
957
                        Vector dragOffset = new Vector(0, e.Delta);
958
                        MoveZoomAndPanControl(dragOffset);
959
                    }
960
                    //else
961
                    //{
962 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
963
                    //    {
964
                    //        instance.IsWheelPageChanage = true;
965
                    //        changePage -= 1;
966
                    //    }
967 f06cce07 taeseongkim
                    //}
968 f87dfb18 taeseongkim
                }
969 f06cce07 taeseongkim
                else if(e.Delta < 0)
970 f87dfb18 taeseongkim
                {
971 f06cce07 taeseongkim
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
972
                    {
973
                        Vector dragOffset = new Vector(0,e.Delta);
974
                        MoveZoomAndPanControl(dragOffset);
975
                    }
976
                    //else
977
                    //{
978 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
979
                    //    {
980
                    //        instance.IsWheelPageChanage = true;
981
                    //        changePage += 1;
982
                    //    }
983 f06cce07 taeseongkim
                    //}
984 f87dfb18 taeseongkim
                }
985 a1142a6b taeseongkim
986
                //if (changePage != 0)
987
                //{
988
                //    await Task.Factory.StartNew(() =>
989
                //    {
990
                //        double beforeScale = instance.ContentScale;
991
992
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
993
994
                //        handler = (snd, evt) =>
995
                //        {
996
                //            /// 최상단으로 이전 zoomScale로 위치한다
997
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
998
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
999
                //            instance.IsWheelPageChanage = false;
1000
                //            pageNavigator.PageChanged -= handler;
1001
                //        };
1002
1003
                //        pageNavigator.PageChanged += handler;
1004
1005
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1006
                //    });
1007
                    
1008
1009
                //}
1010 787a4489 KangIngu
            }
1011
            else
1012
            {
1013 f87dfb18 taeseongkim
                e.Handled = true;
1014
                if (e.Delta > 0)
1015
                {
1016
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1017
                    ZoomIn(currentContentMousePoint);
1018
                }
1019
                else
1020
                {
1021
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1022
                    ZoomOut(currentContentMousePoint);
1023
                }
1024 787a4489 KangIngu
            }
1025
        }
1026
1027 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1028
        {
1029
            e.Handled = true;
1030
            if (e.Delta > 0)
1031
            {
1032
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1033
                ZoomIn_Sync(currentContentMousePoint);
1034
            }
1035
            else
1036
            {
1037
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1038
                ZoomOut_Sync(currentContentMousePoint);
1039
            }
1040
        }
1041
1042 787a4489 KangIngu
        #region ZoomIn & ZoomOut
1043
1044
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1045
        {
1046
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1047
                zoomAndPanControl.ContentZoomFocusY));
1048
        }
1049
1050
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1051
        {
1052
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1053
                zoomAndPanControl.ContentZoomFocusY));
1054
        }
1055
1056
1057
        //강인구 추가 (줌 인아웃 수치 변경)
1058
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1059
        private void ZoomOut(Point contentZoomCenter)
1060
        {
1061
            if (zoomAndPanControl.ContentScale > 0.39)
1062
            {
1063
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1064
            }
1065
            else
1066
            {
1067
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1068
            }
1069
1070 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1071 787a4489 KangIngu
            {
1072 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1073 787a4489 KangIngu
            }
1074
        }
1075
1076
        private void ZoomIn(Point contentZoomCenter)
1077
        {
1078
            if (zoomAndPanControl.ContentScale > 0.19)
1079
            {
1080
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1081
            }
1082
            else
1083
            {
1084
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1085
            }
1086
1087 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1088 787a4489 KangIngu
            {
1089 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1090 787a4489 KangIngu
            }
1091 a1716fa5 KangIngu
1092
        }
1093
1094
        private void ZoomOut_Sync(Point contentZoomCenter)
1095
        {
1096
            if (zoomAndPanControl2.ContentScale > 0.39)
1097
            {
1098
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1099
            }
1100
            else
1101
            {
1102
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1103
            }
1104
1105
            if (Sync.IsChecked)
1106
            {
1107
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1108
            }
1109
        }
1110
1111
        private void ZoomIn_Sync(Point contentZoomCenter)
1112
        {
1113
            if (zoomAndPanControl2.ContentScale > 0.19)
1114
            {
1115
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1116
            }
1117
            else
1118
            {
1119
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1120
            }
1121
1122
            if (Sync.IsChecked)
1123
            {
1124
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1125
            }
1126 787a4489 KangIngu
        }
1127
1128
        private void ZoomOut()
1129
        {
1130
            zoomAndPanControl.ContentScale -= 0.1;
1131
            //if (zoomAndPanControl2 != null)
1132
            //{
1133
            //    zoomAndPanControl2.ContentScale -= 0.1;
1134
            //}
1135
        }
1136
1137
        private void ZoomIn()
1138
        {
1139
            zoomAndPanControl.ContentScale += 0.1;
1140
            //if (zoomAndPanControl2 != null)
1141
            //{
1142
            //    zoomAndPanControl2.ContentScale += 0.1;
1143
            //}
1144
        }
1145
1146
        #endregion
1147
1148
        private void init()
1149
        {
1150
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1151
            {
1152
1153
                ControlList.Clear();
1154
                listBox.Items.Clear();
1155
                selected_item.Clear();
1156
1157
                (item as IMarkupCommonData).IsSelected = false;
1158
            }
1159
1160
        }
1161
1162
        private HitTestResultBehavior MyCallback(HitTestResult result)
1163
        {
1164
            //this.cursor = Cursors.UpArrow;
1165
            var element = result.VisualHit;
1166
            while (element != null && !(element is CommentUserInfo))
1167
                element = VisualTreeHelper.GetParent(element);
1168
1169
            if (element == null)
1170
            {
1171
                return HitTestResultBehavior.Stop;
1172
            }
1173
            else
1174
            {
1175
                if (element is CommentUserInfo)
1176
                {
1177
                    if (!hitList.Contains(element))
1178
                    {
1179
                        hitList.Add((CommentUserInfo)element);
1180
                    }
1181
                    else
1182
                    {
1183
                        return HitTestResultBehavior.Stop;
1184
                    }
1185
                }
1186
            }
1187
            return HitTestResultBehavior.Continue;
1188
        }
1189
1190
        public void ReleaseSelectPath()
1191
        {
1192
            if (SelectionPath == null)
1193
            {
1194
                SelectionPath = new Path();
1195
                SelectionPath.Name = "";
1196
            }
1197
            if (SelectionPath.Name != "")
1198
            {
1199
                SelectionPath.Name = "None";
1200
            }
1201
            SelectionPath.Opacity = 0.01;
1202
            SelectionPath.RenderTransform = null;
1203
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1204
        }
1205
1206
        #region 컨트롤 초기화 
1207
        public void Control_Init(object control)
1208
        {
1209
            if (L_Size != 0 && (control as IPath) != null)
1210
            {
1211
                (control as IPath).LineSize = L_Size;
1212
                L_Size = 0;
1213
            }
1214
1215
            switch (control.GetType().Name)
1216
            {
1217
                case "RectangleControl":
1218
                    {
1219
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1220
                    }
1221
                    break;
1222
                case "CircleControl":
1223
                    {
1224
                        (control as CircleControl).StrokeColor = Brushes.Red;
1225
                    }
1226
                    break;
1227
                case "TriControl":
1228
                    {
1229
                        (control as TriControl).StrokeColor = Brushes.Red;
1230
                    }
1231
                    break;
1232
                case "RectCloudControl":
1233
                    {
1234
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1235
                    }
1236
                    break;
1237
                case "CloudControl":
1238
                    {
1239
                        (control as CloudControl).StrokeColor = Brushes.Red;
1240
                    }
1241
                    break;
1242
                case "PolygonControl":
1243
                    {
1244
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1245
                    }
1246
                    break;
1247
                case "ArcControl":
1248
                    {
1249
                        (control as ArcControl).StrokeColor = Brushes.Red;
1250
                    }
1251
                    break;
1252 40b3ce25 ljiyeon
                case "ArrowArcControl":
1253
                    {
1254
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1255
                    }
1256
                    break;
1257 787a4489 KangIngu
                case "LineControl":
1258
                    {
1259
                        (control as LineControl).StrokeColor = Brushes.Red;
1260
                    }
1261
                    break;
1262
                case "ArrowControl_Multi":
1263
                    {
1264
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1265
                    }
1266
                    break;
1267
                case "TextControl":
1268
                    {
1269
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1270
                    }
1271
                    break;
1272
                case "ArrowTextControl":
1273
                    {
1274
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1275
                    }
1276
                    break;
1277 684ef11c ljiyeon
                case "InsideWhiteControl":
1278
                    {
1279
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1280
                    }
1281
                    break;
1282
                case "OverlapWhiteControl":
1283
                    {
1284
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1285
                    }
1286
                    break;
1287
                case "ClipWhiteControl":
1288
                    {
1289
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1290
                    }
1291
                    break;
1292
                case "CoordinateControl":
1293
                    {
1294
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1295
                    }
1296
                    break;
1297 787a4489 KangIngu
            }
1298
        }
1299
        #endregion
1300
1301
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1302
        {
1303
            //Control_Init(e.Source);
1304
        }
1305 7211e0c2 ljiyeon
        //private Window _dragdropWindow = null;
1306 53880c83 ljiyeon
1307
        [DllImport("user32.dll")]
1308
        [return: MarshalAs(UnmanagedType.Bool)]
1309
        internal static extern bool GetCursorPos(ref Win32Point pt);
1310
1311
        [StructLayout(LayoutKind.Sequential)]
1312
        internal struct Win32Point
1313
        {
1314
            public Int32 X;
1315
            public Int32 Y;
1316
        };
1317 7211e0c2 ljiyeon
        /*
1318
       public string symbol_id = null;
1319
       public long symbol_group_id;
1320
       public int symbol_SelectedIndex;
1321
       public ImageSource symbol_img;
1322
       public string symbol_Data = null;
1323
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1324
       {
1325
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1326
               zoomAndPanCanvas.ActualHeight / 2));
1327
1328
1329
               if (this._dragdropWindow != null)
1330
               {
1331
                   this._dragdropWindow.Close();
1332
                   this._dragdropWindow = null;
1333
               }
1334
1335
               symbol_id = id;
1336
               symbol_group_id = group_id;
1337
               symbol_SelectedIndex = SelectedIndex;
1338
               symbol_Data = Data_;
1339
               symbol_img = img;
1340
1341
1342
               CreateDragDropWindow2(img);
1343
              
1344
    }
1345 53880c83 ljiyeon
1346 7211e0c2 ljiyeon
    private void CreateDragDropWindow2(ImageSource image)
1347 53880c83 ljiyeon
        {
1348
            this._dragdropWindow = new Window();
1349
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1350
            _dragdropWindow.WindowStyle = WindowStyle.None;
1351
            _dragdropWindow.AllowsTransparency = true;           
1352
            _dragdropWindow.AllowDrop = false;
1353
            _dragdropWindow.Background = null;
1354
            _dragdropWindow.IsHitTestVisible = false;
1355
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1356
            _dragdropWindow.Topmost = true;
1357
            _dragdropWindow.ShowInTaskbar = false;
1358
            
1359
            Rectangle r = new Rectangle();
1360
            r.Width = image.Width;
1361
            r.Height = image.Height;
1362
            r.Opacity = 0.5;            
1363
            r.Fill = new ImageBrush(image);
1364
            this._dragdropWindow.Content = r;
1365
1366
            Win32Point w32Mouse = new Win32Point();
1367
            GetCursorPos(ref w32Mouse);
1368
1369
            //w32Mouse.X = getCurrentPoint.X;
1370
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1371
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1372
            this._dragdropWindow.Show();
1373
        }
1374 f87dfb18 taeseongkim
1375
        
1376
1377 7211e0c2 ljiyeon
         */
1378 f87dfb18 taeseongkim
1379
        public void MoveZoomAndPanControl(Vector dragOffset)
1380
        {
1381
   
1382
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1383
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1384
1385
            if (Sync.IsChecked)
1386
            {
1387
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1388
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1389
            }
1390
        }
1391
1392 787a4489 KangIngu
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1393
        {
1394
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1395
            {
1396
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1397
1398
                Point currentPos = e.GetPosition(rect);
1399 d71ee575 djkim
1400 787a4489 KangIngu
                floatingTip.HorizontalOffset = currentPos.X + 20;
1401
                floatingTip.VerticalOffset = currentPos.Y;
1402
            }
1403
1404
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1405 a36a37c3 humkyung
            
1406 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1407 787a4489 KangIngu
            {
1408 e54660e8 KangIngu
                SetCursor();
1409 787a4489 KangIngu
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1410
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1411
1412
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1413 9cd2865b KangIngu
1414 f87dfb18 taeseongkim
                MoveZoomAndPanControl(dragOffset);
1415 787a4489 KangIngu
            }
1416 992a98b4 KangIngu
1417 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1418 787a4489 KangIngu
            {
1419
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1420
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1421
                SetCursor();
1422
1423
                if (currentControl != null)
1424
                {
1425 c7fde400 taeseongkim
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1426
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1427 787a4489 KangIngu
                    //강인구 추가
1428
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1429
1430
                    if ((currentControl as IPath) != null)
1431
                    {
1432
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1433
                    }
1434 5ce56a3a KangIngu
                    if ((currentControl as LineControl) != null)
1435
                    {
1436
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1437
                    }
1438
1439 787a4489 KangIngu
                    if ((currentControl as IShapeControl) != null)
1440
                    {
1441
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1442
                    }
1443
                    if ((currentControl as TextControl) != null)
1444
                    {
1445
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1446
                        {
1447
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1448
                        }
1449
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1450
                        {
1451 d4b0c723 KangIngu
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1452 787a4489 KangIngu
                        }
1453
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1454
                        {
1455
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1456
                        }
1457
                    }
1458
                    else if ((currentControl as ArrowTextControl) != null)
1459
                    {
1460
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1461
                        {
1462
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1463
                        }
1464
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1465
                        {
1466 d4b0c723 KangIngu
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1467 787a4489 KangIngu
                        }
1468
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1469
                        {
1470
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1471
                        }
1472
                    }
1473 9f473fb7 KangIngu
                    else if ((currentControl as RectCloudControl) != null)
1474
                    {
1475
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1476
                    }
1477
                    else if ((currentControl as CloudControl) != null)
1478
                    {
1479
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1480
                    }
1481 787a4489 KangIngu
1482 168f8027 taeseongkim
1483
                    #region // 모든 컨트롤의 공통기능 제어
1484
                    if (controlType != ControlType.PenControl)
1485
                    {
1486
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1487
                    }
1488
1489
1490
                    #endregion
1491
1492
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1493
1494 787a4489 KangIngu
                    switch (controlType)
1495
                    {
1496 684ef11c ljiyeon
                        case (ControlType.Coordinate):
1497
                            {
1498
                                var control = currentControl as CoordinateControl;
1499
                                if (control != null)
1500
                                {
1501 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1502 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1503
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1504
                                }
1505
                            }
1506
                            break;
1507
                        case (ControlType.InsideWhite):
1508
                            {
1509
                                var control = currentControl as InsideWhiteControl;
1510
                                if (control != null)
1511
                                {
1512 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1513 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1514
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1515
                                    control.Paint = PaintSet.Fill;
1516
                                }
1517
                            }
1518
                            break;
1519 a6272c57 humkyung
                        case ControlType.OverlapWhite:
1520 684ef11c ljiyeon
                            {
1521
                                var control = currentControl as OverlapWhiteControl;
1522
                                if (control != null)
1523
                                {
1524 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1525 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1526
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1527
                                    control.Paint = PaintSet.Fill;
1528
                                }
1529
                            }
1530
                            break;
1531 a6272c57 humkyung
                        case ControlType.ClipWhite:
1532 684ef11c ljiyeon
                            {
1533
                                var control = currentControl as ClipWhiteControl;
1534
                                if (control != null)
1535
                                {
1536 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1537 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1538
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1539
                                    control.Paint = PaintSet.Fill;
1540
                                }
1541
                            }
1542
                            break;
1543 787a4489 KangIngu
                        case ControlType.RectCloud:
1544
                            {
1545
                                var control = currentControl as RectCloudControl;
1546
                                if (control != null)
1547
                                {
1548 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1549 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1550
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1551
                                }
1552
                            }
1553
                            break;
1554
                        case ControlType.SingleLine:
1555
                        case ControlType.CancelLine:
1556
                        case ControlType.ArrowLine:
1557
                        case ControlType.TwinLine:
1558
                        case ControlType.DimLine:
1559
                            {
1560 d71ee575 djkim
                                var control = currentControl as LineControl;
1561
                                if (control != null)
1562 787a4489 KangIngu
                                {
1563 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1564 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1565
                                }
1566 168f8027 taeseongkim
1567 787a4489 KangIngu
                            }
1568
                            break;
1569
1570
                        case ControlType.ArcLine:
1571
                            {
1572 d71ee575 djkim
                                var control = currentControl as ArcControl;
1573
                                if (control != null)
1574 787a4489 KangIngu
                                {
1575 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1576 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1577
                                }
1578
                            }
1579
                            break;
1580
1581
                        case ControlType.ArcArrow:
1582
                            {
1583 40b3ce25 ljiyeon
                                var control = currentControl as ArrowArcControl;
1584 d71ee575 djkim
                                if (control != null)
1585 787a4489 KangIngu
                                {
1586 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1587 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1588
                                }
1589
                            }
1590
                            break;
1591
1592
                        case ControlType.ArrowMultiLine:
1593
                            {
1594 d71ee575 djkim
                                var control = currentControl as ArrowControl_Multi;
1595
                                if (control != null)
1596 787a4489 KangIngu
                                {
1597 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1598 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1599
                                }
1600
                            }
1601
                            break;
1602
1603
                        case ControlType.Circle:
1604
                            {
1605 168f8027 taeseongkim
                                var control = currentControl as CircleControl;
1606
1607
                                if (control != null)
1608 787a4489 KangIngu
                                {
1609 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1610
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1611
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1612 787a4489 KangIngu
                                }
1613
                            }
1614
                            break;
1615
1616
                        case ControlType.PolygonCloud:
1617
                            {
1618
                                var control = currentControl as CloudControl;
1619
                                if (control != null)
1620
                                {
1621 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1622 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1623
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1624
                                }
1625
                            }
1626
                            break;
1627
1628
                        case ControlType.Triangle:
1629
                            {
1630
                                var control = currentControl as TriControl;
1631
                                if (control != null)
1632
                                {
1633 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1634 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1635
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1636
                                }
1637
                            }
1638
                            break;
1639
1640
                        case ControlType.ImgControl:
1641
                            {
1642
                                var control = currentControl as ImgControl;
1643
                                if (control != null)
1644
                                {
1645 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1646 787a4489 KangIngu
                                }
1647
                            }
1648
                            break;
1649
1650
                        case ControlType.Date:
1651
                            {
1652
                                var control = currentControl as DateControl;
1653
                                if (control != null)
1654
                                {
1655 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1656 787a4489 KangIngu
                                }
1657
                            }
1658
                            break;
1659
1660
                        case ControlType.ArrowTextControl:
1661
                        case ControlType.ArrowTransTextControl:
1662
                        case ControlType.ArrowTextBorderControl:
1663
                        case ControlType.ArrowTransTextBorderControl:
1664
                        case ControlType.ArrowTextCloudControl:
1665
                        case ControlType.ArrowTransTextCloudControl:
1666
                            {
1667
                                var control = currentControl as ArrowTextControl;
1668
                                if (control != null)
1669
                                {
1670 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1671 787a4489 KangIngu
                                }
1672
                            }
1673
                            break;
1674
                        case ControlType.PolygonControl:
1675 e6a9ddaf humkyung
                        case ControlType.ChainLine:
1676 787a4489 KangIngu
                            {
1677
                                var control = currentControl as PolygonControl;
1678
                                if (control != null)
1679
                                {
1680 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1681 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1682
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1683
                                }
1684
                            }
1685
                            break;
1686
                        case ControlType.Sign:
1687
                            {
1688
                                var control = currentControl as SignControl;
1689
                                if (control != null)
1690
                                {
1691 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1692 787a4489 KangIngu
                                }
1693
                            }
1694
                            break;
1695
                        case ControlType.Symbol:
1696
                            {
1697
                                var control = currentControl as SymControl;
1698
                                if (control != null)
1699
                                {
1700 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1701 787a4489 KangIngu
                                }
1702
                            }
1703
                            break;
1704
                        case ControlType.Stamp:
1705
                            {
1706 cd988cd8 djkim
                                var control = currentControl as SymControlN;
1707
                                if (control != null)
1708 787a4489 KangIngu
                                {
1709 cd988cd8 djkim
                                    if (control.STAMP != null)
1710 cbaa3c91 ljiyeon
                                    {
1711 168f8027 taeseongkim
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1712 cbaa3c91 ljiyeon
                                    }
1713 cd988cd8 djkim
                                    else
1714
                                    {
1715
                                        currentControl = null;
1716
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1717
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1718
                                    }
1719 168f8027 taeseongkim
                                }
1720 787a4489 KangIngu
                            }
1721
                            break;
1722 a6272c57 humkyung
                        case ControlType.Rectangle:
1723 787a4489 KangIngu
                        case ControlType.Mark:
1724
                            {
1725
                                var control = currentControl as RectangleControl;
1726
                                if (control != null)
1727
                                {
1728 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1729
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1730 7a5210f1 humkyung
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1731 787a4489 KangIngu
                                }
1732
                            }
1733
                            break;
1734
                        case ControlType.PenControl:
1735
                            {
1736
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1737
                                //inkBoard.Strokes.Add(stroke);
1738
                            }
1739
                            break;
1740
                        default:
1741
                            break;
1742
                    }
1743 168f8027 taeseongkim
1744
                    #endregion
1745
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1746
                    {
1747 fa48eb85 taeseongkim
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1748 168f8027 taeseongkim
                    }
1749 787a4489 KangIngu
                }
1750
            }
1751 29cf2c0c humkyung
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1752
            {
1753
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1754
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1755
                SetCursor();
1756
                if (currentControl == null)
1757
                {
1758
                    switch (controlType)
1759
                    {
1760
                        case ControlType.PenControl:
1761
                            {
1762
                                if (inkBoard.Tag.ToString() == "Ink")
1763
                                {
1764
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1765
                                }
1766
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1767
                                {
1768
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1769
                                }
1770
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1771
                                {
1772
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1773
                                }
1774
1775
                                //inkBoard.Strokes.Add(stroke);
1776
                            }
1777
                            break;
1778
                    }
1779
                    return;
1780
                }
1781
            }
1782 e6a9ddaf humkyung
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1783
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1784
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1785 787a4489 KangIngu
            {
1786
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1787
1788
                if (isDraggingSelectionRect)
1789
                {
1790 c7fde400 taeseongkim
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1791 787a4489 KangIngu
                    e.Handled = true;
1792
                }
1793
                else if (isLeftMouseButtonDownOnWindow)
1794
                {
1795 c7fde400 taeseongkim
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1796 787a4489 KangIngu
                    double dragDistance = Math.Abs(dragDelta.Length);
1797
1798
                    if (dragDistance > DragThreshold)
1799
                    {
1800
                        isDraggingSelectionRect = true;
1801 c7fde400 taeseongkim
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1802 787a4489 KangIngu
                    }
1803
1804
                    e.Handled = true;
1805
                }
1806
1807 c7fde400 taeseongkim
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1808 787a4489 KangIngu
                {
1809
                }
1810
                else
1811
                {
1812
                    e.Handled = true;
1813
                }
1814
            }
1815 7211e0c2 ljiyeon
            /*
1816 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1817 53880c83 ljiyeon
            { //symbol      
1818
                if(_dragdropWindow != null)
1819
                {
1820
                    Win32Point w32Mouse = new Win32Point();
1821
                    GetCursorPos(ref w32Mouse);
1822
1823
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1824
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1825
                }                
1826
            }
1827 7211e0c2 ljiyeon
            */
1828 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1829
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1830 787a4489 KangIngu
            {
1831 05009a0e ljiyeon
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1832 e6a9ddaf humkyung
                if(control != null)
1833 787a4489 KangIngu
                {
1834
                    this.cursor = Cursors.Hand;
1835
                    SetCursor();
1836
                }
1837
                else
1838
                {
1839 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1840 787a4489 KangIngu
                    SetCursor();
1841
                }
1842
            }
1843
            else
1844
            {
1845
            }
1846
        }
1847
1848 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1849
        {
1850 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1851 a1716fa5 KangIngu
            {
1852
                SetCursor();
1853
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1854
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1855
1856
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1857
1858
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1859
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1860
1861
                if (Sync.IsChecked)
1862
                {
1863
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1864
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1865
                }
1866
            }
1867
        }
1868
1869 787a4489 KangIngu
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1870
1871
        private EllipseGeometry hitArea = new EllipseGeometry();
1872
1873
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1874
        {
1875
            IsDrawing = false;
1876 d5e3aa15 taeseongkim
    
1877 787a4489 KangIngu
            if (mouseHandlingMode != MouseHandlingMode.None)
1878
            {
1879
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1880
                {
1881 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1882 787a4489 KangIngu
1883
                    SetCursor();
1884
1885
                    switch (controlType)
1886
                    {
1887
                        case ControlType.None:
1888
                            break;
1889
                        case ControlType.Rectangle:
1890
                            {
1891
1892
                            }
1893
                            break;
1894
                        case ControlType.PenControl:
1895
                            {
1896
1897
                            }
1898
                            break;
1899
                        default:
1900
                            break;
1901 4eb052e4 ljiyeon
                    }                    
1902 787a4489 KangIngu
                }
1903 9f473fb7 KangIngu
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1904 787a4489 KangIngu
                {
1905 d5e3aa15 taeseongkim
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1906
1907 787a4489 KangIngu
                    if (isLeftMouseButtonDownOnWindow)
1908
                    {
1909
                        bool wasDragSelectionApplied = false;
1910
1911
                        if (isDraggingSelectionRect)
1912
                        {
1913 53880c83 ljiyeon
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1914
                            {
1915
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1916
                                mouseHandlingMode = MouseHandlingMode.None;
1917
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1918
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1919
                                Set_Symbol_Capture(endPoint);
1920
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1921
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1922
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1923
                            }
1924
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1925 787a4489 KangIngu
                            {
1926
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1927
                                mouseHandlingMode = MouseHandlingMode.None;
1928
                                Set_Capture();
1929
1930
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1931
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1932
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1933
                            }
1934 9f473fb7 KangIngu
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1935 787a4489 KangIngu
                            {
1936
                                ApplyDragSelectionRect();
1937
                            }
1938 9f473fb7 KangIngu
                            else
1939
                            {
1940
                                double x = Canvas.GetLeft(dragZoomBorder);
1941
                                double y = Canvas.GetTop(dragZoomBorder);
1942
                                double width = dragZoomBorder.Width;
1943
                                double height = dragZoomBorder.Height;
1944
                                Rect dragRect = new Rect(x, y, width, height);
1945
1946
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1947
1948
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1949
                            }
1950 787a4489 KangIngu
1951 9f473fb7 KangIngu
                            isDraggingSelectionRect = false;
1952 787a4489 KangIngu
                            e.Handled = true;
1953
                            wasDragSelectionApplied = true;
1954
                        }
1955
1956
                        if (isLeftMouseButtonDownOnWindow)
1957
                        {
1958
                            isLeftMouseButtonDownOnWindow = false;
1959
                            this.ReleaseMouseCapture();
1960
                            e.Handled = true;
1961
                        }
1962
1963
                        if (!wasDragSelectionApplied)
1964
                        {
1965
                            init();
1966
                        }
1967
                    }
1968
                }
1969 e6a9ddaf humkyung
                else if (e.RightButton == MouseButtonState.Pressed)
1970 787a4489 KangIngu
                {
1971 510cbd2a ljiyeon
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1972 787a4489 KangIngu
                    SetCursor();
1973
                }
1974
1975
                zoomAndPanControl.ReleaseMouseCapture();
1976
1977
1978
                e.Handled = true;
1979
            }
1980
            else
1981
            {
1982 510cbd2a ljiyeon
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1983 787a4489 KangIngu
                SetCursor();
1984
            }
1985
1986 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
1987 787a4489 KangIngu
            //controlType = ControlType.SingleLine;
1988
        }
1989
1990 53880c83 ljiyeon
        public void Set_Symbol_Capture(Point endPoint)
1991
        {       
1992 c7fde400 taeseongkim
            double x = CanvasDrawingMouseDownPoint.X;
1993
            double y = CanvasDrawingMouseDownPoint.Y;
1994 53880c83 ljiyeon
            if(x > endPoint.X)
1995
            {
1996
                x = endPoint.X;
1997
                y = endPoint.Y;
1998
            }
1999
2000
            double width = dragCaptureBorder.Width;
2001
            double height = dragCaptureBorder.Height;
2002
2003
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2004
2005
            if (x < 0)
2006
            {
2007
                width += x;
2008
                x = 0;
2009
            }
2010
            if (y < 0)
2011
            {
2012
                height += y;
2013
                y = 0;
2014
2015
                width = (int)canvasImage.PixelWidth - x;
2016
            }
2017
            if (x + width > canvasImage.PixelWidth)
2018
            {
2019
                width = (int)canvasImage.PixelWidth - x;
2020
            }
2021
            if (y + height > canvasImage.PixelHeight)
2022
            {
2023
                height = (int)canvasImage.PixelHeight - y;
2024
            }
2025
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2026
2027 69f41aab humkyung
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2028 53880c83 ljiyeon
            var defaultBitmapImage = new BitmapImage();
2029
            defaultBitmapImage.BeginInit();
2030
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2031
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2032
            defaultBitmapImage.UriSource = new Uri(uri);
2033
            defaultBitmapImage.EndInit();
2034
2035 90e7968d ljiyeon
            //GC.Collect();
2036 53880c83 ljiyeon
2037
            if (defaultBitmapImage.IsDownloading)
2038
            {
2039
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2040
                {
2041
                    defaultBitmapImage.Freeze();
2042 90e7968d ljiyeon
                    //GC.Collect();
2043 53880c83 ljiyeon
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2044
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2045
                };
2046
            }
2047
        }
2048
2049 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2050
        {
2051 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2052 a1716fa5 KangIngu
        }
2053
2054 787a4489 KangIngu
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2055
        {
2056 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2057 53880c83 ljiyeon
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2058 787a4489 KangIngu
        }
2059
2060
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2061
        {
2062
2063
        }
2064
2065 4804a4fb humkyung
        /// <summary>
2066
        /// select items by dragging
2067
        /// </summary>
2068 787a4489 KangIngu
        private void ApplyDragSelectionRect()
2069
        {
2070
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2071
2072
            double x = Canvas.GetLeft(dragSelectionBorder);
2073
            double y = Canvas.GetTop(dragSelectionBorder);
2074
            double width = dragSelectionBorder.Width;
2075
            double height = dragSelectionBorder.Height;
2076
            Boolean Flag = false;
2077
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2078 f87a00b1 ljiyeon
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2079 787a4489 KangIngu
2080 e6a9ddaf humkyung
            Rect dragRect = new Rect(x, y, width, height);
2081
            ///dragRect.Inflate(width / 10, height / 10);
2082 787a4489 KangIngu
2083
            foreach (var item in Items)
2084
            {
2085 91efe37a humkyung
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2086 787a4489 KangIngu
2087
                if (Flag)
2088
                {
2089
                    adornerSet.Add(item);
2090 05009a0e ljiyeon
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2091 787a4489 KangIngu
                    Control_Style(item);
2092
                }
2093
            }
2094
            if (adornerSet.Count > 0)
2095
            {
2096
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2097
                SelectLayer.Children.Add(final);
2098
            }
2099
        }
2100
2101
        private void InitDragSelectionRect(Point pt1, Point pt2)
2102
        {
2103 9f473fb7 KangIngu
            //캡쳐 중
2104
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2105
            {
2106
                dragCaptureBorder.Visibility = Visibility.Visible;
2107
            }
2108 787a4489 KangIngu
            //선택 중
2109 9f473fb7 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2110 787a4489 KangIngu
            {
2111 e54660e8 KangIngu
2112 787a4489 KangIngu
                dragSelectionBorder.Visibility = Visibility.Visible;
2113
            }
2114
            else
2115
            {
2116 9f473fb7 KangIngu
                dragZoomBorder.Visibility = Visibility.Visible;
2117 787a4489 KangIngu
            }
2118
            UpdateDragSelectionRect(pt1, pt2);
2119
        }
2120
2121
        /// <summary>
2122
        /// Update the position and size of the rectangle used for drag selection.
2123
        /// </summary>
2124
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2125
        {
2126
            double x, y, width, height;
2127
2128
            //
2129
            // Determine x,y,width and height of the rect inverting the points if necessary.
2130
            // 
2131
2132
            if (pt2.X < pt1.X)
2133
            {
2134
                x = pt2.X;
2135
                width = pt1.X - pt2.X;
2136
            }
2137
            else
2138
            {
2139
                x = pt1.X;
2140
                width = pt2.X - pt1.X;
2141
            }
2142
2143
            if (pt2.Y < pt1.Y)
2144
            {
2145
                y = pt2.Y;
2146
                height = pt1.Y - pt2.Y;
2147
            }
2148
            else
2149
            {
2150
                y = pt1.Y;
2151
                height = pt2.Y - pt1.Y;
2152
            }
2153
2154
            //
2155
            // Update the coordinates of the rectangle used for drag selection.
2156
            //
2157 9f473fb7 KangIngu
            //캡쳐 중
2158
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2159
            {
2160
                Canvas.SetLeft(dragCaptureBorder, x);
2161
                Canvas.SetTop(dragCaptureBorder, y);
2162
                dragCaptureBorder.Width = width;
2163
                dragCaptureBorder.Height = height;
2164
            }
2165 787a4489 KangIngu
            //선택 중
2166 a1716fa5 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2167 787a4489 KangIngu
            {
2168
                Canvas.SetLeft(dragSelectionBorder, x);
2169
                Canvas.SetTop(dragSelectionBorder, y);
2170
                dragSelectionBorder.Width = width;
2171
                dragSelectionBorder.Height = height;
2172
            }
2173
            else
2174
            {
2175 9f473fb7 KangIngu
                Canvas.SetLeft(dragZoomBorder, x);
2176
                Canvas.SetTop(dragZoomBorder, y);
2177
                dragZoomBorder.Width = width;
2178
                dragZoomBorder.Height = height;
2179 787a4489 KangIngu
            }
2180
        }
2181
2182
        private void drawingPannelRotate(double angle)
2183
        {
2184 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2185 787a4489 KangIngu
            rotate.Angle = angle;
2186
            var rotationNum = Math.Abs((rotate.Angle / 90));
2187
2188
            if (angle == 90 || angle == 270)
2189
            {
2190
                double emptySize = zoomAndPanCanvas.Width;
2191
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2192
                zoomAndPanCanvas.Height = emptySize;
2193
            }
2194
            if (angle == 0)
2195
            {
2196
                translate.X = 0;
2197
                translate.Y = 0;
2198
            }
2199
            else if (angle == 90)
2200
            {
2201
                translate.X = zoomAndPanCanvas.Width;
2202
                translate.Y = 0;
2203
            }
2204
            else if (angle == 180)
2205
            {
2206
                translate.X = zoomAndPanCanvas.Width;
2207
                translate.Y = zoomAndPanCanvas.Height;
2208
            }
2209
            else
2210
            {
2211
                translate.X = 0;
2212
                translate.Y = zoomAndPanCanvas.Height;
2213
            }
2214
2215
            zoomAndPanControl.RotationAngle = rotate.Angle;
2216
2217
2218
            if (!testPanel2.IsHidden)
2219
            {
2220
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2221
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2222
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2223
            }
2224
2225
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2226
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2227
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2228
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2229
            ViewerDataModel.Instance.Angle = rotate.Angle;
2230
        }
2231
2232 497bbe52 ljiyeon
        private void syncPannelRotate(double angle)
2233
        {
2234
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2235
            rotate.Angle = angle;
2236
            var rotationNum = Math.Abs((rotate.Angle / 90));
2237
2238
            if (angle == 90 || angle == 270)
2239
            {
2240
                double emptySize = zoomAndPanCanvas2.Width;
2241
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2242
                zoomAndPanCanvas2.Height = emptySize;
2243
            }
2244
            if (angle == 0)
2245
            {
2246
                translate2.X = 0;
2247
                translate2.Y = 0;
2248
            }
2249
            else if (angle == 90)
2250
            {
2251
                translate2.X = zoomAndPanCanvas2.Width;
2252
                translate2.Y = 0;
2253
            }
2254
            else if (angle == 180)
2255
            {
2256
                translate2.X = zoomAndPanCanvas2.Width;
2257
                translate2.Y = zoomAndPanCanvas2.Height;
2258
            }
2259
            else
2260
            {
2261
                translate2.X = 0;
2262
                translate2.Y = zoomAndPanCanvas2.Height;
2263
            }
2264
2265
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2266
        }
2267
2268 53880c83 ljiyeon
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2269 787a4489 KangIngu
        {
2270 53880c83 ljiyeon
            string Data_ = "";
2271
2272
            try
2273
            {
2274
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2275
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2276
                if (Data_ != null || Data_ != "")
2277
                {
2278
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2279
                }
2280
                else
2281
                {
2282
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2283
                }
2284
2285 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2286
                //{
2287
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2288
                //    STATE = 0,
2289
                //};
2290 53880c83 ljiyeon
                if (Data_ != null)
2291
                {
2292
                    Image img = new Image();
2293
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2294
                    if (Data_.Contains(".svg"))
2295
                    {
2296
                        byte[] imageData = null;
2297
                        DrawingImage image = null;
2298
                        using (System.Net.WebClient web = new System.Net.WebClient())
2299
                        {
2300
                            imageData = web.DownloadData(new Uri(Data_));
2301
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2302
                            image = SvgReader.Load(stream);
2303
                        }
2304
                        img.Source = image;
2305
                    }
2306
                    else
2307
                    {
2308
                        img.Source = new BitmapImage(new Uri(Data_));
2309
                    }
2310
2311
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2312
                    {
2313
                        PointSet = new List<Point>(),
2314
                        FilePath = Data_,
2315
                        ImageData = img.Source,
2316
                        StartPoint = canvasZoomPanningMouseDownPoint,
2317
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2318
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2319
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2320
                        canvasZoomPanningMouseDownPoint.Y),
2321
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2322
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2323
                    };
2324
2325
                    currentControl.PointSet = new List<Point>
2326
                                        {
2327
                                            currentControl.StartPoint,
2328
                                            currentControl.LeftBottomPoint,
2329
                                            currentControl.EndPoint,
2330
                                            currentControl.TopRightPoint,
2331
                                        };
2332
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2333
                    UndoData = new Undo_data()
2334
                    {
2335
                        IsUndo = false,
2336
                        Event = Event_Type.Create,
2337
                        EventTime = DateTime.Now,
2338
                        Markup_List = new List<Multi_Undo_data>()
2339
                    };
2340
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2341
                    {
2342
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2343
                    });
2344
2345
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2346
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2347
                    UndoData.Markup_List.Add(multi_Undo_Data);
2348
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2349
2350
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2351 24678e06 humkyung
                    currentControl.CommentID = Commons.shortGuid();
2352 53880c83 ljiyeon
                    currentControl.SymbolID = id;
2353
                    currentControl.GroupID = group_id;
2354
                    currentControl.ApplyTemplate();
2355
                    currentControl.SetImage();
2356
2357
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2358
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2359
                    SelectLayer.Children.Add(final);
2360
                }
2361
            }
2362
            catch (Exception ex)
2363
            {
2364
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2365
            }
2366
        }
2367
2368 d7e20d2d taeseongkim
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2369 10de973b taeseongkim
        {
2370 992a98b4 KangIngu
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2371 be04d12c djkim
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2372 992a98b4 KangIngu
            {
2373
                set_option.Value = double.Parse(set_option.ContentText);
2374 5d55f6fb ljiyeon
                //set_option.Focusable = false;
2375 3c71b3a5 taeseongkim
                zoomAndPanControl.Focus();
2376 992a98b4 KangIngu
            }
2377
2378 f959ea6f humkyung
            ConvertInkControlToPolygon();
2379 787a4489 KangIngu
2380 d62c0439 humkyung
            ///TODO:
2381 787a4489 KangIngu
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2382
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2383
2384 a1716fa5 KangIngu
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2385 787a4489 KangIngu
            {
2386
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2387
            }
2388 d62c0439 humkyung
            /// up to here
2389 787a4489 KangIngu
2390 b7813553 djkim
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2391 787a4489 KangIngu
            {
2392 b7813553 djkim
                if (item as ArrowTextControl != null)
2393 787a4489 KangIngu
                {
2394 b7813553 djkim
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2395 787a4489 KangIngu
                }
2396 76688e76 djkim
                else if (item as TextControl != null)
2397
                {
2398
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2399
                }
2400 787a4489 KangIngu
            }
2401
2402 49b217ad humkyung
            //if (currentControl != null)
2403 787a4489 KangIngu
            {
2404 a6f7f9b6 djkim
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2405
                if (text_item_ != null)
2406 787a4489 KangIngu
                {
2407
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2408
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2409 a6f7f9b6 djkim
                    (text_item_ as TextControl).IsEditingMode = false;                    
2410 49b217ad humkyung
                    currentControl = null;
2411 787a4489 KangIngu
                }
2412
2413
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2414 49b217ad humkyung
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2415 787a4489 KangIngu
                {
2416
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2417
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2418 49b217ad humkyung
                    currentControl = null;
2419 787a4489 KangIngu
                }
2420
            }
2421
2422 ca40e004 ljiyeon
            double Ang = 0;                                          
2423 787a4489 KangIngu
            if (rotate.Angle != 0)
2424
            {
2425
                Ang = 360 - rotate.Angle;
2426
            }
2427
2428
            if (e.OriginalSource is System.Windows.Controls.Image)
2429
            {
2430
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2431
            }
2432 7211e0c2 ljiyeon
            /*
2433 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2434 53880c83 ljiyeon
            {                
2435
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2436
                if(symbol_id != null)
2437
                {
2438
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2439
                }                
2440
            }
2441
2442 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2443 53880c83 ljiyeon
            {
2444
                if (this._dragdropWindow != null)
2445
                {
2446
                    this._dragdropWindow.Close();
2447
                    this._dragdropWindow = null;
2448
                    symbol_id = null;
2449
                }
2450
            }
2451 7211e0c2 ljiyeon
            */
2452 53880c83 ljiyeon
2453 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed)
2454 787a4489 KangIngu
            {
2455 c7fde400 taeseongkim
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2456 787a4489 KangIngu
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2457
2458 510cbd2a ljiyeon
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2459 787a4489 KangIngu
                SetCursor();
2460
2461 f513c215 humkyung
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2462 787a4489 KangIngu
            }
2463 f513c215 humkyung
2464 e6a9ddaf humkyung
            if (e.MiddleButton == MouseButtonState.Pressed)
2465 787a4489 KangIngu
            {
2466
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2467
                cursor = Cursors.SizeAll;
2468
                SetCursor();
2469
            }
2470 e6a9ddaf humkyung
            if (e.RightButton == MouseButtonState.Pressed)
2471 787a4489 KangIngu
            {
2472
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2473
                cursor = Cursors.SizeAll;
2474
                SetCursor();
2475
            }
2476 e6a9ddaf humkyung
            else if (e.XButton1 == MouseButtonState.Pressed)
2477 787a4489 KangIngu
            {
2478
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2479
                {
2480 3908a575 humkyung
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2481 787a4489 KangIngu
                }
2482
2483 3908a575 humkyung
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2484 787a4489 KangIngu
2485
            }
2486 e6a9ddaf humkyung
            else if (e.XButton2 == MouseButtonState.Pressed)
2487 787a4489 KangIngu
            {
2488
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2489
                {
2490
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2491
                }
2492
            }
2493
2494 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2495 787a4489 KangIngu
            {
2496
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2497
                {
2498
                    if (SelectLayer.Children.Count == 0)
2499
                    {
2500
                        isLeftMouseButtonDownOnWindow = true;
2501
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2502
                    }
2503
2504
                    if (controlType == ControlType.None)
2505
                    {
2506
                        isLeftMouseButtonDownOnWindow = true;
2507
                    }
2508
                }
2509
2510 f513c215 humkyung
                /// 캡쳐 모드 설정
2511 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2512
                {
2513
                    dragCaptureBorder.Visibility = Visibility.Visible;
2514
                    isLeftMouseButtonDownOnWindow = true;
2515
                }
2516
2517 f513c215 humkyung
                /// 줌 모드 설정
2518 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2519
                {
2520
                    isLeftMouseButtonDownOnWindow = true;
2521 1066bae3 ljiyeon
                }
2522 787a4489 KangIngu
2523 05009a0e ljiyeon
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2524 787a4489 KangIngu
                if (control != null)
2525
                {
2526 d62c0439 humkyung
                    AdornerFinal final = null;
2527 787a4489 KangIngu
2528
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2529
                    {
2530 d62c0439 humkyung
                        /// 기존 selection 해제
2531 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
2532 d62c0439 humkyung
2533 787a4489 KangIngu
                        final = new AdornerFinal(control);
2534
2535 f513c215 humkyung
                        this.Control_Style(control);
2536 787a4489 KangIngu
2537
                        if ((control as IPath) != null)
2538
                        {
2539
                            if ((control as IPath).LineSize != 0)
2540
                            {
2541
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2542
                            }
2543
                        }
2544
                        if ((control as IShapeControl) != null)
2545
                        {
2546
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2547
                            {
2548
                                ViewerDataModel.Instance.checkHatchShape = true;
2549
                            }
2550
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2551
                            {
2552
                                ViewerDataModel.Instance.checkFillShape = true;
2553
                            }
2554
                            else
2555
                            {
2556
                                ViewerDataModel.Instance.checkHatchShape = false;
2557
                                ViewerDataModel.Instance.checkFillShape = false;
2558
                            }
2559
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2560
                        }
2561 9f473fb7 KangIngu
2562 787a4489 KangIngu
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2563 d4b0c723 KangIngu
2564
                        if ((control as TextControl) != null)
2565
                        {
2566 71d7e0bf 송근호
                            if(!((control as TextControl).EnableEditing)) {
2567
                                (control as TextControl).EnableEditing = true;
2568
                            }
2569 d4b0c723 KangIngu
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2570
                            {
2571
                                ViewerDataModel.Instance.checkTextStyle = true;
2572
                            }
2573
                            else
2574
                            {
2575
                                ViewerDataModel.Instance.checkTextStyle = false;
2576
                            }
2577
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2578
                            {
2579
                                ViewerDataModel.Instance.checkTextWeight = true;
2580
                            }
2581
                            else
2582
                            {
2583
                                ViewerDataModel.Instance.checkTextWeight = false;
2584
                            }
2585
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2586
                            {
2587
                                ViewerDataModel.Instance.checkUnderLine = true;
2588
                            }
2589
                            else
2590
                            {
2591
                                ViewerDataModel.Instance.checkUnderLine = false;
2592
                            }
2593
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2594
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2595 e54660e8 KangIngu
2596 d4b0c723 KangIngu
                        }
2597
                        else if ((control as ArrowTextControl) != null)
2598
                        {
2599 120b8b00 송근호
                            if (!((control as ArrowTextControl).EnableEditing))
2600
                            {
2601 71d7e0bf 송근호
                                (control as ArrowTextControl).EnableEditing = true;
2602
                            }
2603 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2604 d4b0c723 KangIngu
                            {
2605 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = true;
2606
                            }
2607
                            else
2608 d4b0c723 KangIngu
                            {
2609 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextStyle = false;
2610 d4b0c723 KangIngu
                            }
2611 e17af42b KangIngu
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2612 d4b0c723 KangIngu
                            {
2613 e17af42b KangIngu
                                ViewerDataModel.Instance.checkTextWeight = true;
2614
                            }
2615
                            else
2616
                            {
2617
                                ViewerDataModel.Instance.checkTextWeight = false;
2618
                            }
2619
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2620
                            {
2621
                                ViewerDataModel.Instance.checkUnderLine = true;
2622
                            }
2623
                            else
2624
                            {
2625
                                ViewerDataModel.Instance.checkUnderLine = false;
2626 d4b0c723 KangIngu
                            }
2627
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2628
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2629
                        }
2630 9f473fb7 KangIngu
                        else if ((control as RectCloudControl) != null)
2631
                        {
2632
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2633
                        }
2634
                        else if ((control as CloudControl) != null)
2635
                        {
2636
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2637
                        }
2638 787a4489 KangIngu
                    }
2639
                    else
2640
                    {
2641 d62c0439 humkyung
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2642
                        SelectionSet.Instance.UnSelect(this);
2643 787a4489 KangIngu
                        comment.Add(control);
2644
2645
                        Control_Style(control);
2646
2647
                        final = new AdornerFinal(comment);
2648
                    }
2649
2650 f513c215 humkyung
                    if (final != null)
2651
                    {
2652
                        this.SelectLayer.Children.Add(final);
2653
                    }
2654 6707a5c7 ljiyeon
                }              
2655 787a4489 KangIngu
            }
2656
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2657 6707a5c7 ljiyeon
            {               
2658 787a4489 KangIngu
                init();
2659
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2660
                if (cursor != Cursors.SizeAll)
2661
                {
2662
                    cursor = Cursors.Cross;
2663
                    SetCursor();
2664
                }
2665
                bool init_user = false;
2666
                foreach (var user in gridViewMarkup.Items)
2667
                {
2668
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2669
                    {
2670
                        init_user = true;
2671
                    }
2672
                }
2673
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2674
                {
2675 d7e20d2d taeseongkim
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2676 787a4489 KangIngu
                    RadWindow.Alert(new DialogParameters
2677
                    {
2678 b9b01f8e ljiyeon
                        Owner = Application.Current.MainWindow,
2679 787a4489 KangIngu
                        Theme = new VisualStudio2013Theme(),
2680 d7e20d2d taeseongkim
                        Header = "Info",
2681
                        Content = "Existing comments already existed. Select from the user list first",
2682 787a4489 KangIngu
                    });
2683
                    return;
2684
                }
2685
                else
2686
                {
2687
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2688
                    if (item != null)
2689
                    {
2690
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2691
                    }
2692
                }
2693
2694 75448f5e ljiyeon
                switch (controlType)
2695 787a4489 KangIngu
                {
2696 684ef11c ljiyeon
                    case ControlType.Coordinate:
2697
                        {
2698 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2699 684ef11c ljiyeon
                            {
2700
                                if (currentControl is CoordinateControl)
2701
                                {
2702
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2703
                                    {
2704
                                        return;
2705
                                    }
2706
2707 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2708 684ef11c ljiyeon
2709
                                    currentControl = null;
2710
                                    this.cursor = Cursors.Arrow;
2711
                                }
2712
                                else
2713
                                {
2714
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2715 d62c0439 humkyung
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2716 684ef11c ljiyeon
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2717
                                    {
2718
                                        currentControl = null;
2719
                                        this.cursor = Cursors.Arrow;
2720
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2721
                                        return;
2722
                                    }
2723
                                    else
2724
                                    {
2725
                                        currentControl = new CoordinateControl
2726
                                        {
2727
                                            Background = new SolidColorBrush(Colors.Black),
2728 c7fde400 taeseongkim
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2729 684ef11c ljiyeon
                                            ControlType = ControlType.Coordinate
2730
                                        };
2731
2732 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
2733 684ef11c ljiyeon
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2734
                                        currentControl.IsNew = true;
2735
2736
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2737
2738
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2739
                                    }
2740
                                }
2741
                            }
2742
                        }
2743
                        break;
2744
                    case ControlType.InsideWhite:
2745
                        {
2746 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2747 684ef11c ljiyeon
                            {
2748
                                if (currentControl is InsideWhiteControl)
2749
                                {
2750
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2751
                                    {
2752
                                        return;
2753
                                    }
2754
2755 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2756 684ef11c ljiyeon
2757
                                    currentControl = null;
2758
                                    this.cursor = Cursors.Arrow;
2759
                                }
2760
                                else
2761
                                {
2762
                                    currentControl = new InsideWhiteControl
2763
                                    {
2764
                                        Background = new SolidColorBrush(Colors.Black),
2765 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2766 684ef11c ljiyeon
                                        ControlType = ControlType.InsideWhite
2767
                                    };
2768
2769 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2770 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2771
                                    currentControl.IsNew = true;
2772
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2773
2774
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2775
                                }
2776
                            }
2777
                        }
2778
                        break;
2779
                    case ControlType.OverlapWhite:
2780
                        {
2781 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2782 684ef11c ljiyeon
                            {
2783
                                if (currentControl is OverlapWhiteControl)
2784
                                {
2785
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2786
                                    {
2787
                                        return;
2788
                                    }
2789
2790 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2791 684ef11c ljiyeon
2792
                                    currentControl = null;
2793
                                    this.cursor = Cursors.Arrow;
2794
                                }
2795
                                else
2796
                                {
2797
                                    currentControl = new OverlapWhiteControl
2798
                                    {
2799
                                        Background = new SolidColorBrush(Colors.Black),
2800 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2801 684ef11c ljiyeon
                                        ControlType = ControlType.OverlapWhite
2802
                                    };
2803
2804 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2805 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2806
                                    currentControl.IsNew = true;
2807
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2808
2809
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2810
                                }
2811
                            }
2812
                        }
2813
                        break;
2814
                    case ControlType.ClipWhite:
2815
                        {
2816 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2817 684ef11c ljiyeon
                            {
2818
                                if (currentControl is ClipWhiteControl)
2819
                                {
2820
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2821
                                    {
2822
                                        return;
2823
                                    }
2824
2825 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2826 684ef11c ljiyeon
2827
                                    currentControl = null;
2828
                                    this.cursor = Cursors.Arrow;
2829
                                }
2830
                                else
2831
                                {
2832
                                    currentControl = new ClipWhiteControl
2833
                                    {
2834
                                        Background = new SolidColorBrush(Colors.Black),
2835 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2836 684ef11c ljiyeon
                                        ControlType = ControlType.ClipWhite
2837
                                    };
2838
2839 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2840 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2841
                                    currentControl.IsNew = true;
2842
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2843
2844
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2845
                                }
2846
                            }
2847
                        }
2848
                        break;
2849 787a4489 KangIngu
                    case ControlType.Rectangle:
2850
                        {
2851 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2852 787a4489 KangIngu
                            {
2853 f67f164e humkyung
                                if (currentControl is RectangleControl)
2854
                                {
2855
                                    //20180906 LJY TEST IsRotationDrawingEnable
2856
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2857 787a4489 KangIngu
                                    {
2858 f67f164e humkyung
                                        return;
2859
                                    }
2860 787a4489 KangIngu
2861 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2862
                                    currentControl = null;
2863 510cbd2a ljiyeon
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2864 f67f164e humkyung
                                }
2865
                                else
2866
                                {
2867
                                    currentControl = new RectangleControl
2868 787a4489 KangIngu
                                    {
2869 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
2870 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2871 f67f164e humkyung
                                        ControlType = ControlType.Rectangle
2872
                                    };
2873 787a4489 KangIngu
2874 f67f164e humkyung
                                    currentControl.CommentID = Commons.shortGuid();
2875
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2876
                                    currentControl.IsNew = true;
2877
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2878 787a4489 KangIngu
2879 f67f164e humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2880
                                }
2881 787a4489 KangIngu
                            }
2882
                        }
2883
                        break;
2884
                    case ControlType.RectCloud:
2885
                        {
2886 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2887 787a4489 KangIngu
                            {
2888 f67f164e humkyung
                                if (currentControl is RectCloudControl)
2889
                                {
2890
                                    //20180906 LJY TEST IsRotationDrawingEnable
2891
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2892 787a4489 KangIngu
                                    {
2893 f67f164e humkyung
                                        return;
2894
                                    }
2895 e66f22eb KangIngu
2896 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2897 787a4489 KangIngu
2898 f67f164e humkyung
                                    currentControl = null;
2899
                                
2900
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2901
                                }
2902
                                else
2903
                                {
2904
                                    currentControl = new RectCloudControl
2905 787a4489 KangIngu
                                    {
2906 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2907 f67f164e humkyung
                                        ControlType = ControlType.RectCloud,
2908
                                        Background = new SolidColorBrush(Colors.Black)
2909
                                    };
2910 787a4489 KangIngu
2911 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2912
                                    currentControl.CommentID = Commons.shortGuid();
2913
                                    currentControl.IsNew = true;
2914
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2915
                                }
2916 787a4489 KangIngu
                            }
2917
                        }
2918
                        break;
2919
                    case ControlType.Circle:
2920
                        {
2921 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2922 787a4489 KangIngu
                            {
2923 f67f164e humkyung
                                if (currentControl is CircleControl)
2924
                                {
2925
                                    //20180906 LJY TEST IsRotationDrawingEnable
2926
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2927 787a4489 KangIngu
                                    {
2928 f67f164e humkyung
                                        return;
2929
                                    }
2930 e66f22eb KangIngu
2931 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
2932 787a4489 KangIngu
2933 f67f164e humkyung
                                    currentControl = null;
2934
                                }
2935
                                else
2936
                                {
2937
                                    currentControl = new CircleControl
2938 787a4489 KangIngu
                                    {
2939 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2940
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2941 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
2942
                                    };
2943 787a4489 KangIngu
2944 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2945
                                    currentControl.CommentID = Commons.shortGuid();
2946
                                    currentControl.IsNew = true;
2947
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2948
                                }
2949 787a4489 KangIngu
                            }
2950
                        }
2951
                        break;
2952
                    case ControlType.Triangle:
2953
                        {
2954 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2955 787a4489 KangIngu
                            {
2956 f67f164e humkyung
                                if (currentControl is TriControl)
2957
                                {
2958
                                    var content = currentControl as TriControl;
2959
                                    if (content.MidPoint == new Point(0, 0))
2960 787a4489 KangIngu
                                    {
2961 c7fde400 taeseongkim
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2962 787a4489 KangIngu
                                    }
2963
                                    else
2964
                                    {
2965 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
2966 f67f164e humkyung
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2967 e66f22eb KangIngu
                                        {
2968
                                            return;
2969
                                        }
2970
2971 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
2972 787a4489 KangIngu
2973
                                        currentControl = null;
2974
                                    }
2975 f67f164e humkyung
                                }
2976
                                else
2977
                                {
2978
                                    currentControl = new TriControl
2979 787a4489 KangIngu
                                    {
2980 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2981 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
2982
                                    };
2983 787a4489 KangIngu
2984 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2985
                                    currentControl.CommentID = Commons.shortGuid();
2986
                                    currentControl.IsNew = true;
2987
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2988
                                }
2989 787a4489 KangIngu
                            }
2990
                        }
2991
                        break;
2992
                    case ControlType.CancelLine:
2993 f67f164e humkyung
                    case ControlType.SingleLine:
2994
                    case ControlType.ArrowLine:
2995
                    case ControlType.TwinLine:
2996
                    case ControlType.DimLine:
2997 787a4489 KangIngu
                        {
2998 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
2999 787a4489 KangIngu
                            {
3000 f67f164e humkyung
                                if (currentControl is LineControl)
3001
                                {
3002
                                    //20180906 LJY TEST IsRotationDrawingEnable
3003
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3004 787a4489 KangIngu
                                    {
3005 f67f164e humkyung
                                        return;
3006 787a4489 KangIngu
                                    }
3007 f67f164e humkyung
3008
                                    CreateCommand.Instance.Execute(currentControl);
3009
                                    currentControl = null;
3010 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3011 f67f164e humkyung
                                }
3012
                                else
3013
                                {
3014
                                    currentControl = new LineControl
3015 787a4489 KangIngu
                                    {
3016 f67f164e humkyung
                                        ControlType = this.controlType,
3017 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3018 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3019
                                    };
3020 787a4489 KangIngu
3021 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3022
                                    currentControl.CommentID = Commons.shortGuid();
3023
                                    currentControl.IsNew = true;
3024
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3025 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3026 f67f164e humkyung
                                }
3027 787a4489 KangIngu
                            }
3028
                        }
3029
                        break;
3030 f67f164e humkyung
                    case ControlType.PolygonControl:
3031 787a4489 KangIngu
                        {
3032 f67f164e humkyung
                            if (currentControl is PolygonControl)
3033 787a4489 KangIngu
                            {
3034 f67f164e humkyung
                                var control = currentControl as PolygonControl;
3035 e66f22eb KangIngu
3036 f67f164e humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3037
                                {
3038
                                    control.IsCompleted = true;
3039
                                }
3040 787a4489 KangIngu
3041 f67f164e humkyung
                                if (!control.IsCompleted)
3042
                                {
3043
                                    control.PointSet.Add(control.EndPoint);
3044
                                }
3045
                                else
3046
                                {
3047
                                    //20180906 LJY TEST IsRotationDrawingEnable
3048
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3049 787a4489 KangIngu
                                    {
3050 f67f164e humkyung
                                        return;
3051 787a4489 KangIngu
                                    }
3052 e66f22eb KangIngu
3053 f67f164e humkyung
                                    var firstPoint = control.PointSet.First();
3054
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3055
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3056
                                    control.PointSet.Add(firstPoint);
3057 787a4489 KangIngu
3058 f67f164e humkyung
                                    control.ApplyOverViewData();
3059
3060
                                    CreateCommand.Instance.Execute(currentControl);
3061 0d00f9c8 humkyung
                                    control.UpdateControl();
3062 f67f164e humkyung
                                    currentControl = null;
3063
                                }
3064 787a4489 KangIngu
                            }
3065 f67f164e humkyung
                            else
3066 787a4489 KangIngu
                            {
3067 f67f164e humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3068
                                {
3069
                                    currentControl = new PolygonControl
3070 787a4489 KangIngu
                                    {
3071 f67f164e humkyung
                                        PointSet = new List<Point>(),
3072
                                    };
3073 787a4489 KangIngu
3074 f67f164e humkyung
                                    var polygonControl = (currentControl as PolygonControl);
3075
                                    currentControl.CommentID = Commons.shortGuid();
3076
                                    currentControl.IsNew = true;
3077
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3078 c7fde400 taeseongkim
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3079
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3080
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3081
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3082 f67f164e humkyung
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3083
                                    polygonControl.ApplyTemplate();
3084
                                    polygonControl.Visibility = Visibility.Visible;
3085
                                }
3086 787a4489 KangIngu
                            }
3087
                        }
3088
                        break;
3089
                    case ControlType.ChainLine:
3090
                        {
3091
                            if (currentControl is PolygonControl)
3092
                            {
3093
                                var control = currentControl as PolygonControl;
3094
3095 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3096 787a4489 KangIngu
                                {
3097 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3098
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3099 e66f22eb KangIngu
                                    {
3100
                                        return;
3101
                                    }
3102
3103 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3104 787a4489 KangIngu
3105
                                    currentControl = null;
3106 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3107 787a4489 KangIngu
                                    return;
3108
                                }
3109
3110
                                if (!control.IsCompleted)
3111
                                {
3112
                                    control.PointSet.Add(control.EndPoint);
3113 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3114 787a4489 KangIngu
                                }
3115
                            }
3116
                            else
3117
                            {
3118 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3119 787a4489 KangIngu
                                {
3120 2eac4f76 KangIngu
                                    MainAngle.Visibility = Visibility.Visible;
3121 787a4489 KangIngu
                                    currentControl = new PolygonControl
3122
                                    {
3123
                                        PointSet = new List<Point>(),
3124
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3125
                                        ControlType = ControlType.ChainLine,
3126
                                        DashSize = ViewerDataModel.Instance.DashSize,
3127
                                        LineSize = ViewerDataModel.Instance.LineSize,
3128
                                        //PointC = new StylusPointSet()
3129
                                    };
3130
3131 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3132
                                    //{
3133 787a4489 KangIngu
                                        var polygonControl = (currentControl as PolygonControl);
3134 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3135 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3136
                                        currentControl.IsNew = true;
3137
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3138
                                        //currentControl.OnApplyTemplate();
3139
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3140
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3141 c7fde400 taeseongkim
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3142
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3143 e66f22eb KangIngu
                                    //}
3144 787a4489 KangIngu
                                }
3145
                            }
3146
                        }
3147
                        break;
3148
                    case ControlType.ArcLine:
3149
                        {
3150 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3151 787a4489 KangIngu
                            {
3152 f67f164e humkyung
                                if (currentControl is ArcControl)
3153
                                {
3154
                                    //20180906 LJY TEST IsRotationDrawingEnable
3155
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3156 787a4489 KangIngu
                                    {
3157 f67f164e humkyung
                                        return;
3158
                                    }
3159 e66f22eb KangIngu
3160 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3161 787a4489 KangIngu
3162 f67f164e humkyung
                                    currentControl = null;
3163 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3164 f67f164e humkyung
                                }
3165
                                else
3166
                                {
3167
                                    currentControl = new ArcControl
3168 787a4489 KangIngu
                                    {
3169 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3170 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3171
                                    };
3172
                                    currentControl.CommentID = Commons.shortGuid();
3173
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3174
                                    currentControl.IsNew = true;
3175
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3176 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3177 f67f164e humkyung
                                }
3178 787a4489 KangIngu
                            }
3179 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3180 787a4489 KangIngu
                            {
3181
                                if (currentControl != null)
3182
                                {
3183
                                    (currentControl as ArcControl).setClock();
3184 05f4d127 KangIngu
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3185 787a4489 KangIngu
                                }
3186
                            }
3187
                        }
3188
                        break;
3189
                    case ControlType.ArcArrow:
3190
                        {
3191 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3192 787a4489 KangIngu
                            {
3193 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3194
                                //{
3195 40b3ce25 ljiyeon
                                if (currentControl is ArrowArcControl)
3196
                                {
3197
                                    //20180906 LJY TEST IsRotationDrawingEnable
3198
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3199 787a4489 KangIngu
                                    {
3200 40b3ce25 ljiyeon
                                        return;
3201
                                    }
3202 e66f22eb KangIngu
3203 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3204 787a4489 KangIngu
3205 40b3ce25 ljiyeon
                                    currentControl = null;
3206 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3207 40b3ce25 ljiyeon
                                }
3208
                                else
3209
                                {
3210
                                    currentControl = new ArrowArcControl
3211 787a4489 KangIngu
                                    {
3212 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3213 40b3ce25 ljiyeon
                                        Background = new SolidColorBrush(Colors.Black)
3214
                                    };
3215 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3216 40b3ce25 ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3217
                                    currentControl.IsNew = true;
3218
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3219 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3220 40b3ce25 ljiyeon
                                }
3221 e66f22eb KangIngu
                                //}
3222 787a4489 KangIngu
                            }
3223 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3224 787a4489 KangIngu
                            {
3225 40b3ce25 ljiyeon
                                if (currentControl != null)
3226
                                {
3227
                                    (currentControl as ArrowArcControl).setClock();
3228
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3229
                                    //(currentControl as ArcControl).ApplyTemplate();
3230
                                }
3231 787a4489 KangIngu
                            }
3232
                        }
3233
                        break;
3234
                    case ControlType.ArrowMultiLine:
3235
                        {
3236 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3237 787a4489 KangIngu
                            {
3238 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3239
                                //{
3240 787a4489 KangIngu
3241
                                    if (currentControl is ArrowControl_Multi)
3242
                                    {
3243
                                        var content = currentControl as ArrowControl_Multi;
3244
                                        if (content.MiddlePoint == new Point(0, 0))
3245
                                        {
3246 2eac4f76 KangIngu
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3247
                                            {
3248
                                                content.MiddlePoint = content.EndPoint;
3249
                                            }
3250
                                            else
3251
                                            {
3252 c7fde400 taeseongkim
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3253 2eac4f76 KangIngu
                                            }
3254 787a4489 KangIngu
                                        }
3255
                                        else
3256
                                        {
3257 ca40e004 ljiyeon
                                            //20180906 LJY TEST IsRotationDrawingEnable
3258
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3259 e66f22eb KangIngu
                                            {
3260
                                                return;
3261
                                            }
3262
3263 f513c215 humkyung
                                            CreateCommand.Instance.Execute(currentControl);
3264 787a4489 KangIngu
3265
                                            currentControl = null;
3266 168f8027 taeseongkim
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3267 787a4489 KangIngu
                                        }
3268
                                    }
3269
                                    else
3270
                                    {
3271
                                        currentControl = new ArrowControl_Multi
3272
                                        {
3273 c7fde400 taeseongkim
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3274 787a4489 KangIngu
                                            Background = new SolidColorBrush(Colors.Black)
3275
                                        };
3276 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3277 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3278
                                        currentControl.IsNew = true;
3279
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3280 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3281 787a4489 KangIngu
                                    }
3282 e66f22eb KangIngu
                                //}
3283 787a4489 KangIngu
                            }
3284
                        }
3285
                        break;
3286
                    case ControlType.PolygonCloud:
3287
                        {
3288
                            if (currentControl is CloudControl)
3289
                            {
3290
                                var control = currentControl as CloudControl;
3291 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3292 787a4489 KangIngu
                                {
3293
                                    control.IsCompleted = true;
3294
                                }
3295
3296
                                if (!control.IsCompleted)
3297
                                {
3298
                                    control.PointSet.Add(control.EndPoint);
3299
                                }
3300
                                else
3301
                                {
3302 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3303
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3304 e66f22eb KangIngu
                                    {
3305
                                        return;
3306
                                    }
3307
3308 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3309 787a4489 KangIngu
3310
                                    control.isTransOn = true;
3311
                                    var firstPoint = control.PointSet.First();
3312
3313
                                    control.PointSet.Add(firstPoint);
3314
                                    control.DrawingCloud();
3315
                                    control.ApplyOverViewData();
3316
3317
                                    currentControl = null;
3318
                                }
3319
                            }
3320
                            else
3321
                            {
3322 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3323 787a4489 KangIngu
                                {
3324
                                    currentControl = new CloudControl
3325
                                    {
3326
                                        PointSet = new List<Point>(),
3327
                                        PointC = new StylusPointSet()
3328
                                    };
3329
3330 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3331
                                    //{
3332 787a4489 KangIngu
                                        var polygonControl = (currentControl as CloudControl);
3333 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3334 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3335
                                        currentControl.IsNew = true;
3336
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3337
3338 c7fde400 taeseongkim
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3339
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3340 b9ce7aee ljiyeon
                                    
3341 e66f22eb KangIngu
                                    //}
3342 787a4489 KangIngu
                                }
3343
                            }
3344
                        }
3345
                        break;
3346
                    case ControlType.ImgControl:
3347
                        {
3348 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3349 787a4489 KangIngu
                            {
3350 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3351
                                //{
3352 787a4489 KangIngu
                                    if (currentControl is ImgControl)
3353
                                    {
3354 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3355
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3356 e66f22eb KangIngu
                                        {
3357
                                            return;
3358
                                        }
3359
3360 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3361 53880c83 ljiyeon
                                        controlType = ControlType.ImgControl;
3362 787a4489 KangIngu
                                        currentControl = null;
3363
                                    }
3364
                                    else
3365
                                    {
3366 c73426a9 ljiyeon
                                        
3367 787a4489 KangIngu
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3368 53880c83 ljiyeon
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3369 787a4489 KangIngu
                                        {
3370
                                            Image img = new Image();
3371 53880c83 ljiyeon
                                            if (filename.Contains(".svg"))
3372
                                            {
3373
                                                byte[] imageData = null;
3374
                                                DrawingImage image = null;
3375
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3376
                                                {
3377
                                                    imageData = web.DownloadData(new Uri(filename));
3378
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3379
                                                    image = SvgReader.Load(stream);
3380
                                                }
3381
                                                img.Source = image;
3382
                                            }
3383
                                            else
3384
                                            {
3385
                                                img.Source = new BitmapImage(new Uri(filename));
3386
                                            }
3387 787a4489 KangIngu
3388
                                            currentControl = new ImgControl
3389
                                            {
3390 53880c83 ljiyeon
                                                    Background = new SolidColorBrush(Colors.Black),
3391
                                                    PointSet = new List<Point>(),
3392
                                                    FilePath = filename,
3393
                                                    ImageData = img.Source,
3394 c7fde400 taeseongkim
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3395
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3396
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3397
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3398 53880c83 ljiyeon
                                                    ControlType = ControlType.ImgControl
3399
                                                };
3400
3401
                                        
3402 24678e06 humkyung
                                                currentControl.CommentID = Commons.shortGuid();                                            
3403 53880c83 ljiyeon
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3404
                                                currentControl.IsNew = true;
3405
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3406
3407 fa48eb85 taeseongkim
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3408
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3409
                                    }
3410 787a4489 KangIngu
                                    }
3411 e66f22eb KangIngu
                                //}
3412 787a4489 KangIngu
                            }
3413
                        }
3414
                        break;
3415
                    case ControlType.Date:
3416
                        {
3417 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3418 787a4489 KangIngu
                            {
3419 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3420
                                //{
3421 6b6e937c taeseongkim
                                if (currentControl is DateControl)
3422
                                {
3423
                                    //20180906 LJY TEST IsRotationDrawingEnable
3424
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3425 787a4489 KangIngu
                                    {
3426 6b6e937c taeseongkim
                                        return;
3427
                                    }
3428 e66f22eb KangIngu
3429 6b6e937c taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
3430
                                    currentControl = null;
3431 787a4489 KangIngu
3432 6b6e937c taeseongkim
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3433
                                    {
3434
                                        controlType = ControlType.None;
3435
                                        IsSwingMode = false;
3436
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3437
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3438
                                        mouseHandlingMode = MouseHandlingMode.None;
3439
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3440
                                        txtBatch.Visibility = Visibility.Collapsed;
3441 787a4489 KangIngu
3442
                                    }
3443 6b6e937c taeseongkim
                                }
3444
                                else
3445
                                {
3446
                                    currentControl = new DateControl
3447 787a4489 KangIngu
                                    {
3448 6b6e937c taeseongkim
                                        StartPoint = CanvasDrawingMouseDownPoint,
3449
                                        Background = new SolidColorBrush(Colors.Black)
3450
                                    };
3451
                                    currentControl.CommentID = Commons.shortGuid();
3452
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3453
                                    currentControl.IsNew = true;
3454
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3455 ca40e004 ljiyeon
3456 6b6e937c taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3457
                                    if (currentControl is ImgControl)
3458
                                    {
3459 fa48eb85 taeseongkim
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3460 6b6e937c taeseongkim
                                    }
3461 ca40e004 ljiyeon
                                }
3462 e66f22eb KangIngu
                                //}
3463 787a4489 KangIngu
                            }
3464
                        }
3465
                        break;
3466
                    case ControlType.TextControl:
3467
                        {
3468 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3469 787a4489 KangIngu
                            {
3470
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3471
                                {
3472
                                    currentControl = new TextControl
3473
                                    {
3474
                                        ControlType = controlType
3475
                                    };
3476 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3477 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3478 8742caa5 humkyung
                                    currentControl.IsNew = true;
3479
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3480
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3481 1066bae3 ljiyeon
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3482
3483 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3484
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3485 6b5d33c6 djkim
                                    
3486 8742caa5 humkyung
                                    (currentControl as TextControl).ControlType_No = 0;
3487 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3488 8742caa5 humkyung
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3489 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3490
                                    (currentControl as TextControl).Base_TextBox.Focus();
3491 55d4f382 송근호
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3492 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3493 787a4489 KangIngu
                                }
3494
                            }
3495
                        }
3496
                        break;
3497
                    case ControlType.TextBorder:
3498
                        {
3499 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3500 787a4489 KangIngu
                            {
3501
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3502
                                {
3503
                                    currentControl = new TextControl
3504
                                    {
3505
                                        ControlType = controlType
3506
                                    };
3507
3508 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3509 787a4489 KangIngu
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3510 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3511 787a4489 KangIngu
                                    currentControl.IsNew = true;
3512
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3513
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3514 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3515
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3516 6b5d33c6 djkim
                                    
3517 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 1;
3518 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3519 787a4489 KangIngu
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3520 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3521
                                    (currentControl as TextControl).Base_TextBox.Focus();
3522 55d4f382 송근호
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3523 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3524 787a4489 KangIngu
                                }
3525
                            }
3526
                        }
3527
                        break;
3528
                    case ControlType.TextCloud:
3529
                        {
3530 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3531 787a4489 KangIngu
                            {
3532
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3533
                                {
3534
                                    currentControl = new TextControl
3535
                                    {
3536
                                        ControlType = controlType
3537
                                    };
3538 610a4b86 KangIngu
3539
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3540 24678e06 humkyung
                                    currentControl.CommentID = Commons.shortGuid();
3541 787a4489 KangIngu
                                    currentControl.IsNew = true;
3542
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3543
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3544
3545
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3546 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3547
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3548 787a4489 KangIngu
3549 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3550 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 2;
3551
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3552 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3553
                                    (currentControl as TextControl).Base_TextBox.Focus();
3554 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3555 55d4f382 송근호
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3556 49b217ad humkyung
                                    //currentControl = null;
3557 787a4489 KangIngu
                                }
3558
                            }
3559
                        }
3560
                        break;
3561
                    case ControlType.ArrowTextControl:
3562 ca40e004 ljiyeon
                         {
3563 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3564 787a4489 KangIngu
                            {
3565
                                if (currentControl is ArrowTextControl)
3566
                                {
3567 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3568
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3569 e66f22eb KangIngu
                                    {
3570
                                        return;
3571 f513c215 humkyung
                                    }
3572 e66f22eb KangIngu
3573 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3574 787a4489 KangIngu
3575
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3576
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3577 49b217ad humkyung
                                    (currentControl as ArrowTextControl).IsNew = false;
3578 787a4489 KangIngu
                                    currentControl = null;
3579
                                }
3580
                                else
3581
                                {
3582 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3583
                                    //{
3584 787a4489 KangIngu
                                        currentControl = new ArrowTextControl();
3585 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3586 787a4489 KangIngu
                                        currentControl.IsNew = true;
3587
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3588
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3589
3590
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3591 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3592
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3593 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3594 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3595
3596 fa48eb85 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3597
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3598 787a4489 KangIngu
3599 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3600 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3601 55d4f382 송근호
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3602 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3603 ca40e004 ljiyeon
3604
                                    
3605 e66f22eb KangIngu
                                    //}
3606 787a4489 KangIngu
                                }
3607
                            }
3608
                        }
3609
                        break;
3610
                    case ControlType.ArrowTransTextControl:
3611
                        {
3612 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3613 787a4489 KangIngu
                            {
3614
                                if (currentControl is ArrowTextControl)
3615
                                {
3616 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3617
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3618 e66f22eb KangIngu
                                    {
3619
                                        return;
3620 f513c215 humkyung
                                    }
3621 e66f22eb KangIngu
3622 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3623 55d4f382 송근호
3624 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3625 55d4f382 송근호
                                    
3626 49b217ad humkyung
                                    currentControl.IsNew = false;
3627 787a4489 KangIngu
                                    currentControl = null;
3628 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3629 787a4489 KangIngu
                                }
3630
                                else
3631
                                {
3632 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3633
                                    //{
3634 120b8b00 송근호
                                    currentControl = new ArrowTextControl()
3635
                                    {
3636
                                        ControlType = ControlType.ArrowTransTextControl
3637
                                    };
3638
                                    currentControl.CommentID = Commons.shortGuid();
3639
                                    currentControl.IsNew = true;
3640
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3641
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3642
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3643 c7fde400 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3644
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3645 120b8b00 송근호
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3646
                                    (currentControl as ArrowTextControl).isFixed = true;
3647
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3648 787a4489 KangIngu
3649 120b8b00 송근호
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3650 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3651 ca40e004 ljiyeon
3652 120b8b00 송근호
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3653
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3654
                                    (currentControl as ArrowTextControl).isTrans = true;
3655 55d4f382 송근호
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3656 787a4489 KangIngu
                                }
3657
                            }
3658
                        }
3659
                        break;
3660
                    case ControlType.ArrowTextBorderControl:
3661 ca40e004 ljiyeon
                         {
3662 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3663 787a4489 KangIngu
                            {
3664
                                if (currentControl is ArrowTextControl)
3665
                                {
3666 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3667
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3668 e66f22eb KangIngu
                                    {
3669
                                        return;
3670
                                    }
3671
3672 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3673 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3674 49b217ad humkyung
                                    currentControl.IsNew = false;
3675 787a4489 KangIngu
                                    currentControl = null;
3676 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3677 787a4489 KangIngu
                                }
3678
                                else
3679
                                {
3680 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3681
                                    //{
3682 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3683
                                        {
3684
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3685
                                        };
3686 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3687 787a4489 KangIngu
                                        currentControl.IsNew = true;
3688
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3689
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3690
3691
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3692
3693 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3694 787a4489 KangIngu
3695 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3696 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3697 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3698 55d4f382 송근호
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3699 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3700 fa48eb85 taeseongkim
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3701 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3702 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3703 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3704 e66f22eb KangIngu
                                    //}
3705 787a4489 KangIngu
                                }
3706
                            }
3707
                        }
3708
                        break;
3709
                    case ControlType.ArrowTransTextBorderControl:
3710
                        {
3711 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3712 787a4489 KangIngu
                            {
3713
                                if (currentControl is ArrowTextControl)
3714
                                {
3715 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3716
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3717 e66f22eb KangIngu
                                    {
3718
                                        return;
3719
                                    }
3720 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3721 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3722 49b217ad humkyung
                                    currentControl.IsNew = false;
3723 787a4489 KangIngu
                                    currentControl = null;
3724 55d4f382 송근호
3725 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3726 787a4489 KangIngu
                                }
3727
                                else
3728
                                {
3729 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3730
                                    //{
3731 ca40e004 ljiyeon
                                    
3732
3733
                                    currentControl = new ArrowTextControl()
3734 120b8b00 송근호
                                    {
3735
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3736
                                        ControlType = ControlType.ArrowTransTextBorderControl
3737
3738
                                    };
3739 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3740 787a4489 KangIngu
                                        currentControl.IsNew = true;
3741
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3742
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3743
3744
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3745
3746 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3747
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3748 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3749 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3750
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3751 ca40e004 ljiyeon
                                     
3752
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3753 fa48eb85 taeseongkim
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3754 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3755 55d4f382 송근호
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3756 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3757 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3758 ca40e004 ljiyeon
                                    
3759
                                    //20180911 LJY
3760
                                        (currentControl as ArrowTextControl).isTrans = true;
3761
                                    
3762
3763 e66f22eb KangIngu
                                    //}
3764 787a4489 KangIngu
                                }
3765
                            }
3766
                        }
3767
                        break;
3768
                    case ControlType.ArrowTextCloudControl:
3769
                        {
3770 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3771 787a4489 KangIngu
                            {
3772
                                if (currentControl is ArrowTextControl)
3773
                                {
3774 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3775
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3776 e66f22eb KangIngu
                                    {
3777
                                        return;
3778
                                    }
3779 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3780 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3781 49b217ad humkyung
                                    currentControl.IsNew = false;
3782 787a4489 KangIngu
                                    currentControl = null;
3783 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3784 787a4489 KangIngu
                                }
3785
                                else
3786
                                {
3787 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3788
                                    //{
3789 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3790
                                        {
3791
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3792
                                        };
3793 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3794 787a4489 KangIngu
                                        currentControl.IsNew = true;
3795
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3796
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3797
3798
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3799 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3800
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
3801 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3802 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3803 55d4f382 송근호
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3804 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3805 fa48eb85 taeseongkim
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3806 ca40e004 ljiyeon
                                    
3807
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3808 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3809 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3810 e66f22eb KangIngu
                                    //}
3811 787a4489 KangIngu
                                }
3812
                            }
3813
                        }
3814
                        break;
3815
                    case ControlType.ArrowTransTextCloudControl:
3816
                        {
3817 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3818 787a4489 KangIngu
                            {
3819
                                if (currentControl is ArrowTextControl)
3820
                                {
3821 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3822
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3823 e66f22eb KangIngu
                                    {
3824
                                        return;
3825
                                    }
3826 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3827 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3828 49b217ad humkyung
                                    currentControl.IsNew = false;
3829 787a4489 KangIngu
                                    currentControl = null;
3830 168f8027 taeseongkim
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3831 787a4489 KangIngu
                                }
3832
                                else
3833
                                {
3834 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3835
                                    //{
3836 787a4489 KangIngu
                                        currentControl = new ArrowTextControl()
3837
                                        {
3838 120b8b00 송근호
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3839
                                            ControlType = ControlType.ArrowTransTextCloudControl
3840
3841 787a4489 KangIngu
                                        };
3842 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3843 ca40e004 ljiyeon
                                        currentControl.IsNew = true; 
3844 787a4489 KangIngu
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3845
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3846
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3847
3848 c7fde400 taeseongkim
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3849
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3850 610a4b86 KangIngu
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3851 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).isFixed = true;
3852
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3853
3854 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3855 fa48eb85 taeseongkim
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3856 55d4f382 송근호
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3857 ca40e004 ljiyeon
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3858 787a4489 KangIngu
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3859 168f8027 taeseongkim
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3860 ca40e004 ljiyeon
                                    
3861
                                    //20180911 LJY
3862
                                        (currentControl as ArrowTextControl).isTrans = true;
3863 e66f22eb KangIngu
                                    //}
3864 787a4489 KangIngu
                                }
3865
                            }
3866
                        }
3867
                        break;
3868
                    //강인구 추가
3869
                    case ControlType.Sign:
3870
                        {
3871 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3872 787a4489 KangIngu
                            {
3873 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3874
                                //{
3875 d7e20d2d taeseongkim
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
3876 992a98b4 KangIngu
3877 d7e20d2d taeseongkim
                                if (_sign == null)
3878 992a98b4 KangIngu
                                    {
3879
                                        txtBatch.Visibility = Visibility.Collapsed;
3880
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3881
                                        controlType = ControlType.None;
3882
3883
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3884
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3885
                                        return;
3886
                                    }
3887
3888 787a4489 KangIngu
                                    if (currentControl is SignControl)
3889
                                    {
3890 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3891
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3892 e66f22eb KangIngu
                                        {
3893
                                            return;
3894
                                        }
3895
3896 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3897 787a4489 KangIngu
                                        currentControl = null;
3898
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3899
                                        {
3900 999c9e40 humkyung
                                            txtBatch.Text = "Place Date";
3901 787a4489 KangIngu
                                            controlType = ControlType.Date;
3902
                                        }
3903
                                    }
3904
                                    else
3905
                                    {
3906
                                        currentControl = new SignControl
3907
                                        {
3908
                                            Background = new SolidColorBrush(Colors.Black),
3909
                                            UserNumber = App.ViewInfo.UserID,
3910 a6272c57 humkyung
                                            ProjectNO = App.ViewInfo.ProjectNO,
3911 c7fde400 taeseongkim
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3912
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3913 787a4489 KangIngu
                                            ControlType = ControlType.Sign
3914
                                        };
3915
3916 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3917 787a4489 KangIngu
                                        currentControl.IsNew = true;
3918
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3919
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3920 ca40e004 ljiyeon
3921
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3922 fa48eb85 taeseongkim
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3923 ca40e004 ljiyeon
                                }
3924 e66f22eb KangIngu
                                //}
3925 787a4489 KangIngu
                            }
3926
                        }
3927
                        break;
3928
                    case ControlType.Mark:
3929
                        {
3930 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3931 787a4489 KangIngu
                            {
3932 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3933
                                //{
3934 787a4489 KangIngu
                                    if (currentControl is RectangleControl)
3935
                                    {
3936 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3937
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3938 e66f22eb KangIngu
                                        {
3939
                                            return;
3940
                                        }
3941
3942 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3943 787a4489 KangIngu
                                        (currentControl as RectangleControl).ApplyOverViewData();
3944
                                        currentControl = null;
3945 510cbd2a ljiyeon
                                    
3946
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3947 787a4489 KangIngu
3948
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3949
                                        {
3950 999c9e40 humkyung
                                            txtBatch.Text = "Place Signature";
3951 787a4489 KangIngu
                                            controlType = ControlType.Sign;
3952
                                        }
3953
                                    }
3954
                                    else
3955
                                    {
3956
                                        currentControl = new RectangleControl
3957
                                        {
3958 c7fde400 taeseongkim
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3959 787a4489 KangIngu
                                            Background = new SolidColorBrush(Colors.Black),
3960 a6272c57 humkyung
                                            ControlType = ControlType.Mark ,
3961 787a4489 KangIngu
                                            Paint = PaintSet.Fill
3962
                                        };
3963
3964
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3965 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
3966 787a4489 KangIngu
                                        currentControl.IsNew = true;
3967
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3968
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3969
                                    }
3970 e66f22eb KangIngu
                                //}
3971 787a4489 KangIngu
                            }
3972
                        }
3973
                        break;
3974
                    case ControlType.Symbol:
3975
                        {
3976 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3977 787a4489 KangIngu
                            {
3978 a6272c57 humkyung
                                if (currentControl is SymControl)
3979
                                {
3980
                                    //20180906 LJY TEST IsRotationDrawingEnable
3981
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3982 787a4489 KangIngu
                                    {
3983 a6272c57 humkyung
                                        return;
3984 787a4489 KangIngu
                                    }
3985 a6272c57 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3986
                                    currentControl = null;
3987
                                
3988
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3989
                                }
3990
                                else
3991
                                {
3992
                                    currentControl = new SymControl
3993 787a4489 KangIngu
                                    {
3994 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3995 a6272c57 humkyung
                                        Background = new SolidColorBrush(Colors.Black),
3996
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3997
                                        ControlType = ControlType.Symbol
3998
                                    };
3999 787a4489 KangIngu
4000 a6272c57 humkyung
                                    currentControl.IsNew = true;
4001
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4002
                                    currentControl.CommentID = Commons.shortGuid();
4003
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4004 ca40e004 ljiyeon
4005 a6272c57 humkyung
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4006 fa48eb85 taeseongkim
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4007 ca40e004 ljiyeon
                                }
4008 e66f22eb KangIngu
                                //}
4009 787a4489 KangIngu
                            }
4010
                        }
4011
                        break;
4012
                    case ControlType.Stamp:
4013
                        {
4014 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4015 787a4489 KangIngu
                            {
4016 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4017
                                //{
4018 787a4489 KangIngu
                                    if (currentControl is SymControlN)
4019
                                    {
4020 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
4021
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4022 e66f22eb KangIngu
                                        {
4023
                                            return;
4024
                                        }
4025
4026 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
4027 787a4489 KangIngu
                                        currentControl = null;
4028 510cbd2a ljiyeon
                                   
4029
4030
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4031 787a4489 KangIngu
                                    }
4032
                                    else
4033
                                    {
4034
                                        currentControl = new SymControlN
4035
                                        {
4036 c7fde400 taeseongkim
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4037 787a4489 KangIngu
                                            Background = new SolidColorBrush(Colors.Black),
4038 cd988cd8 djkim
                                            STAMP = App.SystemInfo.STAMP,                                            
4039 787a4489 KangIngu
                                            ControlType = ControlType.Stamp
4040
                                        };
4041
4042
                                        currentControl.IsNew = true;
4043
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4044 24678e06 humkyung
                                        currentControl.CommentID = Commons.shortGuid();
4045 787a4489 KangIngu
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4046 ca40e004 ljiyeon
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4047 fa48eb85 taeseongkim
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4048 ca40e004 ljiyeon
                                }                                    
4049 e66f22eb KangIngu
                                //}
4050 787a4489 KangIngu
                            }
4051
                        }
4052
                        break;
4053
                    case ControlType.PenControl:
4054
                        {
4055
                            if (inkBoard.Tag.ToString() == "Ink")
4056
                            {
4057
                                inkBoard.IsEnabled = true;
4058 c7fde400 taeseongkim
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4059 787a4489 KangIngu
                            }
4060
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4061
                            {
4062 c7fde400 taeseongkim
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4063 787a4489 KangIngu
                            }
4064
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4065
                            {
4066 c7fde400 taeseongkim
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4067 787a4489 KangIngu
                            }
4068
                            IsDrawing = true;
4069
                            return;
4070
                        }
4071
                    default:
4072
                        if (currentControl != null)
4073
                        {
4074
                            currentControl.CommentID = null;
4075
                            currentControl.IsNew = false;
4076
                        }
4077
                        break;
4078
                }
4079 fa48eb85 taeseongkim
4080
                if (currentControl != null)
4081
                {
4082
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4083
                }
4084 787a4489 KangIngu
            }
4085 e6a9ddaf humkyung
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4086 787a4489 KangIngu
            {
4087
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4088
                {
4089
                    bool mouseOff = false;
4090
                    foreach (var item in SelectLayer.Children)
4091
                    {
4092
                        if (item is AdornerFinal)
4093
                        {
4094
4095 4913851c humkyung
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4096 787a4489 KangIngu
                            if (over != null)
4097
                            {
4098
                                mouseOff = true;
4099
                            }
4100
                        }
4101
                    }
4102
4103
                    if (!mouseOff)
4104
                    {
4105 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
4106 787a4489 KangIngu
                    }
4107
                }
4108
                zoomAndPanControl.CaptureMouse();
4109
                e.Handled = true;
4110
            }
4111 5d55f6fb ljiyeon
          
4112 787a4489 KangIngu
        }
4113 e54660e8 KangIngu
4114 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4115
        {
4116 e6a9ddaf humkyung
            ///mouseButtonDown = e.ChangedButton;
4117 a1716fa5 KangIngu
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4118
        }
4119
4120 787a4489 KangIngu
        private void RemoveLineStroke(Point P)
4121
        {
4122 05009a0e ljiyeon
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4123 787a4489 KangIngu
            if (control != null)
4124
            {
4125 f729ef4e humkyung
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4126 787a4489 KangIngu
            }
4127
        }
4128
4129
        private void RemovePointStroke(Point P)
4130
        {
4131
            foreach (Stroke hits in inkBoard.Strokes)
4132
            {
4133
                foreach (StylusPoint sty in hits.StylusPoints)
4134
                {
4135
4136
                }
4137
                if (hits.HitTest(P))
4138
                {
4139
                    inkBoard.Strokes.Remove(hits);
4140
                    return;
4141
                }
4142
            }
4143
        }
4144
4145
        private void StartNewStroke(Point P)
4146
        {
4147
            strokePoints = new StylusPointCollection();
4148
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4149
            strokePoints.Add(segment1Start);
4150
            stroke = new Stroke(strokePoints);
4151
4152
            stroke.DrawingAttributes.Color = Colors.Red;
4153
            stroke.DrawingAttributes.Width = 4;
4154
            stroke.DrawingAttributes.Height = 4;
4155
4156
            inkBoard.Strokes.Add(stroke);
4157
        }
4158
4159
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4160
        {
4161
            ConsolidationMethod();
4162
        }
4163
4164 102476f6 humkyung
        /// <summary>
4165
        /// execute TeamConsolidationCommand
4166
        /// </summary>
4167 04a7385a djkim
        public void TeamConsolidationMethod()
4168
        {
4169 102476f6 humkyung
            this.UpdateMyMarkupList();
4170 04a7385a djkim
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4171
            {
4172
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4173
            }
4174
            else
4175
            {
4176 8129f2a5 ljiyeon
4177
                ViewerDataModel.Instance.IsConsolidate = true;
4178
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4179
4180 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4181
                {
4182
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4183
                    {
4184
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4185
                        return;
4186
                    }                    
4187
                }
4188 102476f6 humkyung
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4189 04a7385a djkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4190 90e7968d ljiyeon
                {
4191 102476f6 humkyung
                    MarkupInfoList.Add(item);
4192 04a7385a djkim
                }
4193 102476f6 humkyung
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4194 04a7385a djkim
            }
4195
        }
4196 102476f6 humkyung
4197 787a4489 KangIngu
        public void ConsolidationMethod()
4198
        {
4199
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4200
            {
4201
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4202
            }
4203
            else
4204 90e7968d ljiyeon
            {
4205 35a96e24 humkyung
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4206
                foreach (var item in this.gridViewMarkup.SelectedItems)
4207
                {
4208
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4209
                }
4210
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4211 8129f2a5 ljiyeon
                
4212 35a96e24 humkyung
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4213 787a4489 KangIngu
            }
4214
        }
4215
4216
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4217
        {
4218
            if (App.ViewInfo != null)
4219
            {
4220
                btnConsolidate = (sender as RadRibbonButton);
4221
                if (!App.ViewInfo.NewCommentPermission)
4222
                {
4223
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4224
                }
4225
            }
4226
        }
4227
4228
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4229
        {
4230 04a7385a djkim
            TeamConsolidationMethod();
4231 787a4489 KangIngu
        }
4232
4233
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4234
        {
4235
            btnTeamConsolidate = sender as RadRibbonButton;
4236
            if (App.ViewInfo != null)
4237
            {
4238
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4239
                {
4240
                    if (btnConsolidate != null)
4241
                    {
4242
                        btnConsolidate.Visibility = Visibility.Collapsed;
4243
                    }
4244
4245
                    if (!App.ViewInfo.NewCommentPermission)
4246
                    {
4247
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4248
                    }
4249
                }
4250
                else
4251
                {
4252
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4253
                }
4254
            }
4255
        }
4256
4257
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4258
        {
4259 3b62305d ljiyeon
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4260 056e4dfd djkim
            if(item != null)
4261 787a4489 KangIngu
            {
4262 056e4dfd djkim
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4263 81e3c9f6 ljiyeon
                {
4264
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4265
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4266
                }
4267
                else
4268
                {
4269 056e4dfd djkim
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4270 81e3c9f6 ljiyeon
                }
4271 056e4dfd djkim
            }else{
4272
                //Consolidate 가 없는 경우
4273
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4274 787a4489 KangIngu
            }
4275 056e4dfd djkim
            
4276 787a4489 KangIngu
        }
4277
4278
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4279
        {
4280
            btnFinalPDF = sender as RadRibbonButton;
4281
            if (App.ViewInfo != null)
4282
            {
4283
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4284
                {
4285
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4286
                    if (btnConsolidate != null)
4287
                    {
4288
                        btnConsolidate.Visibility = Visibility.Collapsed;
4289
                    }
4290
                }
4291
            }
4292
        }
4293
4294 80458c15 ljiyeon
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4295
        {
4296 d62c0439 humkyung
            UpdateMyMarkupList();
4297 80458c15 ljiyeon
4298
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4299
            {
4300
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4301
            }
4302
            else
4303
            {
4304
                ViewerDataModel.Instance.IsConsolidate = true;
4305
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4306
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4307
4308
                string project_no = App.ViewInfo.ProjectNO;
4309
                string doc_id = _DocInfo.ID;
4310
                string user_id = App.ViewInfo.UserID;
4311
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4312
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4313
                {
4314
                    markupInfoItems.Add(item);
4315
                }
4316
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4317
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4318
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4319 1126281e djkim
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4320 80458c15 ljiyeon
4321 1126281e djkim
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4322 80458c15 ljiyeon
                if (item2 != null)
4323
                {
4324
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4325
4326
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4327 1126281e djkim
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4328 80458c15 ljiyeon
                }
4329
                else
4330
                {
4331
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4332
                }
4333 90e7968d ljiyeon
            }
4334 80458c15 ljiyeon
        }
4335
4336
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4337 90e7968d ljiyeon
        {
4338 80458c15 ljiyeon
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4339 84605c0c taeseongkim
#if Hyosung
4340
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4341
#else
4342 80458c15 ljiyeon
            if (App.ViewInfo != null)
4343
            {
4344
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4345
                {
4346 90e7968d ljiyeon
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4347 80458c15 ljiyeon
                }
4348 90e7968d ljiyeon
            }
4349 84605c0c taeseongkim
#endif
4350 80458c15 ljiyeon
        }
4351
4352 787a4489 KangIngu
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4353
        {
4354 adce8360 humkyung
            SetCompareRect();
4355 787a4489 KangIngu
        }
4356
4357 9cd2865b KangIngu
        private void Sync_Click(object sender, RoutedEventArgs e)
4358
        {
4359 a1716fa5 KangIngu
            if (Sync.IsChecked)
4360 9cd2865b KangIngu
            {
4361
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4362
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4363
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4364
            }
4365
        }
4366
4367 787a4489 KangIngu
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4368
        {
4369
            if (UserList.IsChecked)
4370
            {
4371
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4372
            }
4373
            else
4374
            {
4375
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4376
            }
4377
        }
4378
4379
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4380
        {
4381
4382
            if (BalanceMode.IsChecked)
4383
            {
4384
                ViewerDataModel.Instance.PageBalanceMode = true;
4385
            }
4386
            else
4387
            {
4388
                ViewerDataModel.Instance.PageBalanceMode = false;
4389
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4390
            }
4391
        }
4392
4393
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4394
        {
4395
            //초기화
4396
            testPanel2.IsHidden = true;
4397
            ViewerDataModel.Instance.PageBalanceMode = false;
4398
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4399
            ViewerDataModel.Instance.PageNumber = 0;
4400
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4401
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4402
            UserList.IsChecked = false;
4403
            BalanceMode.IsChecked = false;
4404
        }
4405
4406 ac4f1e13 taeseongkim
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4407 787a4489 KangIngu
        {
4408
            if ((sender as System.Windows.Controls.Control).Tag != null)
4409
            {
4410
                //Compare 초기화
4411
                CompareMode.IsChecked = false;
4412
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4413
4414
                if (ViewerDataModel.Instance.PageNumber == 0)
4415
                {
4416
                    ViewerDataModel.Instance.PageNumber = 1;
4417
                }
4418
4419
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4420
                {
4421
                }
4422
                else
4423
                {
4424
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4425
                }
4426
4427 6b6e937c taeseongkim
4428
4429 787a4489 KangIngu
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4430
                {
4431
4432
                }
4433
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4434
                {
4435
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4436
                }
4437
4438 d04e8ee9 taeseongkim
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4439 6b6e937c taeseongkim
4440 787a4489 KangIngu
                if (!testPanel2.IsHidden)
4441
                {
4442
                    if (IsSyncPDFMode)
4443
                    {
4444
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4445
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4446
4447
                        if (pdfpath.IsDownloading)
4448
                        {
4449
                            pdfpath.DownloadCompleted += (ex, arg) =>
4450
                            {
4451
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4452
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4453
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4454
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4455
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4456
                            };
4457
                        }
4458
                        else
4459
                        {
4460
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4461
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4462
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4463
4464
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4465
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4466
                        }
4467
4468
                    }
4469
                    else
4470
                    {
4471 6b6e937c taeseongkim
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4472 787a4489 KangIngu
4473
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4474
4475
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4476
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4477
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4478
4479
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4480
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4481
4482
                        if (defaultBitmapImage_Compare.IsDownloading)
4483
                        {
4484
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4485
                            {
4486
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4487
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4488
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4489
4490
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4491
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4492
                            };
4493
                        }
4494
                    }
4495
4496
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4497
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4498
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4499
4500
                    foreach (var item in gridSelectionRevItem)
4501
                    {
4502 ac4f1e13 taeseongkim
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4503
                        foreach (var markupitem in markupitems)
4504 787a4489 KangIngu
                        {
4505 ac4f1e13 taeseongkim
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4506
                        }
4507 787a4489 KangIngu
                    }
4508 e54660e8 KangIngu
4509 787a4489 KangIngu
                    //강인구 추가
4510
                    zoomAndPanControl2.ZoomTo(new Rect
4511
                    {
4512
                        X = 0,
4513
                        Y = 0,
4514
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4515
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4516
                    });
4517 ae56d52d KangIngu
4518 787a4489 KangIngu
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4519
4520
                }
4521
            }
4522
        }
4523
4524
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4525
        {
4526
            if (MarkupMode.IsChecked)
4527
            {
4528
                IsSyncPDFMode = true;
4529
4530
                var uri = CurrentRev.TO_VENDOR;
4531 ae56d52d KangIngu
4532 787a4489 KangIngu
                if (ViewerDataModel.Instance.PageNumber == 0)
4533
                {
4534
                    ViewerDataModel.Instance.PageNumber = 1;
4535
                }
4536
4537
                //PDF모드 잠시 대기(강인구)
4538
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4539
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4540
4541
                if (pdfpath.IsDownloading)
4542
                {
4543
                    pdfpath.DownloadCompleted += (ex, arg) =>
4544
                    {
4545
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4546
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4547
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4548
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4549
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4550
                    };
4551
                }
4552
                else
4553
                {
4554
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4555
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4556
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4557
4558
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4559
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4560
                }
4561
            }
4562
            else
4563
            {
4564
                IsSyncPDFMode = false;
4565 69f41aab humkyung
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4566 787a4489 KangIngu
4567
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4568
4569
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4570
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4571
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4572
4573
                if (defaultBitmapImage_Compare.IsDownloading)
4574
                {
4575
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4576
                    {
4577
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4578
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4579
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4580
                    };
4581
                }
4582
                zoomAndPanControl2.ApplyTemplate();
4583
                zoomAndPanControl2.UpdateLayout();
4584
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4585
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4586
            }
4587
        }
4588
4589 adce8360 humkyung
        /// <summary>
4590
        /// Compare된 영역을 초기화
4591
        /// </summary>
4592
        private void ClearCompareRect()
4593
        {
4594
            da.From = 1;
4595
            da.To = 1;
4596
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4597
            da.AutoReverse = false;
4598
            canvas_compareBorder.Children.Clear();
4599
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4600
        }
4601
4602
        /// <summary>
4603
        /// 문서 Comprare 
4604
        /// </summary>
4605
        private void SetCompareRect()
4606
        {
4607
            if (CompareMode.IsChecked)
4608
            {
4609
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4610
                {
4611
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4612
                }
4613
                if (ViewerDataModel.Instance.PageNumber == 0)
4614
                {
4615
                    ViewerDataModel.Instance.PageNumber = 1;
4616
                }
4617
4618
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4619
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4620
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4621
4622
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4623
            }
4624
            else
4625
            {
4626
                ClearCompareRect();
4627
            }
4628
        }
4629
4630 787a4489 KangIngu
        private void RadButton_Click(object sender, RoutedEventArgs e)
4631
        {
4632
            gridViewHistory_Busy.IsBusy = true;
4633
4634
            RadButton instance = sender as RadButton;
4635
            if (instance.CommandParameter != null)
4636
            {
4637
                CurrentRev = instance.CommandParameter as VPRevision;
4638 adce8360 humkyung
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4639
4640
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4641 787a4489 KangIngu
                {
4642
                    if (ea.Error == null && ea.Result != null)
4643
                    {
4644
                        testPanel2.IsHidden = false;
4645
4646 d128ceb2 humkyung
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4647
                        foreach(var info in ea.Result)
4648
                        {
4649
                            if(info.UserID == App.ViewInfo.UserID)
4650
                            {
4651
                                info.userDelete = true;
4652
                                info.DisplayColor = "FFFF0000";
4653
                            }
4654
                            else
4655
                            {
4656
                                info.userDelete = false;
4657
                            }
4658
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4659
                        }
4660 787a4489 KangIngu
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4661
4662 69f41aab humkyung
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4663 787a4489 KangIngu
4664
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4665
4666 adce8360 humkyung
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4667
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4668
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4669
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4670
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4671
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4672 787a4489 KangIngu
4673
                        zoomAndPanControl2.ApplyTemplate();
4674
                        zoomAndPanControl2.UpdateLayout();
4675
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4676
                        {
4677
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4678
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4679
                        }
4680
4681 9cd2865b KangIngu
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4682
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4683
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4684
4685 787a4489 KangIngu
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4686
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4687
                        gridViewHistory_Busy.IsBusy = false;
4688
                    }
4689 0f065e57 ljiyeon
4690
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4691 adce8360 humkyung
4692
                    if (GetSyncMarkupInfoItemshandler != null)
4693
                    {
4694
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4695
                    }
4696
4697
                    ClearCompareRect();
4698
                    SetCompareRect();
4699 90e7968d ljiyeon
                };
4700 adce8360 humkyung
4701
                /// 중복 실행이 발생하여 수정함.
4702
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4703 787a4489 KangIngu
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4704 adce8360 humkyung
4705 0f065e57 ljiyeon
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4706 787a4489 KangIngu
            }
4707
        }
4708 4eb052e4 ljiyeon
4709 94b7c12c djkim
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4710
        {
4711
            try
4712
            {
4713
                if (sender is RadButton)
4714
                {
4715
                    if ((sender as RadButton).Tag != null)
4716
                    {
4717
                        var url = (sender as RadButton).Tag.ToString();
4718
                        System.Diagnostics.Process.Start(url);
4719
                    }
4720
                    else
4721
                    {
4722
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4723
                    }
4724
                }
4725
            }
4726
            catch (Exception ex)
4727
            {
4728
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4729
            }
4730
        }
4731 787a4489 KangIngu
4732
        public void Sync_Event(VPRevision Currnet_Rev)
4733
        {
4734
            CurrentRev = Currnet_Rev;
4735
4736
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4737
            {
4738
                if (ea.Error == null && ea.Result != null)
4739
                {
4740
                    testPanel2.IsHidden = false;
4741
4742 d128ceb2 humkyung
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4743
                    foreach(var info in ea.Result)
4744
                    {
4745
                        if(info.UserID == App.ViewInfo.UserID)
4746
                        {
4747
                            info.userDelete = true;
4748
                            info.DisplayColor = "FFFF0000";
4749
                        }
4750
                        else
4751
                        {
4752
                            info.userDelete = false;
4753
                        }
4754
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4755
                    }
4756 787a4489 KangIngu
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4757
4758 69f41aab humkyung
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4759 787a4489 KangIngu
4760
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4761
4762
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4763
4764
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4765
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4766
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4767
4768
                    if (defaultBitmapImage_Compare.IsDownloading)
4769
                    {
4770
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4771
                        {
4772
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4773
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4774
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4775
                        };
4776
                    }
4777 90e7968d ljiyeon
4778
4779 787a4489 KangIngu
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4780
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4781
                    zoomAndPanControl2.ApplyTemplate();
4782
                    zoomAndPanControl2.UpdateLayout();
4783
4784
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4785
                    {
4786
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4787
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4788
                    }
4789
                    //}
4790
4791
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4792
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4793 90e7968d ljiyeon
                    gridViewHistory_Busy.IsBusy = false;
4794 787a4489 KangIngu
                }
4795 0f065e57 ljiyeon
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4796 90e7968d ljiyeon
4797 787a4489 KangIngu
            };
4798 0f065e57 ljiyeon
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4799 90e7968d ljiyeon
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4800 787a4489 KangIngu
        }
4801
4802
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4803
        {
4804
            if (sender is Image)
4805
            {
4806
                if ((sender as Image).Tag != null)
4807
                {
4808
                    var pdfUrl = (sender as Image).Tag.ToString();
4809
                    System.Diagnostics.Process.Start(pdfUrl);
4810
                }
4811
                else
4812
                {
4813
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4814
                }
4815
            }
4816
        }
4817
4818
        private void Create_Symbol(object sender, RoutedEventArgs e)
4819
        {
4820 5529d2a2 humkyung
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4821 787a4489 KangIngu
4822
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4823
            {
4824
                DialogMessage_Alert("Please Select Controls", "Alert");
4825
            }
4826
            else //선택된 것이 있으면
4827
            {
4828
                string MarkupData = "";
4829
                adorner_ = new AdornerFinal();
4830
4831
                foreach (var item in SelectLayer.Children)
4832
                {
4833
                    if (item.GetType().Name == "AdornerFinal")
4834
                    {
4835
                        adorner_ = (item as Controls.AdornerFinal);
4836 4913851c humkyung
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4837 787a4489 KangIngu
                        {
4838
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4839
                            {
4840 5529d2a2 humkyung
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4841 787a4489 KangIngu
                                MarkupData += markupReturn.ConvertData;
4842
                            }
4843
                        }
4844
                    }
4845
                }
4846
                DialogParameters parameters = new DialogParameters()
4847
                {
4848 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
4849 787a4489 KangIngu
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4850
                    DefaultPromptResultValue = "Custom State",
4851
                    Content = "Name :",
4852
                    Header = "Insert Custom Symbol Name",
4853
                    Theme = new VisualStudio2013Theme(),
4854
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4855
                };
4856
                RadWindow.Prompt(parameters);
4857
            }
4858
4859
        }
4860 53880c83 ljiyeon
        public int symbolselectindex = 0;
4861
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4862
        {
4863
            //Save save = new Save();
4864
            try
4865
            {
4866
                string svgfilename = null;
4867
                if (symbolname != null)
4868
                {
4869
                    if (symbolpng == true || symbolsvg == true)
4870
                    {
4871
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4872 24678e06 humkyung
                        string guid = Commons.shortGuid();
4873 53880c83 ljiyeon
4874
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4875 c73426a9 ljiyeon
                        //Check_Uri.UriCheck();
4876 53880c83 ljiyeon
                        fileUploader.RunCompleted += (ex, arg) =>
4877
                        {
4878
                            filename = arg.Result;
4879
                            if (symbolpng == true)
4880
                            {
4881
                                if (filename != null)
4882
                                { 
4883
                                    if (symbolselectindex == 0)
4884
                                    {
4885
                                        SymbolSave(symbolname, filename, data);
4886
                                    }
4887
                                    else
4888
                                    {
4889
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4890
                                    }
4891
                                    DataBind();
4892
                                }                                
4893
                            }
4894
4895
                            if (symbolsvg == true)
4896
                            {
4897 c73426a9 ljiyeon
                                try
4898 53880c83 ljiyeon
                                {
4899 c73426a9 ljiyeon
                                    var defaultBitmapImage = new BitmapImage();
4900
                                    defaultBitmapImage.BeginInit();
4901
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4902
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4903
                                    Check_Uri.UriCheck(filename);
4904
                                    defaultBitmapImage.UriSource = new Uri(filename);
4905
                                    defaultBitmapImage.EndInit();
4906 53880c83 ljiyeon
4907 c73426a9 ljiyeon
                                    System.Drawing.Bitmap image;
4908 53880c83 ljiyeon
4909 c73426a9 ljiyeon
                                    if (defaultBitmapImage.IsDownloading)
4910
                                    {
4911
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4912 53880c83 ljiyeon
                                        {
4913 c73426a9 ljiyeon
                                            defaultBitmapImage.Freeze();
4914
                                            image = GetBitmap(defaultBitmapImage);
4915
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4916
                                            Process potrace = new Process
4917 53880c83 ljiyeon
                                            {
4918 c73426a9 ljiyeon
                                                StartInfo = new ProcessStartInfo
4919
                                                {
4920
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4921
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4922
                                                    RedirectStandardInput = true,
4923
                                                    RedirectStandardOutput = true,
4924
                                                    RedirectStandardError = true,
4925
                                                    UseShellExecute = false,
4926
                                                    CreateNoWindow = true,
4927
                                                    WindowStyle = ProcessWindowStyle.Hidden
4928
                                                },
4929
                                            };
4930 53880c83 ljiyeon
4931 c73426a9 ljiyeon
                                            StringBuilder svgBuilder = new StringBuilder();
4932
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4933 53880c83 ljiyeon
                                            {
4934 c73426a9 ljiyeon
                                                svgBuilder.AppendLine(e2.Data);
4935
                                            };
4936
4937
                                            potrace.EnableRaisingEvents = true;
4938
                                            potrace.Start();
4939
                                            potrace.Exited += (sender, e) =>
4940 53880c83 ljiyeon
                                            {
4941 c73426a9 ljiyeon
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4942
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4943
                                                Check_Uri.UriCheck(svgfilename);
4944
                                                if (symbolselectindex == 0)
4945
                                                {
4946
                                                    SymbolSave(symbolname, svgfilename, data);
4947
                                                }
4948
                                                else
4949
                                                {
4950
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4951
                                                }
4952 53880c83 ljiyeon
4953 c73426a9 ljiyeon
                                                DataBind();
4954
                                            };
4955
                                            potrace.WaitForExit();
4956 53880c83 ljiyeon
                                        };
4957 c73426a9 ljiyeon
                                    }
4958
                                    else
4959
                                    {
4960
                                        //GC.Collect();
4961
                                    }
4962 53880c83 ljiyeon
                                }
4963 c73426a9 ljiyeon
                                catch(Exception ee)
4964 90e7968d ljiyeon
                                {
4965 c73426a9 ljiyeon
                                    DialogMessage_Alert("" + ee, "Alert");
4966 90e7968d ljiyeon
                                }
4967 53880c83 ljiyeon
                            }
4968
                        };                                             
4969
                    }
4970
                }
4971
            }
4972
            catch (Exception e)
4973
            {
4974
                //DialogMessage_Alert(e + "", "Alert");
4975
            }            
4976
        }
4977
4978
        public void SymbolSave(string Name, string Url, string Data)
4979
        {
4980
            try
4981
            {
4982
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4983
                {
4984 24678e06 humkyung
                    ID = Commons.shortGuid(),
4985 53880c83 ljiyeon
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4986
                    NAME = Name,
4987
                    IMAGE_URL = Url,
4988
                    DATA = Data
4989
                };
4990
4991
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4992
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4993
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4994
            }
4995
            catch (Exception)
4996
            {
4997
                throw;
4998
            }
4999
        }
5000
5001
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5002
        {
5003
            try
5004
            {
5005
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5006
                {
5007 24678e06 humkyung
                    ID = Commons.shortGuid(),
5008 53880c83 ljiyeon
                    DEPARTMENT = Department,
5009
                    NAME = Name,
5010
                    IMAGE_URL = Url,
5011
                    DATA = Data
5012
                };
5013
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5014
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5015
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5016
            }
5017
            catch (Exception)
5018
            {
5019
                throw;
5020
            }
5021
        }
5022
5023
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5024
        {           
5025
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5026
            DataBind();
5027
        }
5028
5029
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5030
        {
5031
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5032
            DataBind();
5033
        }
5034
        private void DataBind()
5035
        {
5036
            try
5037
            {
5038
                Symbol_Custom Custom = new Symbol_Custom();
5039
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5040 5928384e djkim
                
5041 bb3a236d ljiyeon
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5042 53880c83 ljiyeon
                foreach (var item in symbol_Private)
5043
                {
5044
                    Custom.Name = item.NAME;
5045
                    Custom.ImageUri = item.IMAGE_URL;
5046
                    Custom.ID = item.ID;
5047
                    Custom_List.Add(Custom);
5048
                    Custom = new Symbol_Custom();
5049
                }
5050
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5051
                
5052
                Custom = new Symbol_Custom();
5053
                Custom_List = new List<Symbol_Custom>();
5054
5055 bb3a236d ljiyeon
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5056 53880c83 ljiyeon
5057
                List<SYMBOL_PUBLIC> symbol_Public;
5058 787a4489 KangIngu
5059 53880c83 ljiyeon
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5060
                {
5061 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5062 53880c83 ljiyeon
                }
5063
                else
5064
                {
5065 bb3a236d ljiyeon
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5066 53880c83 ljiyeon
                }
5067
                foreach (var item in symbol_Public)
5068
                {
5069
                    Custom.Name = item.NAME;
5070
                    Custom.ImageUri = item.IMAGE_URL;
5071
                    Custom.ID = item.ID;
5072
                    Custom_List.Add(Custom);
5073
                    Custom = new Symbol_Custom();
5074
                }
5075
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5076 bb3a236d ljiyeon
                BaseClient.Close();                
5077 53880c83 ljiyeon
            }
5078
            catch(Exception e)
5079
            {
5080
                //DialogMessage_Alert("DataBind", "Alert");
5081
            }
5082
            
5083
        }
5084 ac4f1e13 taeseongkim
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5085 787a4489 KangIngu
        {
5086 c73426a9 ljiyeon
            try
5087 787a4489 KangIngu
            {
5088 c73426a9 ljiyeon
                if (args.PromptResult != null)
5089 53880c83 ljiyeon
                {
5090 c73426a9 ljiyeon
                    if (args.DialogResult.Value)
5091
                    {
5092 ac4f1e13 taeseongkim
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5093 787a4489 KangIngu
5094 c73426a9 ljiyeon
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5095
                        _Encoder.Save(fs);
5096
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5097 787a4489 KangIngu
5098 c73426a9 ljiyeon
                        byte[] Img_byte = fs.ToArray();
5099 787a4489 KangIngu
5100 c73426a9 ljiyeon
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5101 24678e06 humkyung
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5102 c73426a9 ljiyeon
                        Check_Uri.UriCheck(filename);
5103
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5104
                        {
5105 de6499db humkyung
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5106 c73426a9 ljiyeon
                        }
5107
                        else
5108
                        {
5109 de6499db humkyung
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5110 c73426a9 ljiyeon
                        }
5111
                        DataBind();
5112 53880c83 ljiyeon
                    }
5113
                }
5114 787a4489 KangIngu
            }
5115 c73426a9 ljiyeon
            catch(Exception ex)
5116
            {
5117
                DialogMessage_Alert("" + ex, "Alert");
5118
            }
5119 787a4489 KangIngu
        }
5120
5121 ac4f1e13 taeseongkim
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5122 787a4489 KangIngu
        {
5123
5124
            Canvas _canvas = new Canvas();
5125
            _canvas.Background = Brushes.White;
5126
            _canvas.Width = adorner_.BorderSize.Width;
5127
            _canvas.Height = adorner_.BorderSize.Height;
5128 ac4f1e13 taeseongkim
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5129 787a4489 KangIngu
5130
            BitmapEncoder encoder = new PngBitmapEncoder();
5131
5132
5133
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
5134
5135
            DrawingVisual dv = new DrawingVisual();
5136
5137
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5138
            _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)));
5139
5140
            using (DrawingContext ctx = dv.RenderOpen())
5141
            {
5142
                VisualBrush vb = new VisualBrush(_canvas);
5143
                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)));
5144
            }
5145
5146
            try
5147
            {
5148
                renderBitmap.Render(dv);
5149
5150 90e7968d ljiyeon
                //GC.Collect();
5151 787a4489 KangIngu
                GC.WaitForPendingFinalizers();
5152 90e7968d ljiyeon
                //GC.Collect();
5153 787a4489 KangIngu
                // encode png data
5154
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5155
                // puch rendered bitmap into it
5156
                pngEncoder.Interlace = PngInterlaceOption.Off;
5157
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5158
                return pngEncoder;
5159
5160
            }
5161 53880c83 ljiyeon
            catch //(Exception ex)
5162 787a4489 KangIngu
            {
5163
                return null;
5164
            }
5165
5166
        }
5167
5168
        public void DialogMessage_Alert(string content, string header)
5169
        {
5170
            DialogParameters parameters = new DialogParameters()
5171
            {
5172 4279e717 djkim
                Owner = this.ParentOfType<MainWindow>(),
5173 0d32593b ljiyeon
                Content = new TextBlock()
5174
                { 
5175
                    MinWidth = 400,
5176
                    FontSize = 11,
5177
                    Text = content,
5178
                    TextWrapping = System.Windows.TextWrapping.Wrap
5179
                },
5180 b79f786f 송근호
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5181 787a4489 KangIngu
                Header = header,
5182
                Theme = new VisualStudio2013Theme(),
5183
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5184 90e7968d ljiyeon
            };            
5185 787a4489 KangIngu
            RadWindow.Alert(parameters);
5186
        }
5187
5188 84605c0c taeseongkim
#region 캡쳐 기능
5189 787a4489 KangIngu
5190
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5191
        {
5192
            if (x < 0)
5193
            {
5194
                width += x;
5195
                x = 0;
5196
            }
5197
            if (y < 0)
5198
            {
5199
                height += y;
5200
                y = 0;
5201
5202
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5203
            }
5204
            if (x + width > zoomAndPanCanvas.ActualWidth)
5205
            {
5206
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5207
            }
5208
            if (y + height > zoomAndPanCanvas.ActualHeight)
5209
            {
5210
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5211
            }
5212
5213
            byte[] pixels = CopyPixels(x, y, width, height);
5214
5215
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5216
5217
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5218
        }
5219
5220
        public byte[] CopyPixels(int x, int y, int width, int height)
5221
        {
5222
            byte[] pixels = new byte[width * height * 4];
5223
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5224
5225
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
5226
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
5227
5228
            return pixels;
5229
        }
5230
5231
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5232
        {
5233
            DrawingVisual drawingVisual = new DrawingVisual();
5234
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5235
5236
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5237
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5238
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5239
            drawingContext.Close();
5240
5241
            // 비트맵으로 변환합니다.
5242
            RenderTargetBitmap target =
5243
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5244
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5245
5246
            target.Render(drawingVisual);
5247
            return target;
5248
        }
5249
5250 53880c83 ljiyeon
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5251
        {
5252
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5253
            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);
5254
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5255
            bmp.UnlockBits(data);
5256
            return bmp;
5257
        }
5258
        public string symbolname = null;
5259
        public bool symbolsvg = true;
5260
        public bool symbolpng = true;
5261
5262
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5263
        {
5264
            System.Drawing.Bitmap image = GetBitmap(source);
5265
            //흰색 제거
5266
            //image.MakeTransparent(System.Drawing.Color.White);
5267
5268
            var imageStream = new System.IO.MemoryStream();
5269
            byte[] imageBytes = null;
5270
            using (imageStream)
5271
            {
5272
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5273
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5274
                imageStream.Position = 0;
5275
                imageBytes = imageStream.ToArray();
5276
            }
5277
5278
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5279
5280
            RadWindow CheckPop = new RadWindow();
5281
            //Alert check = new Alert(Msg);
5282
5283
            CheckPop = new RadWindow
5284
            {
5285
                MinWidth = 400,
5286
                MinHeight = 100,
5287
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5288
                Header = "Alert",
5289
                Content = symbolPrompt,
5290
                //DialogResult = 
5291
                ResizeMode = System.Windows.ResizeMode.NoResize,
5292
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5293
                IsTopmost = true,
5294
            };
5295
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5296
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5297
            CheckPop.ShowDialog();
5298
5299
            /*
5300
            DialogParameters parameters = new DialogParameters()
5301
            {
5302
                Owner = Application.Current.MainWindow,
5303
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5304
                DefaultPromptResultValue = "Custom State",
5305
                Content = "Name :",
5306
                Header = "Insert Custom Symbol Name",
5307
                Theme = new VisualStudio2013Theme(),
5308
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5309
            };            
5310
            RadWindow.Prompt(parameters);
5311
            */
5312
        }
5313
5314 787a4489 KangIngu
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5315
        {
5316
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5317
            KCOMDataModel.DataModel.CHECK_LIST check_;
5318
            string Result = streamToBase64.ImageToBase64(source);
5319
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5320 6c781c0c djkim
            string projectno = App.ViewInfo.ProjectNO;
5321
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5322 0f065e57 ljiyeon
5323
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5324 6c781c0c djkim
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5325 90e7968d ljiyeon
            if (Item != null)
5326 0f065e57 ljiyeon
            {
5327
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5328
            }
5329
            else
5330
            {
5331
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5332
            }
5333 90e7968d ljiyeon
5334 6c781c0c djkim
            if (Item == null)
5335 787a4489 KangIngu
            {
5336 6c781c0c djkim
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5337 787a4489 KangIngu
                {
5338 24678e06 humkyung
                    ID = Commons.shortGuid(),
5339 6c781c0c djkim
                    USER_ID = App.ViewInfo.UserID,
5340
                    IMAGE_URL = Result,
5341
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5342
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5343
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5344
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5345
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5346
                    STATUS = "False",
5347
                    CREATE_TIME = DateTime.Now,
5348
                    UPDATE_TIME = DateTime.Now,
5349
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5350
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5351
                };
5352 0f065e57 ljiyeon
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5353
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5354
                //this.BaseClient.AddCheckList(projectno, check_);
5355 787a4489 KangIngu
            }
5356 6c781c0c djkim
            else
5357
            {
5358
                Item.IMAGE_URL = Result;
5359
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5360 90e7968d ljiyeon
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5361 0f065e57 ljiyeon
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5362
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5363
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5364 6c781c0c djkim
            }
5365 90e7968d ljiyeon
5366 787a4489 KangIngu
        }
5367
5368
        public void Set_Capture()
5369 90e7968d ljiyeon
        {
5370 c7fde400 taeseongkim
            double x = CanvasDrawingMouseDownPoint.X;
5371
            double y = CanvasDrawingMouseDownPoint.Y;
5372 787a4489 KangIngu
            double width = dragCaptureBorder.Width;
5373
            double height = dragCaptureBorder.Height;
5374
5375
            if (width > 5 || height > 5)
5376
            {
5377
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5378
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5379
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5380
            }
5381
        }
5382 84605c0c taeseongkim
#endregion
5383 787a4489 KangIngu
5384
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5385
        {
5386
            multi_Undo_Data = new Multi_Undo_data();
5387
5388
            multi_Undo_Data.Markup = control;
5389
5390
            if ((control as IShapeControl) != null)
5391
            {
5392
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5393
            }
5394
            if ((control as IDashControl) != null)
5395
            {
5396
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5397
            }
5398
            if ((control as IPath) != null)
5399
            {
5400
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5401
            }
5402
            if ((control as UIElement) != null)
5403
            {
5404
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5405
            }
5406
5407
            return multi_Undo_Data;
5408
        }
5409
5410 ac4f1e13 taeseongkim
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5411 787a4489 KangIngu
        {
5412
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5413
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5414
            {
5415
                if (items.UserID == Select_ID)
5416
                {
5417
                    foreach (var item in items.MarkupList)
5418
                    {
5419
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5420
                        {
5421 ac4f1e13 taeseongkim
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5422 24678e06 humkyung
                                items.MarkupInfoID, Commons.shortGuid());
5423 787a4489 KangIngu
                        }
5424
                    }
5425
                }
5426
            }
5427
        }
5428 d62c0439 humkyung
5429 f959ea6f humkyung
        /// <summary>
5430
        /// convert inkcontrol to polygoncontrol
5431
        /// </summary>
5432
        public void ConvertInkControlToPolygon()
5433 787a4489 KangIngu
        {
5434
            if (inkBoard.Strokes.Count > 0)
5435
            {
5436
                inkBoard.Strokes.ToList().ForEach(stroke =>
5437
                {
5438
                    InkToPath ip = new InkToPath();
5439 f959ea6f humkyung
5440 787a4489 KangIngu
                    List<Point> inkPointSet = new List<Point>();
5441 f959ea6f humkyung
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5442
5443
                    PolygonControl pc = new PolygonControl()
5444 787a4489 KangIngu
                    {
5445 fa48eb85 taeseongkim
                        CommentAngle = 0,
5446 f959ea6f humkyung
                        PointSet = inkPointSet,
5447 787a4489 KangIngu
                        ControlType = ControlType.Ink
5448
                    };
5449 f959ea6f humkyung
                    pc.StartPoint = inkPointSet[0];
5450
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5451
                    pc.LineSize = 3;
5452
                    pc.CommentID = Commons.shortGuid();
5453
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5454 787a4489 KangIngu
5455 f959ea6f humkyung
                    if (pc.PointSet.Count > 0)
5456
                    {
5457
                        CreateCommand.Instance.Execute(pc);
5458 787a4489 KangIngu
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5459
                    }
5460
                });
5461 f959ea6f humkyung
                inkBoard.Strokes.Clear();
5462 787a4489 KangIngu
            }
5463
        }
5464 17a22987 KangIngu
5465 4318fdeb KangIngu
        /// <summary>
5466 e66f22eb KangIngu
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5467
        /// </summary>
5468
        /// <author>ingu</author>
5469
        /// <date>2018.06.05</date>
5470
        /// <param name="getPoint"></param>
5471
        /// <returns></returns>
5472
        private bool IsGetoutpoint(Point getPoint)
5473 670a4be2 humkyung
        {
5474 e66f22eb KangIngu
            if (getPoint == new Point())
5475 670a4be2 humkyung
            {
5476 e66f22eb KangIngu
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5477
                currentControl = null;
5478
                return true;
5479 670a4be2 humkyung
            }
5480
5481 e66f22eb KangIngu
            return false;
5482 670a4be2 humkyung
        }
5483 e66f22eb KangIngu
5484 5b46312f djkim
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5485
        {
5486
            e.Effects = DragDropEffects.Copy;
5487
        }
5488
5489
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5490
        {
5491
            e.Effects = DragDropEffects.Copy;
5492
        }
5493
5494
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5495
        {
5496
            e.Effects = DragDropEffects.None;
5497
        }
5498
5499 92442e4a taeseongkim
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5500 cdfb57ff taeseongkim
        {
5501
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5502
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5503
5504 92442e4a taeseongkim
            ScaleImage(pageWidth, pageHeight);
5505
        }
5506
5507
        /// <summary>
5508
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5509
        /// </summary>
5510
        /// <param name="pageWidth">원본 사이즈</param>
5511
        /// <param name="pageHeight">원본 사이즈</param>
5512
        /// <returns></returns>
5513
        private void ScaleImage(double pageWidth,double pageHeight)
5514
        {
5515 7e2d682c taeseongkim
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5516 cdfb57ff taeseongkim
        }
5517
5518 d0eda156 ljiyeon
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5519
        {
5520
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5521
        }
5522
5523 eeb0a39c taeseongkim
5524 e6a9ddaf humkyung
        /*
5525 5b46312f djkim
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5526
        {
5527 90e7968d ljiyeon
            try
5528 5b46312f djkim
            {
5529 90e7968d ljiyeon
                if (e.Data.GetDataPresent(typeof(string)))
5530
                {
5531
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5532
                    string dragData = e.Data.GetData(typeof(string)) as string;
5533
                    Move_Symbol(sender, dragData);
5534
                }
5535 5b46312f djkim
            }
5536 90e7968d ljiyeon
            catch (Exception ex)
5537
            {
5538
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5539
            }            
5540 5b46312f djkim
        }
5541 e6a9ddaf humkyung
        */
5542 787a4489 KangIngu
    }
5543 f65e6c02 taeseongkim
5544
    public class testItem
5545
    {
5546
        public string Title { get; set; }
5547
    }
5548 5a6a5dd1 humkyung
}
클립보드 이미지 추가 (최대 크기: 500 MB)