프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 54a28343

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