프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 54a28343

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

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

    
20
namespace KCOM.Controls
21
{
22
    /// <summary>
23
    /// Interaction logic for PageNavigator.xaml
24
    /// </summary>
25
    public partial class Sample : UserControl, INotifyPropertyChanged
26
    {
27
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
28
        public event PropertyChangedEventHandler PropertyChanged;
29

    
30
        PageManager.PageStorage samplePageStorage;
31

    
32
        public Sample()
33
        {
34
            InitializeComponent();
35

    
36
            if (App.IsDesignMode)
37
            {
38
                return;
39
            }
40

    
41
            //App.splashString(ISplashMessage.SAMPLE);
42
            this.Loaded += Sample_Loaded;
43
        }
44

    
45
        private void Sample_Loaded(object sender, RoutedEventArgs e)
46
        {
47
            if(!_Initialize)
48
            {
49
                _Initialize = true;
50

    
51
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
52
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
53
            }            
54
        }
55

    
56
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
57
        private List<DOCPAGE> _PageList = null;
58
        private string _DefaultUri = null;
59
        public ThumbnailItem CurrentPage = null;
60
        public int PageCount = 0;
61
        private bool _Initialize;
62

    
63
        public event EventHandler<EventArgs> ThumbInitialized;
64
        public event EventHandler<PageChangeEventArgs> PageChanged;
65
        public event EventHandler<PageChangeEventArgs> PageChanging;
66

    
67
        private List<UsersCommentPagesMember> _UsersCommentPagesList;
68

    
69
        public List<UsersCommentPagesMember> UsersCommentPagesList
70
        {
71
            get {
72
                if(_UsersCommentPagesList == null)
73
                {
74
                    _UsersCommentPagesList = new List<UsersCommentPagesMember>();
75
                }
76

    
77
                return _UsersCommentPagesList; }
78
            set { _UsersCommentPagesList = value; }
79
        }
80

    
81
        public class PageChangeEventArgs : EventArgs
82
        {
83
            public DOCPAGE CurrentPage { get; set; }
84
            public string PageUri { get; set; }
85
            public int PageNumber { get; set; }
86
        }
87
        private bool _IsFitOn { get; set; }
88
        public bool IsFitOn
89
        {
90
            get
91
            {
92
                return _IsFitOn;
93
            }
94
            set
95
            {
96
                _IsFitOn = value;
97
                RaisePropertyChanged("IsFitOn");
98
            }
99
        }
100

    
101
        public void RaisePropertyChanged(string propName)
102
        {
103
            if (PropertyChanged != null)
104
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
105
        }
106

    
107
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
108
        {
109
            this._PageList = PageList;
110
            this._DefaultUri = DefaultUri;
111

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

    
114
            samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
115

    
116
            await ThumbnailSetAsync();
117
            
118
            this.PageCount = PageList.Count();
119

    
120
            //ThumbNmailSet();
121
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
122
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
123
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
124
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
125
        }
126

    
127
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
128
        {
129
            Logger.sendCheckLog("rdoCommented_Checked", 1);
130
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
131
            SetCommentPages();
132
        }
133

    
134
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
135
        {
136
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
137
            if (rdoFavoritePages.IsChecked == true)
138
                expCommentPages.IsExpanded = false;
139

    
140
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
141
            if (_FavoriteSet.Count > 0)
142
            {
143
                SetCommentPages_Favorite(); //수정    
144
            }
145
            else
146
            {
147
                rdoAllPages.IsChecked = true;
148
                rdoFavoritePages.IsChecked = false;
149
            }
150
        }
151

    
152
        private async void SetCommentPages_Favorite()
153
        {
154
            await ThumbnailSetAsync();            
155
            SetCommentPages();
156
        }
157

    
158
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
159
        {
160
            //txtThumbCount.Visibility = Visibility.Collapsed;            
161
        }
162

    
163
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
164
        {
165
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
166
            rdoAllPages.IsChecked = false;
167
            rdoFavoritePages.IsChecked = false;
168
            //txtThumbCount.Visibility = Visibility.Visible;
169
            SetCommentPages();
170
        }
171

    
172
        /// <summary>
173
        /// called when image list box's selection is changed
174
        /// </summary>
175
        /// <param name="sender"></param>
176
        /// <param name="e"></param>
177
        private async void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
178
        {
179
            if(e.AddedItems.Count > 0)
180
            {
181
                await ImgListbox.Dispatcher.InvokeAsync(() =>
182
                {
183
                    var number = (e.AddedItems[0] as KCOM.Common.ThumbnailItem).PageNumber;
184

    
185
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
186

    
187
                    this.CurrentPage = e.AddedItems[0] as KCOM.Common.ThumbnailItem;
188

    
189
                    PageChanging(this, new PageChangeEventArgs
190
                    {
191
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
192
                        PageNumber = number,
193
                        PageUri = null
194
                    });
195

    
196
                });
197
            }
198
            
199

    
200
            //if (ImgListbox.SelectedItem != null)
201
            //{
202
            //    int _CurrentPageNo = -1;
203
            //    if (this.CurrentPage != null)
204
            //    {
205
            //        ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
206

    
207
            //        _CurrentPageNo = this.CurrentPage.PageNumber;
208
            //    }
209

    
210
            //    this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
211
            //    int iPageNo = this.CurrentPage.PageNumber;
212
            //    if(_CurrentPageNo != iPageNo)
213
            //    {
214
            //        PageChanging(this, new PageChangeEventArgs
215
            //        {
216
            //            CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
217
            //            PageNumber = iPageNo,
218
            //            PageUri = null
219
            //        });
220
            //    }
221
            //}
222

    
223
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
224
            //if (border != null)
225
            //{
226
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
227

    
228
            //}
229
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
230

    
231
            
232
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
233
        }
234

    
235
        public bool GotoPageFlag = false;
236

    
237
        /// <summary>
238
        /// 해당 썸네일로 이동
239
        /// </summary>
240
        /// <param name="_pageNumber">이동할 페이지 번호</param>
241
        public void GotoPage(int _pageNumber)
242
        {
243
            try
244
            {
245
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
246

    
247
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
248
                    if (_page.Count() > 0)
249
                    {
250
                        ThumbnailItem thumbnailitem = _page.First();
251
                        if (PageChanging != null)
252
                        {
253

    
254
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
255
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
256
                                ImgListbox.SelectedItem = thumbnailitem;
257
                            });
258
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
259
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
260
                            //    ImgListbox.ScrollIntoView(_itemIndex);
261
                            //else
262
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
263
                        }
264
                    }
265

    
266
                }).ConfigureAwait(true);
267
            }
268
            catch(Exception ex)
269
            {
270
                Logger.sendResLog("GotoPage", ex.Message, 0);
271
            }
272
        }
273

    
274
        /// <summary>
275
        /// 주어진 페이지로 변경한다
276
        /// </summary>
277
        /// <param name="iPageNo">변경할 페이지 번호</param>
278
        public void ChangePage(int iPageNo)
279
        {
280
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
281
            if ((PageChanged != null) && (thumbitem != null))
282
            {
283
                var uri = thumbitem.PageUri.ToString();
284
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
285

    
286
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
287
                if (_DocPages != null)
288
                {
289
                    PageChanged(this, new PageChangeEventArgs
290
                    {
291
                        CurrentPage = _DocPages,
292
                        PageUri = uri,
293
                        PageNumber = thumbitem.PageNumber
294
                    });
295
                    //ImgListbox.SelectedItem = thumbitem;                    
296
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
297
                    
298
                    this.CurrentPage = thumbitem;
299
                }
300
                else
301
                {
302
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
303
                }
304
            }
305
        }
306

    
307
        public void GotoPageTALK(int _pageNumber, int _angle)
308
        {
309
            int _PageNo = -1;
310

    
311
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
312
            {
313
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
314
                if (_page.Count() > 0)
315
                {
316
                    ThumbnailItem _item = _page.First();
317
                    setPageChangeTALK(_item, _angle);
318
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
319
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
320
                }
321
            }
322
        }
323

    
324
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
325
        {
326
            if (thumbnailItem != null)
327
            {
328
                if (PageChanging != null)
329
                {
330
                    ///this.CurrentPage = _NextPage;
331
                    ///_NextPage = thumbnailItem;
332
                    PageChanging(this, new PageChangeEventArgs
333
                    {
334
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
335
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
336
                        PageUri = null
337
                    });
338

    
339
                    var instanceMain = this.ParentOfType<MainWindow>();
340

    
341
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
342

    
343
                    if (rotationNum > 0) // 1, 2, 3
344
                    {
345
                        for (int i = 0; i < rotationNum; i++)
346
                        {
347
                            drawingPannelRotate(true);
348
                        }
349
                    }
350
                    else if (rotationNum < 0)// -1, -2, -3
351
                    {
352
                        for (int i = 0; i < -rotationNum; i++)
353
                        {
354
                            drawingPannelRotate(false);
355
                        }
356
                    }
357
                }
358
            }
359
        }
360

    
361
        public void drawingPannelRotate(bool Flag)
362
        {
363
            var instanceMain = this.ParentOfType<MainWindow>();
364

    
365
            if (Flag)
366
            {
367
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
368
                {
369
                    instanceMain.dzMainMenu.rotate.Angle = 0;
370
                }
371
                else
372
                {
373
                    instanceMain.dzMainMenu.rotate.Angle += 90;
374
                }
375
            }
376
            else
377
            {
378
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
379
                {
380
                    instanceMain.dzMainMenu.rotate.Angle = 270;
381
                }
382
                else
383
                {
384
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
385
                }
386
            }
387

    
388
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
389
            {
390
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
391
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
392
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
393
            }
394

    
395
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
396
            {
397
                instanceMain.dzMainMenu.translate.X = 0;
398
                instanceMain.dzMainMenu.translate.Y = 0;
399
            }
400
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
401
            {
402
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
403
                instanceMain.dzMainMenu.translate.Y = 0;
404
            }
405
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
406
            {
407
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
408
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
409
            }
410
            else
411
            {
412
                instanceMain.dzMainMenu.translate.X = 0;
413
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
414
            }
415

    
416
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
417
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
418
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
419
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
420
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
421
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
422

    
423
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
424
            {
425
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
426

    
427
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
428
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
429
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
430

    
431
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
432
                if (rotationdoc != null)
433
                {
434
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
435
                }
436
                else
437
                {
438
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
439
                }
440
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
441
            });
442
        }
443

    
444
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
445
        {
446
            SetCommentPages();
447
        }
448
        
449
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
450
        {
451
            SetCommentPages();
452
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
453
        }
454

    
455
        public async void SetCommentPages()
456
        {
457
            await ThumbnailSetAsync();
458
            SetCommentList(UsersCommentPagesList.ToList());
459
        }
460

    
461
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
462
        {
463
            Logger.sendCheckLog("SetCommentList", 1);
464
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
465
            #region 기존 색상 제거 작업
466
            foreach (var item in this._thumbnailItems)
467
            {
468
                item.DisplayColorItems.Clear();
469
            }
470
            #endregion
471

    
472
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
473
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
474

    
475
            this.UsersCommentPagesList.ToList().ForEach(item =>
476
            {
477
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
478

    
479
                if (_comm.Count() == 0)
480
                {
481
                    _delItem.Add(item);
482
                }
483
            });
484

    
485
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
486

    
487
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
488
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
489

    
490
            UsersCommentPagesList.ForEach(user =>
491
            {
492
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
493
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
494

    
495
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
496

    
497
                if (_commLst.Count() == 0)
498
                {
499
                    this.UsersCommentPagesList.Add(user);
500
                }
501
                else
502
                {
503
                    if (_commLst.First().PageNumber != user.PageNumber)
504
                        _commLst.First().PageNumber = user.PageNumber;
505
                }
506

    
507
                user.PageNumber.ForEach(page =>
508
                {
509
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
510

    
511
                    if (_items.Count() > 0)
512
                    {
513
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
514
                        
515
                    }
516
                        
517
                });
518
            });
519

    
520
            foreach (var item in this._thumbnailItems)
521
            {
522
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
523
            }
524
            
525
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
526
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
527
            if (data.Count() != 0)
528
            {
529
                if (Convert.ToBoolean(data.First().isConSolidation))
530
                {
531
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
532
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
533
                    this.lstSelectComment.ItemsSource = data;
534
                }
535
                else
536
                {
537
                    this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
538
                }
539
            }
540
            else
541
            {
542
                this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
543
            }
544

    
545
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
546

    
547

    
548
            //var template = this.ImgListbox.ItemTemplate;
549
            //this.ImgListbox.ItemTemplate = null;
550
            //this.ImgListbox.ItemTemplate = template;
551

    
552
        }
553

    
554
        private async Task ThumbnailSetAsync()
555
        {
556
            Logger.sendCheckLog("ThumbnailSet", 1);
557
      
558
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
559
            List<int> _selectComment = new List<int>();
560
            if (this.lstSelectComment.ItemsSource != null)
561
            {
562
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
563
                             where commentPage.IsSelected == true
564
                             select commentPage.PageNumber;
565

    
566
                foreach (var item in _pages)
567
                {
568
                    item.ForEach(pp => _selectComment.Add(pp));
569
                }
570

    
571
                _selectComment.Distinct();
572
            }
573

    
574
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
575
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
576
            //this._PageList.ForEach(page =>
577

    
578
            var items = ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList();
579

    
580
            foreach (var page in items)
581
            {
582

    
583
            //}
584
            //ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
585
            //{
586
                var _pageNo = page.PAGE_NUMBER;
587
                bool _addFlag = false;
588

    
589
                if (rdoFavoritePages.IsChecked == false)
590
                {
591
                    if (_selectComment.Count() > 0)
592
                    {
593
                        if ((rdoAllPages.IsChecked == true)
594
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
595
                        {
596
                            _addFlag = true;
597
                        }
598
                    }
599
                    else
600
                    {
601
                        //if (App.ViewInfo.IsCustomPage)
602
                        //{
603
                        //    //_addFlag = false;
604

    
605
                        //    //App.ViewInfo.IsCustomPage = false;
606
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
607
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
608
                        //    this.rdoAllPages.IsChecked = false;
609
                        //    this.rdoFavoritePages.IsChecked = true;
610
                        //    //SetCommentPages();                        
611
                        //}
612
                        //else
613
                        //{
614
                        _addFlag = true;
615
                        //}
616
                    }
617
                }
618

    
619
                var pageUri = await samplePageStorage.GetPageUriAsync(_pageNo);
620

    
621
                if (_addFlag)
622
                {
623
                    
624
                   this._thumbnailItems.Add(new ThumbnailItem
625
                    {
626
                        ImageUri = pageUri,
627
                        PageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString()).Replace("jpg","png")),
628
                        PageNumber = _pageNo,
629
                        Angle = page.PAGE_ANGLE,
630
                    });
631
                }
632
                else
633
                {
634
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
635
                    {
636
                        this._thumbnailItems.Add(new ThumbnailItem
637
                        {
638
                            ImageUri = pageUri,
639
                            PageNumber = _pageNo,
640
                            Angle = page.PAGE_ANGLE,
641
                        });
642
                    }
643
                }
644
            }
645

    
646
            if (ImgListbox.ItemsSource == null)
647
            {
648
                ImgListbox.ItemsSource = this._thumbnailItems;
649

    
650
                this.CurrentPage = this._thumbnailItems.FirstOrDefault();
651

    
652
                this._thumbnailItems.ToList().ForEach(data =>
653
                {
654
                    data.Width = ImgListbox.ActualWidth;
655
                    data.Height = ImgListbox.ActualHeight;
656
                });
657

    
658
                if (ImgListbox.Items.Count > 0)
659
                {
660
                    int StartPageIdx = 1;
661
                
662
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
663
                    {
664
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
665
                    }
666
                    else
667
                    {
668
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
669
                    }
670
                }
671
            }
672
            else
673
            {
674
                ImgListbox.UpdateLayout();
675
                ImgListbox.ItemsSource = this._thumbnailItems;
676
            }
677

    
678
            if(ThumbInitialized != null)
679
            {
680
                ThumbInitialized(this, new EventArgs());
681
            }
682
        }
683

    
684
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
685
        {
686
            if (e.ClickCount >= 2)
687
            {
688
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
689

    
690
                GotoPage(selectItem.PageNumber);
691

    
692
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data);
693

    
694
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
695
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
696
                //bool isGO = false;
697

    
698
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
699
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
700
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
701
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
702
                //{
703
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
704
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
705
                //    {
706
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
707
                //    }
708

    
709
                //};
710
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
711

    
712
                //GotoPage(MarkupList.SelectedItem as MarkupList)
713
            }
714
        }
715

    
716
        public class MarkupInfoItemSmall
717
        {
718
            public string Id { get; set; }
719
            public string UserName { get; set; }
720
            public string UserID { get; set; }
721
            public int PageNumber { get; set; }
722
            public string Data { get; set; }
723
            public int Data_Type { get; set; }
724
            public bool IsConsolidate { get; set; }
725
        }
726

    
727
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
728
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
729
        {
730
            get
731
            {
732
                if (_MarkupInfoSmallList == null)
733
                {
734
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
735
                }
736
                return _MarkupInfoSmallList;
737
            }
738
            set
739
            {
740

    
741
                _MarkupInfoSmallList = value;
742
                RaisePropertyChanged("MarkupInfoSmallList");
743
            }
744
        }
745

    
746
        /// <summary>
747
        /// goto page and select item selected by user
748
        /// </summary>
749
        /// <param name="sender"></param>
750
        /// <param name="e"></param>
751
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
752
        {
753
            var clickButtonItem = sender as RadButton;
754
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
755
            {
756
                try
757
                {
758
                    Rect rect = new Rect();
759
                    Point s_point = new Point();
760
                    Point e_point = new Point();
761

    
762
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
763
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
764

    
765
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString()); //언패킹작업
766
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
767
                    {
768
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
769
                            {
770
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
771
                                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));
772
                            }
773
                            break;
774
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
775
                            {
776
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
777
                                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));
778
                            }
779
                            break;
780
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
781
                            {
782
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
783
                                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));
784
                            }
785
                            break;
786
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
787
                            {
788
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
789

    
790
                                foreach (Point A in instance.PointSet)
791
                                {
792
                                    if (s_point == new Point())
793
                                    {
794
                                        s_point = A;
795
                                        e_point = A;
796
                                    }
797
                                    s_point.X = Math.Min(s_point.X, A.X);
798
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
799
                                    e_point.X = Math.Max(e_point.X, A.X);
800
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
801
                                }
802
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
803
                            }
804
                            break;
805
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
806
                            {
807
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
808

    
809
                                foreach (Point A in instance.PointSet)
810
                                {
811
                                    if (s_point == new Point())
812
                                    {
813
                                        s_point = A;
814
                                        e_point = A;
815
                                    }
816
                                    s_point.X = Math.Min(s_point.X, A.X);
817
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
818
                                    e_point.X = Math.Max(e_point.X, A.X);
819
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
820
                                }
821
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
822
                            }
823
                            break;
824
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
825
                            {
826
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
827

    
828
                                foreach (Point A in instance.PointSet)
829
                                {
830
                                    if (s_point == new Point())
831
                                    {
832
                                        s_point = A;
833
                                        e_point = A;
834
                                    }
835
                                    s_point.X = Math.Min(s_point.X, A.X);
836
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
837
                                    e_point.X = Math.Max(e_point.X, A.X);
838
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
839
                                }
840
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
841
                            }
842
                            break;
843
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
844
                            {
845
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
846

    
847
                                foreach (Point A in instance.PointSet)
848
                                {
849
                                    if (s_point == new Point())
850
                                    {
851
                                        s_point = A;
852
                                        e_point = A;
853
                                    }
854
                                    s_point.X = Math.Min(s_point.X, A.X);
855
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
856
                                    e_point.X = Math.Max(e_point.X, A.X);
857
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
858
                                }
859
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
860
                            }
861
                            break;
862
                        default:
863
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
864
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
865
                            break;
866
                    }
867

    
868
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
869
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
870
                }
871
                catch (Exception ex)
872
                {
873
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
874
                }
875
            }
876
        }
877

    
878

    
879
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
880
        {
881
            var clickButtonItem = sender as RadButton;
882
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
883
            {
884
                try
885
                {
886
             
887

    
888
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
889
                    MarkupList.SelectedItem = gaza;
890

    
891
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
892
                }
893
                catch (Exception ex)
894
                {
895
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
896
                }
897
            }
898
        }
899

    
900
        ///// <summary>
901
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
902
        ///// </summary>
903
        ///// <param name="CommentIdList"></param>
904
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
905
        //{
906
        //    var instance = Common.ViewerDataModel.Instance;
907

    
908
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
909

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

    
912
        //    if (commentList.Count() > 0)
913
        //    {
914
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
915
        //        #region markup list grid select items
916

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

    
919
        //        if (infoItem.Count() > 0)
920
        //        {
921

    
922
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
923
        //            gridMarkup.SelectedItems.Clear();
924
        //            gridMarkup.SelectedItems.Add(infoItem.First());
925
        //        }
926

    
927
        //        #endregion
928

    
929
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
930

    
931
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
932
        //        {
933
        //            GotoSelectedMarkup(CommentIdList);
934
        //        }
935
        //        else
936
        //        {
937
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
938

    
939
        //            handler = (snd, evt) =>
940
        //            {
941
        //                GotoSelectedMarkup(CommentIdList);
942
        //                pageNavigator.PageChanged -= handler;
943
        //            };
944

    
945
        //            pageNavigator.PageChanged += handler;
946

    
947
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
948
        //        }
949
        //    }
950
        //}
951

    
952
        ///// <summary>
953
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
954
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
955
        ///// </summary>
956
        ///// <param name="CommentIdList"></param>
957
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
958
        //{
959
        //    var instance = Common.ViewerDataModel.Instance;
960

    
961
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
962
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
963

    
964
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
965
        //    {
966
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
967
        //        commentUserInfo.AddRange(selectOrderComments);
968

    
969
        //        if (commentUserInfo?.Count() > 0)
970
        //        {
971
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
972

    
973
        //            try
974
        //            {
975
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
976
        //                {
977
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
978
        //                    {
979
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
980
        //                    } 
981
                            
982
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
983
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
984
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
985
        //                }
986

    
987
        //                Rect rect = commentUserInfo.First().ItemRect;
988

    
989
        //                foreach (var UserInfo in commentUserInfo)
990
        //                {
991
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
992
        //                }
993

    
994
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
995

    
996
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
997
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
998
        //                //rect.Transform(matrix);
999

    
1000
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1001
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1002
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1003
        //                double positionX = 0;
1004
        //                double positionY = 0;
1005

    
1006
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1007
        //                {
1008
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1009
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1010
        //                }
1011

    
1012
        //                main.zoomAndPanControl.ContentScale = newScale;
1013
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1014
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1015

    
1016
              
1017
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1018

    
1019
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1020

    
1021
        //                if (pageAngle == 90)
1022
        //                {
1023
        //                    pageAngle = 270;
1024
        //                }
1025
        //                else
1026
        //                {
1027
        //                    pageAngle = 90;
1028
        //                }
1029

    
1030
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1031
        //                {
1032
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1033
        //                    rect.Transform(matrix);
1034

    
1035
        //                    main.zoomAndPanControl.ZoomTo(rect);
1036
        //                }
1037
        //                else
1038
        //                {
1039
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1040

    
1041
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1042
        //                    rect.Transform(matrix);
1043

    
1044

    
1045
        //                    main.zoomAndPanControl.ZoomTo(rect);
1046
        //                }
1047
        //            }
1048
        //            catch (Exception ex)
1049
        //            {
1050
        //                main.DialogMessage_Alert(ex.Message, "Error");
1051
        //            }
1052
        //        }
1053
        //    }
1054
        //}
1055

    
1056
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1057
        {
1058
            if (MarkupInfoSmallList.Count == 0)
1059
            {
1060
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1061
                {
1062
                    if (d.MarkupList != null)
1063
                    {
1064
                        d.MarkupList.ForEach(b =>
1065
                        {
1066
                            bool isConsolidate = false;
1067

    
1068
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1069
                            {
1070
                                isConsolidate = true;
1071
                            }
1072

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

    
1075
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1076
                            {
1077
                                Id = b.ID,
1078
                                Data = b.Data,
1079
                                Data_Type = b.Data_Type,
1080
                                PageNumber = b.PageNumber,
1081
                                UserID = d.UserID,
1082
                                UserName = d.UserName,
1083
                                IsConsolidate = isConsolidate
1084

    
1085
                            });
1086
                        });
1087
                    }
1088
                });
1089
                MarkupList.ItemsSource = null;
1090
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1091

    
1092
                FilterUpdate();
1093
            }
1094
        }
1095

    
1096
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1097
        {
1098
            if (MarkupInfoSmallList.Count == 0)
1099
            {
1100
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1101
                {
1102
                    if (d.MarkupList != null)
1103
                    {
1104
                        d.MarkupList.ForEach(b =>
1105
                        {
1106
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1107
                            {
1108
                                Id = b.ID,
1109
                                Data = b.Data,
1110
                                Data_Type = b.Data_Type,
1111
                                PageNumber = b.PageNumber,
1112
                                UserID = d.UserID,
1113
                                UserName = d.UserName,
1114
                            });
1115
                        });
1116
                    }
1117
                });
1118
                MarkupList.ItemsSource = null;
1119
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1120
            }
1121

    
1122
            switch (eventType)
1123
            {
1124
                case Event_Type.Create:
1125
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1126
                    {
1127
                        Id = res.CommentID,
1128
                        Data = res.ConvertData,
1129
                        Data_Type = res.DATA_TYPE,
1130
                        PageNumber = CurrentPage.PageNumber,
1131
                        UserID = App.ViewInfo.UserID,
1132
                        UserName = App.UserName,
1133
                    });
1134
                    break;
1135
                case Event_Type.Delete:
1136
                    if(CommentID == null) //user information list delete btn
1137
                    {
1138
                        foreach (var delItem in item.MarkupList)
1139
                        {
1140
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1141
                        }
1142
                    }
1143
                    else //delete, cut, 
1144
                    {
1145
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1146
                    }                    
1147
                    break;
1148
                case Event_Type.Thumb://이동 회전
1149
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1150
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1151
                    {
1152
                        Id = res.CommentID,
1153
                        Data = res.ConvertData,
1154
                        Data_Type = res.DATA_TYPE,
1155
                        PageNumber = CurrentPage.PageNumber,
1156
                        UserID = App.ViewInfo.UserID,
1157
                        UserName = App.UserName,
1158
                    });
1159
                    break;
1160
                default:
1161
                    break;
1162
            }
1163

    
1164
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1165

    
1166
            bool IsConsolidation = false;
1167
            string UserId = null;
1168

    
1169
            if (commentUser.SelectedValue != null)
1170
            {
1171
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1172
                {
1173
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1174
                }
1175
                else
1176
                {
1177
                    IsConsolidation = true;
1178
                }
1179
            }
1180

    
1181
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1182
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1183
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1184

    
1185
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1186

    
1187
            FilterUpdate();
1188
        }
1189

    
1190
        private void FilterUpdate(string selectUser = null)
1191
        {
1192
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1193

    
1194
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1195
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1196

    
1197

    
1198
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1199
 
1200
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1201
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1202

    
1203
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1204
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1205

    
1206
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1207
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1208

    
1209
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1210
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1211
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1212
        }
1213

    
1214
        
1215

    
1216
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1217
        {
1218
            MarkupList.ItemsSource = null;
1219
            txtSearch.Text = string.Empty;
1220

    
1221
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1222

    
1223
            bool IsConsolidation = false;
1224
            string userName = null;
1225

    
1226
            if (commentUser.SelectedValue != null)
1227
            {
1228
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1229
                {
1230
                    userName = commentUser.SelectedValue.ToString();
1231
                }
1232
                else
1233
                {
1234
                    IsConsolidation = true;
1235
                }
1236
            }
1237

    
1238
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1239
                                   .WhereIf(userName != null, d => d.UserName == userName)
1240
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1241
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1242

    
1243
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1244

    
1245
            FilterUpdate();
1246
        }
1247

    
1248
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1249
        {
1250
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1251
        }
1252

    
1253
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1254
        {
1255
            string search_str = txtSearch.Text;
1256

    
1257
            if(string.IsNullOrWhiteSpace(search_str))
1258
            {
1259
                return;
1260
            }
1261

    
1262
            var sel_type = commentType.SelectedItem;
1263
            var sel_user = commentUser.SelectedItem;
1264
            var sel_page = commentPage.SelectedItem;
1265
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1266
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1267
            if (sel_page != null)
1268
            {
1269
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1270
            }
1271
            if (sel_type != null)
1272
            {
1273
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1274
            }
1275
            if (sel_user != null)
1276
            {
1277
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1278
            }
1279
            foreach (var item in list)
1280
            {
1281
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString());
1282

    
1283
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1284
                {
1285
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1286
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1287
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1288
                        {
1289
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1290

    
1291
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1292
                            {
1293
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1294
                                {
1295
                                    small_list.Add(item);
1296
                                }
1297
                            }
1298
                        }
1299
                        break;
1300
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1301
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1302
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1303
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1304
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1305
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1306
                        {
1307
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1308

    
1309
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1310
                            {
1311
                                if (instance.ArrowText.Contains(search_str))
1312
                                {
1313
                                    small_list.Add(item);
1314
                                }
1315
                            }
1316
                        }
1317
                        break;
1318
                }
1319
            }
1320

    
1321
            MarkupList.ItemsSource = null;
1322
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1323
        }
1324

    
1325
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1326
        {
1327
            if(e.Key == Key.Enter || e.Key == Key.Return)
1328
            {
1329
                btnSearch_Click(sender, new RoutedEventArgs());
1330
            }
1331
        }
1332
    }
1333
}
클립보드 이미지 추가 (최대 크기: 500 MB)