프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu

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