프로젝트

일반

사용자정보

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

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

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