프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 1edefbdf

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

1
using IIpc;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Common;
6
using MarkupToPDF.Controls.Parsing;
7
using System;
8
using System.Collections.Generic;
9
using System.Collections.ObjectModel;
10
using System.ComponentModel;
11
using System.Diagnostics;
12
using System.Linq;
13
using System.Threading;
14
using System.Threading.Tasks;
15
using System.Windows;
16
using System.Windows.Controls;
17
using System.Windows.Data;
18
using System.Windows.Input;
19
using System.Windows.Media;
20
using Telerik.Windows.Controls;
21
using static MarkupToPDF.Controls.Parsing.MarkupParser;
22

    
23
namespace KCOM.Controls
24
{
25
    /// <summary>
26
    /// Interaction logic for PageNavigator.xaml
27
    /// </summary>
28
    public partial class Sample : UserControl, INotifyPropertyChanged
29
    {
30
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
31
        public event PropertyChangedEventHandler PropertyChanged;
32
        public DelegateCommand SelectCommentCommand { get; private set; }
33

    
34

    
35
        public Sample()
36
        {
37
            InitializeComponent();
38

    
39
            if (App.IsDesignMode)
40
            {
41
                return;
42
            }
43

    
44
            App.splashString(ISplashMessage.SAMPLE);
45
            this.SizeChanged += Sample_SizeChanged1;
46
            this.Loaded += Sample_Loaded;
47
            this.Unloaded += Sample_Unloaded;
48
        }
49

    
50
        private void Sample_SizeChanged1(object sender, SizeChangedEventArgs e)
51
        {
52
            if(e.PreviousSize.Width != e.NewSize.Width)
53
            {
54
                ImgListbox.ApplyTemplate();
55
            }
56
        }
57

    
58
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
59
        {
60
          
61
        }
62

    
63
        private void Sample_Loaded(object sender, RoutedEventArgs e)
64
        {
65
            if(!_Initialize)
66
            {
67
                _Initialize = true;
68
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
69

    
70

    
71
                this.SizeChanged += Sample_SizeChanged;
72
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
73
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);
74
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
75

    
76

    
77
            }            
78
        }
79

    
80
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
81
        {
82
            if (e.WidthChanged)
83
            {
84
                ImgListbox.ApplyTemplate();
85
            }
86
        }
87

    
88
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample)
89
                                                                            ,new PropertyMetadata(null,new PropertyChangedCallback(FilteredThumbnailPropertyChanged)));
90

    
91
        private static void FilteredThumbnailPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
92
        {
93
            var owner = d as Sample;
94

    
95
            if(owner != null)
96
            {
97
                owner.ImgListbox.ApplyTemplate();
98
            }
99
        }
100

    
101
        public CollectionViewSource FilteredThumbnail
102
        {
103
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
104
            set { SetValue(FilteredThumbnailProperty, value); }
105
        }
106

    
107
        public static readonly DependencyProperty CurrentPageProperty 
108
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
109

    
110
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
111
        {
112
            //var owner = d as Sample;
113

    
114
            //if (owner?.UsersCommentPagesList != null)
115
            //{
116
            //    owner.SetCommentPages();
117
            //}
118
        }
119

    
120
        public ThumbnailItem CurrentPage
121
        {
122
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
123
            set { SetValue(CurrentPageProperty, value); }
124
        }
125

    
126
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
127
        private List<DOCPAGE> _PageList = null;
128
        private string _DefaultUri = null;
129
        public int PageCount = 0;
130
        private bool _Initialize;
131

    
132
        public event EventHandler<EventArgs> ThumbInitialized;
133
        public event EventHandler<PageChangeEventArgs> PageChanged;
134
        public event EventHandler<PageChangeEventArgs> PageChanging;
135

    
136
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
137

    
138
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
139
        {
140
            get {
141
                if(_UsersCommentPagesList == null)
142
                {
143
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
144
                }
145

    
146
                return _UsersCommentPagesList; }
147
            set { _UsersCommentPagesList = value; }
148
        }
149

    
150
        public class PageChangeEventArgs : EventArgs
151
        {
152
            public DOCPAGE CurrentPage { get; set; }
153
            public string PageUri { get; set; }
154
            public int PageNumber { get; set; }
155
        }
156
        private bool _IsFitOn { get; set; }
157
        public bool IsFitOn
158
        {
159
            get
160
            {
161
                return _IsFitOn;
162
            }
163
            set
164
            {
165
                _IsFitOn = value;
166
                RaisePropertyChanged("IsFitOn");
167
            }
168
        }
169

    
170
        public void RaisePropertyChanged(string propName)
171
        {
172
            if (PropertyChanged != null)
173
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
174
        }
175

    
176
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
177
        {
178
            App.splashString(ISplashMessage.SAMPLE);
179
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
180
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
181

    
182
            this._PageList = PageList;
183
            this._DefaultUri = DefaultUri;
184

    
185
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
186

    
187
            
188
            //ThumbnailSetAsync();
189
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
190

    
191
            this.PageCount = PageList.Count();
192

    
193
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
194

    
195
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
196
            wcfServer.IpcThumbnailReceived += WcfServer_IpcThumbnailReceived;
197
            wcfServer.Start();
198

    
199
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
200
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath, App.PageStorage.LocalStorage,Common.ViewerDataModel.Instance.OriginalTempFile);
201

    
202
            App.splashScreen.Close();
203

    
204
        }
205

    
206
        private void WcfServer_IpcThumbnailReceived(object sender, IpcThumbnailEventArgs e)
207
        {
208
            var items = _thumbnailItems.Where(x => x.PageNumber == e.PageNo);
209

    
210
            if (items.Count() > 0)
211
            {
212
                //Dispatcher.BeginInvoke((Action)delegate ()
213
                //{
214
                items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
215

    
216
                
217
                if (e.PageNo > 2 && ImgListbox.Items.Count > 0)
218
                {
219
                    ImgListbox.IsScrollIntoViewEnabled = true;
220
                    //ImgListbox.BringIntoView();
221
                    ImgListbox.ScrollIntoView(0);
222
                }
223

    
224
                //});
225
            }
226
        }
227

    
228
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
229
        {
230
            Logger.sendCheckLog("rdoCommented_Checked", 1);
231
            SetCommentPages();
232
        }
233

    
234
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
235
        {
236
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
237
            //if (rdoFavoritePages.IsChecked == true)
238
            //    expCommentPages.IsExpanded = false;
239

    
240
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
241
            //if (_FavoriteSet.Count > 0)
242
            //{
243
            //    SetCommentPages(); //수정    
244
            //}
245
            //else
246
            //{
247
            //    rdoAllPages.IsChecked = true;
248
            //    rdoFavoritePages.IsChecked = false;
249
            //}
250
        }
251

    
252
        private async void ShowPageChange(object sender, RoutedEventArgs e)
253
        {
254
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
255
            if (IsInitialized)
256
            {
257
                //ThumbnailSetAsync();
258
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
259
            }
260
        }
261

    
262
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
263
        {
264
            //txtThumbCount.Visibility = Visibility.Collapsed;            
265
        }
266

    
267
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
268
        {
269
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
270
            rdoAllPages.IsChecked = false;
271
            rdoFavoritePages.IsChecked = false;
272
            //txtThumbCount.Visibility = Visibility.Visible;
273
            SetCommentPages();
274
        }
275

    
276
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
277
        {
278
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
279
            {
280
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
281

    
282
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
283
            }
284
        }
285

    
286
        /// <summary>
287
        /// called when image list box's selection is changed
288
        /// </summary>
289
        /// <param name="sender"></param>
290
        /// <param name="e"></param>
291
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
292
        {
293
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
294
            {
295
                if (ImgListbox.SelectedItem != null)
296
                {
297
                    PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
298
                }
299
            }
300
        }
301

    
302
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
303
        { 
304
                var number = selectItem.PageNumber;
305

    
306
                if (ViewerDataModel.Instance.SyncPageNumber != number)
307
                {
308
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
309

    
310
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
311

    
312
                    PageChanging(this, new PageChangeEventArgs
313
                    {
314
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
315
                        PageNumber = number,
316
                        PageUri = null
317
                    });
318
                }
319
        }
320

    
321
        public bool GotoPageFlag = false;
322

    
323
        /// <summary>
324
        /// 해당 썸네일로 이동
325
        /// </summary>
326
        /// <param name="_pageNumber">이동할 페이지 번호</param>
327
        public void GotoPage(int _pageNumber)
328
        {
329
            try
330
            {
331
                //System.Threading.Tasks.Task.Factory.StartNew(() => { 
332

    
333
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
334
                    if (_page.Count() > 0)
335
                    {
336
                        ThumbnailItem thumbnailitem = _page.First();
337
                        if (PageChanging != null)
338
                        {
339

    
340
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
341
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
342

    
343
                                ImgListbox.SelectedItem = thumbnailitem;
344

    
345

    
346
                                if (navigationTab.SelectedIndex != 0)
347
                                {
348
                                    PageChange(thumbnailitem);
349
                                }
350

    
351
                            });
352
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
353
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
354
                            //    ImgListbox.ScrollIntoView(_itemIndex);
355
                            //else
356
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
357
                        }
358
                    }
359

    
360
                //}).ConfigureAwait(false);
361
            }
362
            catch(Exception ex)
363
            {
364
                //Logger.sendResLog("GotoPage", ex.Message, 0);
365
            }
366
        }
367

    
368
        /// <summary>
369
        /// 주어진 페이지로 변경한다
370
        /// </summary>
371
        /// <param name="iPageNo">변경할 페이지 번호</param>
372
        public void ChangePage(int iPageNo)
373
        {
374
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
375
            if ((PageChanged != null) && (thumbitem != null))
376
            {
377
                var uri = thumbitem.PageUri.ToString();
378
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
379

    
380
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
381
                if (_DocPages != null)
382
                {
383
                    PageChanged(this, new PageChangeEventArgs
384
                    {
385
                        CurrentPage = _DocPages,
386
                        PageUri = uri,
387
                        PageNumber = thumbitem.PageNumber
388
                    });
389
                    //ImgListbox.SelectedItem = thumbitem;                    
390
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
391
                    
392
                    this.CurrentPage = thumbitem;
393
                }
394
                else
395
                {
396
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
397
                }
398
            }
399
        }
400

    
401
        public void GotoPageTALK(int _pageNumber, int _angle)
402
        {
403
            int _PageNo = -1;
404

    
405
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
406
            {
407
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
408
                if (_page.Count() > 0)
409
                {
410
                    ThumbnailItem _item = _page.First();
411
                    setPageChangeTALK(_item, _angle);
412
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
413
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
414
                }
415
            }
416
        }
417

    
418
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
419
        {
420
            if (thumbnailItem != null)
421
            {
422
                if (PageChanging != null)
423
                {
424
                    ///this.CurrentPage = _NextPage;
425
                    ///_NextPage = thumbnailItem;
426
                    PageChanging(this, new PageChangeEventArgs
427
                    {
428
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
429
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
430
                        PageUri = null
431
                    });
432

    
433
                    var instanceMain = this.ParentOfType<MainWindow>();
434

    
435
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
436

    
437
                    if (rotationNum > 0) // 1, 2, 3
438
                    {
439
                        for (int i = 0; i < rotationNum; i++)
440
                        {
441
                            drawingPannelRotate(true);
442
                        }
443
                    }
444
                    else if (rotationNum < 0)// -1, -2, -3
445
                    {
446
                        for (int i = 0; i < -rotationNum; i++)
447
                        {
448
                            drawingPannelRotate(false);
449
                        }
450
                    }
451
                }
452
            }
453
        }
454

    
455
        public void drawingPannelRotate(bool Flag)
456
        {
457
            var instanceMain = this.ParentOfType<MainWindow>();
458

    
459
            if (Flag)
460
            {
461
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
462
                {
463
                    instanceMain.dzMainMenu.rotate.Angle = 0;
464
                }
465
                else
466
                {
467
                    instanceMain.dzMainMenu.rotate.Angle += 90;
468
                }
469
            }
470
            else
471
            {
472
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
473
                {
474
                    instanceMain.dzMainMenu.rotate.Angle = 270;
475
                }
476
                else
477
                {
478
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
479
                }
480
            }
481

    
482
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
483
            {
484
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
485
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
486
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
487
            }
488

    
489
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
490
            {
491
                instanceMain.dzMainMenu.translate.X = 0;
492
                instanceMain.dzMainMenu.translate.Y = 0;
493
            }
494
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
495
            {
496
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
497
                instanceMain.dzMainMenu.translate.Y = 0;
498
            }
499
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
500
            {
501
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
502
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
503
            }
504
            else
505
            {
506
                instanceMain.dzMainMenu.translate.X = 0;
507
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
508
            }
509

    
510
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
511
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
512
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
513
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
514
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
515
            ViewerDataModel.Instance.MarkupAngle = instanceMain.dzMainMenu.rotate.Angle;
516

    
517
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
518
            {
519
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
520

    
521
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
522
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
523
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
524

    
525
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
526
                if (rotationdoc != null)
527
                {
528
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
529
                }
530
                else
531
                {
532
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
533
                }
534
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
535
            });
536
        }
537

    
538
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
539
        {
540
            SetCommentPages();
541
        }
542

    
543
        public async void SetCommentPages(object obj = null)
544
        {
545
            //ThumbnailSetAsync();
546
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
547
        }
548

    
549
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
550
        {
551
            Logger.sendCheckLog("SetCommentList", 1);
552
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
553
            #region 기존 색상 제거 작업
554

    
555
            foreach (var item in this._thumbnailItems)
556
            {
557
                if (item.DisplayColorItems != null)
558
                {
559
                    item.DisplayColorItems.Clear();
560
                }
561
            }
562
            #endregion
563

    
564
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
565
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
566

    
567
            this.UsersCommentPagesList.ToList().ForEach(item =>
568
            {
569
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
570

    
571
                if (_comm.Count() == 0)
572
                {
573
                    _delItem.Add(item);
574
                }
575

    
576
                if (cts != null)
577
                {
578
                    if (cts.Value.IsCancellationRequested)
579
                        return;
580
                }
581
            });
582

    
583
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
584

    
585
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
586
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
587

    
588
            UsersCommentPagesList.ForEach(user =>
589
            {
590
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
591
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
592

    
593
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
594

    
595
                if (_commLst.Count() == 0)
596
                {
597
                    this.UsersCommentPagesList.Add(user);
598
                }
599
                else
600
                {
601
                    if (_commLst.First().PageNumber != user.PageNumber)
602
                        _commLst.First().PageNumber = user.PageNumber;
603
                }
604

    
605
                user.PageNumber.ForEach(page =>
606
                {
607
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
608

    
609
                    if (_items.Count() > 0)
610
                    {
611
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
612
                        
613
                    }
614

    
615
                    if (cts != null)
616
                    {
617
                        if (cts.Value.IsCancellationRequested)
618
                            return;
619
                    }
620
                });
621
            });
622

    
623
            foreach (var item in this._thumbnailItems)
624
            {
625
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
626
            }
627

    
628
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
629
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
630

    
631
            if (data.Count() != 0)
632
            {
633
                if (Convert.ToBoolean(data.First().isConSolidation))
634
                {
635
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
636
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
637
                    this.lstSelectComment.ItemsSource = data;
638
                }
639
            }
640

    
641
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
642
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
643

    
644

    
645
            //var template = this.ImgListbox.ItemTemplate;
646
            //this.ImgListbox.ItemTemplate = null;
647
            //this.ImgListbox.ItemTemplate = template;
648

    
649
        }
650

    
651
        List<int> FilterPages = null;
652

    
653
        private void ThumbnailSetAsync()
654
        {
655
            Logger.sendCheckLog("ThumbnailSet", 1);
656

    
657
            if (FilteredThumbnail == null)
658
            {
659
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
660

    
661
                var pageList = ViewerDataModel.Instance.Document_Info;
662

    
663
                var items = from page in pageList
664
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
665
                            select new ThumbnailItem
666
                            {
667
                                //ImageUri = new Uri(pageLink),
668
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
669
                                PageNumber = page.PAGE_NUMBER,
670
                                Angle = page.PAGE_ANGLE
671
                            };
672

    
673
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
674
                FilteredThumbnail = new CollectionViewSource();
675
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
676

    
677
                FilteredThumbnail.Source = _thumbnailItems;
678

    
679
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
680
                  {
681
                      System.Diagnostics.Debug.WriteLine("ect");
682
                  };
683

    
684
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
685

    
686
                FilteredThumbnail.Filter += (snd, evt) =>
687
                {
688
                    if (FilterPages?.Count() > 0 && evt.Item != null)
689
                    {
690
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
691
                    }
692
                    else
693
                    {
694
                        evt.Accepted = false;
695
                    }
696
                };
697

    
698
            }
699

    
700
            FilterPages.Clear();
701

    
702
            if (rdoAllPages.IsChecked == true)
703
            {
704
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
705
            }
706
            else if (rdoFavoritePages.IsChecked == true)
707
            {
708
                if (_FavoriteSet != null)
709
                {
710
                    FilterPages = (from thumb in _thumbnailItems
711
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
712
                                select thumb.PageNumber).ToList();
713
                }
714
            }
715
            else if (rdoCommentPages.IsChecked == true)
716
            {
717
                if (this.lstSelectComment.ItemsSource != null)
718
                {
719
                    var commentPages = (from commentPage in this.UsersCommentPagesList
720
                                        where commentPage.IsSelected == true
721
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
722

    
723
                    if (commentPages?.Count() > 0)
724
                    {
725
                        FilterPages = (from thumb in _thumbnailItems
726
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
727
                                       select thumb.PageNumber).ToList();
728
                    }
729
                }
730
            }
731

    
732
            if (FilterPages != null)
733
            {
734
                if(FilteredThumbnail == null)
735
                {
736
                    System.Diagnostics.Debug.WriteLine("filter null");
737
                }
738

    
739
                if (FilteredThumbnail.View == null)
740
                {
741
                    System.Diagnostics.Debug.WriteLine("filter null");
742
                }
743

    
744
                FilteredThumbnail.View.Refresh();
745

    
746
                if (FilterPages.Count() > 0)
747
                {
748
                    if (_thumbnailItems.Count() > 0)
749
                    {
750
                        ImgListbox.SelectedItem = _thumbnailItems[0];
751
                    }
752

    
753
                    //SetCommentList(UsersCommentPagesList.ToList());
754
                }
755
                else
756
                {
757
                    ImgListbox.SelectedItem = null;
758
                }
759

    
760
                if (ThumbInitialized != null)
761
                {
762
                    ThumbInitialized(this, new EventArgs());
763
                    ThumbInitialized = null;
764
                }
765
            }
766
        }
767

    
768

    
769
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
770
        {
771
            if (e.ClickCount >= 2)
772
            {
773
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
774

    
775
                GotoPage(selectItem.PageNumber);
776

    
777
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.CancellationToken());
778

    
779
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
780
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
781
                //bool isGO = false;
782

    
783
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
784
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
785
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
786
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
787
                //{
788
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
789
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
790
                //    {
791
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
792
                //    }
793

    
794
                //};
795
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
796

    
797
                //GotoPage(MarkupList.SelectedItem as MarkupList)
798
            }
799
        }
800

    
801
        public class MarkupInfoItemSmall
802
        {
803
            public string Id { get; set; }
804
            public string UserName { get; set; }
805
            public string UserID { get; set; }
806
            public int PageNumber { get; set; }
807
            public string Data { get; set; }
808
            public int Data_Type { get; set; }
809
            public bool IsConsolidate { get; set; }
810
        }
811

    
812
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
813
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
814
        {
815
            get
816
            {
817
                if (_MarkupInfoSmallList == null)
818
                {
819
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
820
                }
821
                return _MarkupInfoSmallList;
822
            }
823
            set
824
            {
825

    
826
                _MarkupInfoSmallList = value;
827
                RaisePropertyChanged("MarkupInfoSmallList");
828
            }
829
        }
830

    
831
        /// <summary>
832
        /// goto page and select item selected by user
833
        /// </summary>
834
        /// <param name="sender"></param>
835
        /// <param name="e"></param>
836
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
837
        {
838
            var clickButtonItem = sender as RadButton;
839
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
840
            {
841
                try
842
                {
843
                    Rect rect = new Rect();
844
                    Point s_point = new Point();
845
                    Point e_point = new Point();
846

    
847
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
848
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
849

    
850
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
851
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
852
                    {
853
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
854
                            {
855
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
856
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
857
                            }
858
                            break;
859
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
860
                            {
861
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
862
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
863
                            }
864
                            break;
865
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
866
                            {
867
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
868
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
869
                            }
870
                            break;
871
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
872
                            {
873
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
874

    
875
                                foreach (Point A in instance.PointSet)
876
                                {
877
                                    if (s_point == new Point())
878
                                    {
879
                                        s_point = A;
880
                                        e_point = A;
881
                                    }
882
                                    s_point.X = Math.Min(s_point.X, A.X);
883
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
884
                                    e_point.X = Math.Max(e_point.X, A.X);
885
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
886
                                }
887
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
888
                            }
889
                            break;
890
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
891
                            {
892
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
893

    
894
                                foreach (Point A in instance.PointSet)
895
                                {
896
                                    if (s_point == new Point())
897
                                    {
898
                                        s_point = A;
899
                                        e_point = A;
900
                                    }
901
                                    s_point.X = Math.Min(s_point.X, A.X);
902
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
903
                                    e_point.X = Math.Max(e_point.X, A.X);
904
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
905
                                }
906
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
907
                            }
908
                            break;
909
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
910
                            {
911
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
912

    
913
                                foreach (Point A in instance.PointSet)
914
                                {
915
                                    if (s_point == new Point())
916
                                    {
917
                                        s_point = A;
918
                                        e_point = A;
919
                                    }
920
                                    s_point.X = Math.Min(s_point.X, A.X);
921
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
922
                                    e_point.X = Math.Max(e_point.X, A.X);
923
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
924
                                }
925
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
926
                            }
927
                            break;
928
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
929
                            {
930
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
931

    
932
                                foreach (Point A in instance.PointSet)
933
                                {
934
                                    if (s_point == new Point())
935
                                    {
936
                                        s_point = A;
937
                                        e_point = A;
938
                                    }
939
                                    s_point.X = Math.Min(s_point.X, A.X);
940
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
941
                                    e_point.X = Math.Max(e_point.X, A.X);
942
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
943
                                }
944
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
945
                            }
946
                            break;
947
                        default:
948
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
949
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
950
                            break;
951
                    }
952

    
953
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
954
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
955
                }
956
                catch (Exception ex)
957
                {
958
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
959
                }
960
            }
961
        }
962

    
963
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
964
        {
965
            var clickButtonItem = sender as RadButton;
966
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
967
            {
968
                try
969
                {
970
             
971

    
972
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
973
                    MarkupList.SelectedItem = gaza;
974

    
975
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
976
                }
977
                catch (Exception ex)
978
                {
979
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
980
                }
981
            }
982
        }
983

    
984
        ///// <summary>
985
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
986
        ///// </summary>
987
        ///// <param name="CommentIdList"></param>
988
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
989
        //{
990
        //    var instance = Common.ViewerDataModel.Instance;
991

    
992
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
993

    
994
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
995

    
996
        //    if (commentList.Count() > 0)
997
        //    {
998
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
999
        //        #region markup list grid select items
1000

    
1001
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
1002

    
1003
        //        if (infoItem.Count() > 0)
1004
        //        {
1005

    
1006
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
1007
        //            gridMarkup.SelectedItems.Clear();
1008
        //            gridMarkup.SelectedItems.Add(infoItem.First());
1009
        //        }
1010

    
1011
        //        #endregion
1012

    
1013
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
1014

    
1015
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
1016
        //        {
1017
        //            GotoSelectedMarkup(CommentIdList);
1018
        //        }
1019
        //        else
1020
        //        {
1021
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
1022

    
1023
        //            handler = (snd, evt) =>
1024
        //            {
1025
        //                GotoSelectedMarkup(CommentIdList);
1026
        //                pageNavigator.PageChanged -= handler;
1027
        //            };
1028

    
1029
        //            pageNavigator.PageChanged += handler;
1030

    
1031
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
1032
        //        }
1033
        //    }
1034
        //}
1035

    
1036
        ///// <summary>
1037
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
1038
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
1039
        ///// </summary>
1040
        ///// <param name="CommentIdList"></param>
1041
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
1042
        //{
1043
        //    var instance = Common.ViewerDataModel.Instance;
1044

    
1045
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1046
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1047

    
1048
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1049
        //    {
1050
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1051
        //        commentUserInfo.AddRange(selectOrderComments);
1052

    
1053
        //        if (commentUserInfo?.Count() > 0)
1054
        //        {
1055
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1056

    
1057
        //            try
1058
        //            {
1059
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1060
        //                {
1061
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1062
        //                    {
1063
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1064
        //                    } 
1065
                            
1066
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1067
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1068
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1069
        //                }
1070

    
1071
        //                Rect rect = commentUserInfo.First().ItemRect;
1072

    
1073
        //                foreach (var UserInfo in commentUserInfo)
1074
        //                {
1075
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1076
        //                }
1077

    
1078
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1079

    
1080
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1081
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1082
        //                //rect.Transform(matrix);
1083

    
1084
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1085
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1086
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1087
        //                double positionX = 0;
1088
        //                double positionY = 0;
1089

    
1090
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1091
        //                {
1092
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1093
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1094
        //                }
1095

    
1096
        //                main.zoomAndPanControl.ContentScale = newScale;
1097
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1098
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1099

    
1100
              
1101
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1102

    
1103
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1104

    
1105
        //                if (pageAngle == 90)
1106
        //                {
1107
        //                    pageAngle = 270;
1108
        //                }
1109
        //                else
1110
        //                {
1111
        //                    pageAngle = 90;
1112
        //                }
1113

    
1114
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1115
        //                {
1116
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1117
        //                    rect.Transform(matrix);
1118

    
1119
        //                    main.zoomAndPanControl.ZoomTo(rect);
1120
        //                }
1121
        //                else
1122
        //                {
1123
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1124

    
1125
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1126
        //                    rect.Transform(matrix);
1127

    
1128

    
1129
        //                    main.zoomAndPanControl.ZoomTo(rect);
1130
        //                }
1131
        //            }
1132
        //            catch (Exception ex)
1133
        //            {
1134
        //                main.DialogMessage_Alert(ex.Message, "Error");
1135
        //            }
1136
        //        }
1137
        //    }
1138
        //}
1139

    
1140
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1141
        {
1142
            if (MarkupInfoSmallList.Count == 0)
1143
            {
1144
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1145
                {
1146
                    if (d.MarkupList != null)
1147
                    {
1148
                        d.MarkupList.ForEach(b =>
1149
                        {
1150
                            bool isConsolidate = false;
1151

    
1152
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1153
                            {
1154
                                isConsolidate = true;
1155
                            }
1156

    
1157
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1158

    
1159
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1160
                            {
1161
                                Id = b.ID,
1162
                                Data = b.Data,
1163
                                Data_Type = b.Data_Type,
1164
                                PageNumber = b.PageNumber,
1165
                                UserID = d.UserID,
1166
                                UserName = d.UserName,
1167
                                IsConsolidate = isConsolidate
1168

    
1169
                            });
1170
                        });
1171
                    }
1172
                });
1173
                MarkupList.ItemsSource = null;
1174
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1175

    
1176
                FilterUpdate();
1177
            }
1178
        }
1179

    
1180
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1181
        {
1182
            if (MarkupInfoSmallList.Count == 0)
1183
            {
1184
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1185
                {
1186
                    if (d.MarkupList != null)
1187
                    {
1188
                        d.MarkupList.ForEach(b =>
1189
                        {
1190
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1191
                            {
1192
                                Id = b.ID,
1193
                                Data = b.Data,
1194
                                Data_Type = b.Data_Type,
1195
                                PageNumber = b.PageNumber,
1196
                                UserID = d.UserID,
1197
                                UserName = d.UserName,
1198
                            });
1199
                        });
1200
                    }
1201
                });
1202
                MarkupList.ItemsSource = null;
1203
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1204
            }
1205

    
1206
            switch (eventType)
1207
            {
1208
                case Event_Type.Create:
1209
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1210
                    {
1211
                        Id = res.CommentID,
1212
                        Data = res.ConvertData,
1213
                        Data_Type = res.DATA_TYPE,
1214
                        PageNumber = CurrentPage.PageNumber,
1215
                        UserID = App.ViewInfo.UserID,
1216
                        UserName = App.UserName,
1217
                    });
1218
                    break;
1219
                case Event_Type.Delete:
1220
                    if(CommentID == null) //user information list delete btn
1221
                    {
1222
                        foreach (var delItem in item.MarkupList)
1223
                        {
1224
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1225
                        }
1226
                    }
1227
                    else //delete, cut, 
1228
                    {
1229
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1230
                    }                    
1231
                    break;
1232
                case Event_Type.Thumb://이동 회전
1233
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1234
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1235
                    {
1236
                        Id = res.CommentID,
1237
                        Data = res.ConvertData,
1238
                        Data_Type = res.DATA_TYPE,
1239
                        PageNumber = CurrentPage.PageNumber,
1240
                        UserID = App.ViewInfo.UserID,
1241
                        UserName = App.UserName,
1242
                    });
1243
                    break;
1244
                default:
1245
                    break;
1246
            }
1247

    
1248
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1249

    
1250
            bool IsConsolidation = false;
1251
            string UserId = null;
1252

    
1253
            if (commentUser.SelectedValue != null)
1254
            {
1255
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1256
                {
1257
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1258
                }
1259
                else
1260
                {
1261
                    IsConsolidation = true;
1262
                }
1263
            }
1264

    
1265
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1266
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1267
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1268

    
1269
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1270

    
1271
            FilterUpdate();
1272
        }
1273

    
1274
        private void FilterUpdate(string selectUser = null)
1275
        {
1276
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1277

    
1278
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1279
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1280

    
1281

    
1282
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1283
 
1284
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1285
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1286

    
1287
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1288
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1289

    
1290
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1291
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1292

    
1293
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1294
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1295
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1296
        }
1297

    
1298
        
1299

    
1300
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1301
        {
1302
            MarkupList.ItemsSource = null;
1303
            txtSearch.Text = string.Empty;
1304

    
1305
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1306

    
1307
            bool IsConsolidation = false;
1308
            string userName = null;
1309

    
1310
            if (commentUser.SelectedValue != null)
1311
            {
1312
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1313
                {
1314
                    userName = commentUser.SelectedValue.ToString();
1315
                }
1316
                else
1317
                {
1318
                    IsConsolidation = true;
1319
                }
1320
            }
1321

    
1322
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1323
                                   .WhereIf(userName != null, d => d.UserName == userName)
1324
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1325
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1326

    
1327
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1328

    
1329
            FilterUpdate();
1330
        }
1331

    
1332
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1333
        {
1334
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1335
        }
1336

    
1337
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1338
        {
1339
            string search_str = txtSearch.Text;
1340

    
1341
            if(string.IsNullOrWhiteSpace(search_str))
1342
            {
1343
                return;
1344
            }
1345

    
1346
            var sel_type = commentType.SelectedItem;
1347
            var sel_user = commentUser.SelectedItem;
1348
            var sel_page = commentPage.SelectedItem;
1349
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1350
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1351
            if (sel_page != null)
1352
            {
1353
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1354
            }
1355
            if (sel_type != null)
1356
            {
1357
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1358
            }
1359
            if (sel_user != null)
1360
            {
1361
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1362
            }
1363
            foreach (var item in list)
1364
            {
1365
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1366

    
1367
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1368
                {
1369
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1370
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1371
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1372
                        {
1373
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1374

    
1375
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1376
                            {
1377
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1378
                                {
1379
                                    small_list.Add(item);
1380
                                }
1381
                            }
1382
                        }
1383
                        break;
1384
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1385
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1386
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1387
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1388
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1389
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1390
                        {
1391
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1392

    
1393
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1394
                            {
1395
                                if (instance.ArrowText.Contains(search_str))
1396
                                {
1397
                                    small_list.Add(item);
1398
                                }
1399
                            }
1400
                        }
1401
                        break;
1402
                }
1403
            }
1404

    
1405
            MarkupList.ItemsSource = null;
1406
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1407
        }
1408

    
1409
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1410
        {
1411
            if(e.Key == Key.Enter || e.Key == Key.Return)
1412
            {
1413
                btnSearch_Click(sender, new RoutedEventArgs());
1414
            }
1415
        }
1416

    
1417
    }
1418
}
클립보드 이미지 추가 (최대 크기: 500 MB)