프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 7841e9fb

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