프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 2007ecaa

이력 | 보기 | 이력해설 | 다운로드 (57.8 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.Loaded += Sample_Loaded;
46
            this.Unloaded += Sample_Unloaded;
47
        }
48

    
49
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
50
        {
51
          
52
        }
53

    
54
        private void Sample_Loaded(object sender, RoutedEventArgs e)
55
        {
56
            if(!_Initialize)
57
            {
58
                _Initialize = true;
59
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
60

    
61

    
62
                this.SizeChanged += Sample_SizeChanged;
63
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
64
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);
65
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
66

    
67

    
68
            }            
69
        }
70

    
71
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
72
        {
73
            if (e.WidthChanged)
74
            {
75
                ImgListbox.UpdateLayout();
76
            }
77
        }
78

    
79
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
80
        public CollectionViewSource FilteredThumbnail
81
        {
82
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
83
            set { SetValue(FilteredThumbnailProperty, value); }
84
        }
85

    
86
        public static readonly DependencyProperty CurrentPageProperty 
87
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
88

    
89
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
90
        {
91
            //var owner = d as Sample;
92

    
93
            //if (owner?.UsersCommentPagesList != null)
94
            //{
95
            //    owner.SetCommentPages();
96
            //}
97
        }
98

    
99
        public ThumbnailItem CurrentPage
100
        {
101
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
102
            set { SetValue(CurrentPageProperty, value); }
103
        }
104

    
105
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
106
        private List<DOCPAGE> _PageList = null;
107
        private string _DefaultUri = null;
108
        public int PageCount = 0;
109
        private bool _Initialize;
110

    
111
        public event EventHandler<EventArgs> ThumbInitialized;
112
        public event EventHandler<PageChangeEventArgs> PageChanged;
113
        public event EventHandler<PageChangeEventArgs> PageChanging;
114

    
115
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
116

    
117
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
118
        {
119
            get {
120
                if(_UsersCommentPagesList == null)
121
                {
122
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
123
                }
124

    
125
                return _UsersCommentPagesList; }
126
            set { _UsersCommentPagesList = value; }
127
        }
128

    
129
        public class PageChangeEventArgs : EventArgs
130
        {
131
            public DOCPAGE CurrentPage { get; set; }
132
            public string PageUri { get; set; }
133
            public int PageNumber { get; set; }
134
        }
135
        private bool _IsFitOn { get; set; }
136
        public bool IsFitOn
137
        {
138
            get
139
            {
140
                return _IsFitOn;
141
            }
142
            set
143
            {
144
                _IsFitOn = value;
145
                RaisePropertyChanged("IsFitOn");
146
            }
147
        }
148

    
149
        public void RaisePropertyChanged(string propName)
150
        {
151
            if (PropertyChanged != null)
152
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
153
        }
154

    
155
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
156
        {
157
            App.splashString(ISplashMessage.SAMPLE);
158
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
159
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
160

    
161
            this._PageList = PageList;
162
            this._DefaultUri = DefaultUri;
163

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

    
166
            
167
            //ThumbnailSetAsync();
168
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
169

    
170
            this.PageCount = PageList.Count();
171

    
172
            string endpoint = App.ViewInfo.DocumentItemID + "Thumbnail";
173

    
174
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
175
            wcfServer.IpcThumbnailReceived += WcfServer_IpcThumbnailReceived;
176
            wcfServer.Start();
177

    
178
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
179

    
180
            App.splashScreen.Close();
181
        }
182

    
183
        private void WcfServer_IpcThumbnailReceived(object sender, IpcThumbnailEventArgs e)
184
        {
185
            var items = _thumbnailItems.Where(x => x.PageNumber == e.PageNo);
186

    
187
            if (items.Count() > 0)
188
            {
189
                //Dispatcher.BeginInvoke((Action)delegate ()
190
                //{
191
                    items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
192
                //});
193
            }
194
        }
195

    
196
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
197
        {
198
            Logger.sendCheckLog("rdoCommented_Checked", 1);
199
            SetCommentPages();
200
        }
201

    
202
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
203
        {
204
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
205
            //if (rdoFavoritePages.IsChecked == true)
206
            //    expCommentPages.IsExpanded = false;
207

    
208
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
209
            //if (_FavoriteSet.Count > 0)
210
            //{
211
            //    SetCommentPages(); //수정    
212
            //}
213
            //else
214
            //{
215
            //    rdoAllPages.IsChecked = true;
216
            //    rdoFavoritePages.IsChecked = false;
217
            //}
218
        }
219

    
220
        private async void ShowPageChange(object sender, RoutedEventArgs e)
221
        {
222
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
223
            if (IsInitialized)
224
            {
225
                //ThumbnailSetAsync();
226
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
227
            }
228
        }
229

    
230
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
231
        {
232
            //txtThumbCount.Visibility = Visibility.Collapsed;            
233
        }
234

    
235
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
236
        {
237
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
238
            rdoAllPages.IsChecked = false;
239
            rdoFavoritePages.IsChecked = false;
240
            //txtThumbCount.Visibility = Visibility.Visible;
241
            SetCommentPages();
242
        }
243

    
244
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
245
        {
246
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
247
            {
248
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
249

    
250
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
251
            }
252
        }
253

    
254
        /// <summary>
255
        /// called when image list box's selection is changed
256
        /// </summary>
257
        /// <param name="sender"></param>
258
        /// <param name="e"></param>
259
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
260
        {
261
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
262
            {
263
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
264
            }
265
        }
266

    
267
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
268
        { 
269
                var number = selectItem.PageNumber;
270

    
271
                if (ViewerDataModel.Instance.PageNumber != number)
272
                {
273
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
274

    
275
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
276

    
277
                    PageChanging(this, new PageChangeEventArgs
278
                    {
279
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
280
                        PageNumber = number,
281
                        PageUri = null
282
                    });
283
                }
284
        }
285

    
286
        public bool GotoPageFlag = false;
287

    
288
        /// <summary>
289
        /// 해당 썸네일로 이동
290
        /// </summary>
291
        /// <param name="_pageNumber">이동할 페이지 번호</param>
292
        public void GotoPage(int _pageNumber)
293
        {
294
            try
295
            {
296
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
297

    
298
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
299
                    if (_page.Count() > 0)
300
                    {
301
                        ThumbnailItem thumbnailitem = _page.First();
302
                        if (PageChanging != null)
303
                        {
304

    
305
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
306
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
307
                                ImgListbox.SelectedItem = thumbnailitem;
308
                            });
309
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
310
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
311
                            //    ImgListbox.ScrollIntoView(_itemIndex);
312
                            //else
313
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
314
                        }
315
                    }
316

    
317
                }).ConfigureAwait(true);
318
            }
319
            catch(Exception ex)
320
            {
321
                Logger.sendResLog("GotoPage", ex.Message, 0);
322
            }
323
        }
324

    
325
        /// <summary>
326
        /// 주어진 페이지로 변경한다
327
        /// </summary>
328
        /// <param name="iPageNo">변경할 페이지 번호</param>
329
        public void ChangePage(int iPageNo)
330
        {
331
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
332
            if ((PageChanged != null) && (thumbitem != null))
333
            {
334
                var uri = thumbitem.PageUri.ToString();
335
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
336

    
337
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
338
                if (_DocPages != null)
339
                {
340
                    PageChanged(this, new PageChangeEventArgs
341
                    {
342
                        CurrentPage = _DocPages,
343
                        PageUri = uri,
344
                        PageNumber = thumbitem.PageNumber
345
                    });
346
                    //ImgListbox.SelectedItem = thumbitem;                    
347
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
348
                    
349
                    this.CurrentPage = thumbitem;
350
                }
351
                else
352
                {
353
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
354
                }
355
            }
356
        }
357

    
358
        public void GotoPageTALK(int _pageNumber, int _angle)
359
        {
360
            int _PageNo = -1;
361

    
362
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
363
            {
364
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
365
                if (_page.Count() > 0)
366
                {
367
                    ThumbnailItem _item = _page.First();
368
                    setPageChangeTALK(_item, _angle);
369
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
370
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
371
                }
372
            }
373
        }
374

    
375
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
376
        {
377
            if (thumbnailItem != null)
378
            {
379
                if (PageChanging != null)
380
                {
381
                    ///this.CurrentPage = _NextPage;
382
                    ///_NextPage = thumbnailItem;
383
                    PageChanging(this, new PageChangeEventArgs
384
                    {
385
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
386
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
387
                        PageUri = null
388
                    });
389

    
390
                    var instanceMain = this.ParentOfType<MainWindow>();
391

    
392
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
393

    
394
                    if (rotationNum > 0) // 1, 2, 3
395
                    {
396
                        for (int i = 0; i < rotationNum; i++)
397
                        {
398
                            drawingPannelRotate(true);
399
                        }
400
                    }
401
                    else if (rotationNum < 0)// -1, -2, -3
402
                    {
403
                        for (int i = 0; i < -rotationNum; i++)
404
                        {
405
                            drawingPannelRotate(false);
406
                        }
407
                    }
408
                }
409
            }
410
        }
411

    
412
        public void drawingPannelRotate(bool Flag)
413
        {
414
            var instanceMain = this.ParentOfType<MainWindow>();
415

    
416
            if (Flag)
417
            {
418
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
419
                {
420
                    instanceMain.dzMainMenu.rotate.Angle = 0;
421
                }
422
                else
423
                {
424
                    instanceMain.dzMainMenu.rotate.Angle += 90;
425
                }
426
            }
427
            else
428
            {
429
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
430
                {
431
                    instanceMain.dzMainMenu.rotate.Angle = 270;
432
                }
433
                else
434
                {
435
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
436
                }
437
            }
438

    
439
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
440
            {
441
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
442
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
443
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
444
            }
445

    
446
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
447
            {
448
                instanceMain.dzMainMenu.translate.X = 0;
449
                instanceMain.dzMainMenu.translate.Y = 0;
450
            }
451
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
452
            {
453
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
454
                instanceMain.dzMainMenu.translate.Y = 0;
455
            }
456
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
457
            {
458
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
459
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
460
            }
461
            else
462
            {
463
                instanceMain.dzMainMenu.translate.X = 0;
464
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
465
            }
466

    
467
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
468
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
469
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
470
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
471
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
472
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
473

    
474
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
475
            {
476
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
477

    
478
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
479
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
480
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
481

    
482
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
483
                if (rotationdoc != null)
484
                {
485
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
486
                }
487
                else
488
                {
489
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
490
                }
491
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
492
            });
493
        }
494

    
495
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
496
        {
497
            SetCommentPages();
498
        }
499

    
500
        public async void SetCommentPages(object obj = null)
501
        {
502
            //ThumbnailSetAsync();
503
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
504
        }
505

    
506
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
507
        {
508
            Logger.sendCheckLog("SetCommentList", 1);
509
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
510
            #region 기존 색상 제거 작업
511

    
512
            foreach (var item in this._thumbnailItems)
513
            {
514
                if (item.DisplayColorItems != null)
515
                {
516
                    item.DisplayColorItems.Clear();
517
                }
518
            }
519
            #endregion
520

    
521
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
522
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
523

    
524
            this.UsersCommentPagesList.ToList().ForEach(item =>
525
            {
526
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
527

    
528
                if (_comm.Count() == 0)
529
                {
530
                    _delItem.Add(item);
531
                }
532

    
533
                if (cts != null)
534
                {
535
                    if (cts.Value.IsCancellationRequested)
536
                        return;
537
                }
538
            });
539

    
540
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
541

    
542
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
543
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
544

    
545
            UsersCommentPagesList.ForEach(user =>
546
            {
547
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
548
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
549

    
550
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
551

    
552
                if (_commLst.Count() == 0)
553
                {
554
                    this.UsersCommentPagesList.Add(user);
555
                }
556
                else
557
                {
558
                    if (_commLst.First().PageNumber != user.PageNumber)
559
                        _commLst.First().PageNumber = user.PageNumber;
560
                }
561

    
562
                user.PageNumber.ForEach(page =>
563
                {
564
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
565

    
566
                    if (_items.Count() > 0)
567
                    {
568
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
569
                        
570
                    }
571

    
572
                    if (cts != null)
573
                    {
574
                        if (cts.Value.IsCancellationRequested)
575
                            return;
576
                    }
577
                });
578
            });
579

    
580
            foreach (var item in this._thumbnailItems)
581
            {
582
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
583
            }
584

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

    
588
            if (data.Count() != 0)
589
            {
590
                if (Convert.ToBoolean(data.First().isConSolidation))
591
                {
592
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
593
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
594
                    this.lstSelectComment.ItemsSource = data;
595
                }
596
            }
597

    
598
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
599

    
600
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
601

    
602

    
603
            //var template = this.ImgListbox.ItemTemplate;
604
            //this.ImgListbox.ItemTemplate = null;
605
            //this.ImgListbox.ItemTemplate = template;
606

    
607
        }
608

    
609
        List<int> FilterPages = null;
610

    
611
        private void ThumbnailSetAsync()
612
        {
613
            Logger.sendCheckLog("ThumbnailSet", 1);
614

    
615
            if (FilteredThumbnail == null)
616
            {
617
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
618

    
619
                var pageList = ViewerDataModel.Instance.Document_Info;
620

    
621
                var items = from page in pageList
622
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
623
                            select new ThumbnailItem
624
                            {
625
                                //ImageUri = new Uri(pageLink),
626
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
627
                                PageNumber = page.PAGE_NUMBER,
628
                                Angle = page.PAGE_ANGLE
629
                            };
630

    
631
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
632
                FilteredThumbnail = new CollectionViewSource();
633
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
634

    
635
                FilteredThumbnail.Source = _thumbnailItems;
636

    
637
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
638
                  {
639
                      System.Diagnostics.Debug.WriteLine("ect");
640
                  };
641

    
642
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
643

    
644
                FilteredThumbnail.Filter += (snd, evt) =>
645
                {
646
                    if (FilterPages?.Count() > 0 && evt.Item != null)
647
                    {
648
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
649
                    }
650
                    else
651
                    {
652
                        evt.Accepted = false;
653
                    }
654
                };
655

    
656
            }
657

    
658
            FilterPages.Clear();
659

    
660
            if (rdoAllPages.IsChecked == true)
661
            {
662
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
663
            }
664
            else if (rdoFavoritePages.IsChecked == true)
665
            {
666
                if (_FavoriteSet != null)
667
                {
668
                    FilterPages = (from thumb in _thumbnailItems
669
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
670
                                select thumb.PageNumber).ToList();
671
                }
672
            }
673
            else if (rdoCommentPages.IsChecked == true)
674
            {
675
                if (this.lstSelectComment.ItemsSource != null)
676
                {
677
                    var commentPages = (from commentPage in this.UsersCommentPagesList
678
                                        where commentPage.IsSelected == true
679
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
680

    
681
                    if (commentPages?.Count() > 0)
682
                    {
683
                        FilterPages = (from thumb in _thumbnailItems
684
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
685
                                       select thumb.PageNumber).ToList();
686
                    }
687
                }
688
            }
689

    
690
            if (FilterPages != null)
691
            {
692
                FilteredThumbnail.View.Refresh();
693

    
694
                if (FilterPages.Count() > 0)
695
                {
696
                    if (_thumbnailItems.Count() > 0)
697
                    {
698
                        ImgListbox.SelectedItem = _thumbnailItems[0];
699
                    }
700

    
701
                    //SetCommentList(UsersCommentPagesList.ToList());
702
                }
703
                else
704
                {
705
                    ImgListbox.SelectedItem = null;
706
                }
707

    
708
                if (ThumbInitialized != null)
709
                {
710
                    ThumbInitialized(this, new EventArgs());
711
                    ThumbInitialized = null;
712
                }
713
            }
714
        }
715

    
716

    
717
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
718
        {
719
            if (e.ClickCount >= 2)
720
            {
721
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
722

    
723
                GotoPage(selectItem.PageNumber);
724

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

    
727
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
728
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
729
                //bool isGO = false;
730

    
731
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
732
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
733
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
734
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
735
                //{
736
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
737
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
738
                //    {
739
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
740
                //    }
741

    
742
                //};
743
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
744

    
745
                //GotoPage(MarkupList.SelectedItem as MarkupList)
746
            }
747
        }
748

    
749
        public class MarkupInfoItemSmall
750
        {
751
            public string Id { get; set; }
752
            public string UserName { get; set; }
753
            public string UserID { get; set; }
754
            public int PageNumber { get; set; }
755
            public string Data { get; set; }
756
            public int Data_Type { get; set; }
757
            public bool IsConsolidate { get; set; }
758
        }
759

    
760
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
761
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
762
        {
763
            get
764
            {
765
                if (_MarkupInfoSmallList == null)
766
                {
767
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
768
                }
769
                return _MarkupInfoSmallList;
770
            }
771
            set
772
            {
773

    
774
                _MarkupInfoSmallList = value;
775
                RaisePropertyChanged("MarkupInfoSmallList");
776
            }
777
        }
778

    
779
        /// <summary>
780
        /// goto page and select item selected by user
781
        /// </summary>
782
        /// <param name="sender"></param>
783
        /// <param name="e"></param>
784
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
785
        {
786
            var clickButtonItem = sender as RadButton;
787
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
788
            {
789
                try
790
                {
791
                    Rect rect = new Rect();
792
                    Point s_point = new Point();
793
                    Point e_point = new Point();
794

    
795
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
796
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
797

    
798
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
799
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
800
                    {
801
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
802
                            {
803
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
804
                                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));
805
                            }
806
                            break;
807
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
808
                            {
809
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
810
                                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));
811
                            }
812
                            break;
813
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
814
                            {
815
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
816
                                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));
817
                            }
818
                            break;
819
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
820
                            {
821
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
822

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

    
842
                                foreach (Point A in instance.PointSet)
843
                                {
844
                                    if (s_point == new Point())
845
                                    {
846
                                        s_point = A;
847
                                        e_point = A;
848
                                    }
849
                                    s_point.X = Math.Min(s_point.X, A.X);
850
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
851
                                    e_point.X = Math.Max(e_point.X, A.X);
852
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
853
                                }
854
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
855
                            }
856
                            break;
857
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
858
                            {
859
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
860

    
861
                                foreach (Point A in instance.PointSet)
862
                                {
863
                                    if (s_point == new Point())
864
                                    {
865
                                        s_point = A;
866
                                        e_point = A;
867
                                    }
868
                                    s_point.X = Math.Min(s_point.X, A.X);
869
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
870
                                    e_point.X = Math.Max(e_point.X, A.X);
871
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
872
                                }
873
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
874
                            }
875
                            break;
876
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
877
                            {
878
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
879

    
880
                                foreach (Point A in instance.PointSet)
881
                                {
882
                                    if (s_point == new Point())
883
                                    {
884
                                        s_point = A;
885
                                        e_point = A;
886
                                    }
887
                                    s_point.X = Math.Min(s_point.X, A.X);
888
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
889
                                    e_point.X = Math.Max(e_point.X, A.X);
890
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
891
                                }
892
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
893
                            }
894
                            break;
895
                        default:
896
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
897
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
898
                            break;
899
                    }
900

    
901
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
902
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
903
                }
904
                catch (Exception ex)
905
                {
906
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
907
                }
908
            }
909
        }
910

    
911
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
912
        {
913
            var clickButtonItem = sender as RadButton;
914
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
915
            {
916
                try
917
                {
918
             
919

    
920
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
921
                    MarkupList.SelectedItem = gaza;
922

    
923
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
924
                }
925
                catch (Exception ex)
926
                {
927
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
928
                }
929
            }
930
        }
931

    
932
        ///// <summary>
933
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
934
        ///// </summary>
935
        ///// <param name="CommentIdList"></param>
936
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
937
        //{
938
        //    var instance = Common.ViewerDataModel.Instance;
939

    
940
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
941

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

    
944
        //    if (commentList.Count() > 0)
945
        //    {
946
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
947
        //        #region markup list grid select items
948

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

    
951
        //        if (infoItem.Count() > 0)
952
        //        {
953

    
954
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
955
        //            gridMarkup.SelectedItems.Clear();
956
        //            gridMarkup.SelectedItems.Add(infoItem.First());
957
        //        }
958

    
959
        //        #endregion
960

    
961
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
962

    
963
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
964
        //        {
965
        //            GotoSelectedMarkup(CommentIdList);
966
        //        }
967
        //        else
968
        //        {
969
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
970

    
971
        //            handler = (snd, evt) =>
972
        //            {
973
        //                GotoSelectedMarkup(CommentIdList);
974
        //                pageNavigator.PageChanged -= handler;
975
        //            };
976

    
977
        //            pageNavigator.PageChanged += handler;
978

    
979
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
980
        //        }
981
        //    }
982
        //}
983

    
984
        ///// <summary>
985
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
986
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
987
        ///// </summary>
988
        ///// <param name="CommentIdList"></param>
989
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
990
        //{
991
        //    var instance = Common.ViewerDataModel.Instance;
992

    
993
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
994
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
995

    
996
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
997
        //    {
998
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
999
        //        commentUserInfo.AddRange(selectOrderComments);
1000

    
1001
        //        if (commentUserInfo?.Count() > 0)
1002
        //        {
1003
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1004

    
1005
        //            try
1006
        //            {
1007
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1008
        //                {
1009
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1010
        //                    {
1011
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1012
        //                    } 
1013
                            
1014
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1015
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1016
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1017
        //                }
1018

    
1019
        //                Rect rect = commentUserInfo.First().ItemRect;
1020

    
1021
        //                foreach (var UserInfo in commentUserInfo)
1022
        //                {
1023
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1024
        //                }
1025

    
1026
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1027

    
1028
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1029
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1030
        //                //rect.Transform(matrix);
1031

    
1032
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1033
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1034
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1035
        //                double positionX = 0;
1036
        //                double positionY = 0;
1037

    
1038
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1039
        //                {
1040
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1041
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1042
        //                }
1043

    
1044
        //                main.zoomAndPanControl.ContentScale = newScale;
1045
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1046
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1047

    
1048
              
1049
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1050

    
1051
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1052

    
1053
        //                if (pageAngle == 90)
1054
        //                {
1055
        //                    pageAngle = 270;
1056
        //                }
1057
        //                else
1058
        //                {
1059
        //                    pageAngle = 90;
1060
        //                }
1061

    
1062
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1063
        //                {
1064
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1065
        //                    rect.Transform(matrix);
1066

    
1067
        //                    main.zoomAndPanControl.ZoomTo(rect);
1068
        //                }
1069
        //                else
1070
        //                {
1071
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1072

    
1073
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1074
        //                    rect.Transform(matrix);
1075

    
1076

    
1077
        //                    main.zoomAndPanControl.ZoomTo(rect);
1078
        //                }
1079
        //            }
1080
        //            catch (Exception ex)
1081
        //            {
1082
        //                main.DialogMessage_Alert(ex.Message, "Error");
1083
        //            }
1084
        //        }
1085
        //    }
1086
        //}
1087

    
1088
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1089
        {
1090
            if (MarkupInfoSmallList.Count == 0)
1091
            {
1092
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1093
                {
1094
                    if (d.MarkupList != null)
1095
                    {
1096
                        d.MarkupList.ForEach(b =>
1097
                        {
1098
                            bool isConsolidate = false;
1099

    
1100
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1101
                            {
1102
                                isConsolidate = true;
1103
                            }
1104

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

    
1107
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1108
                            {
1109
                                Id = b.ID,
1110
                                Data = b.Data,
1111
                                Data_Type = b.Data_Type,
1112
                                PageNumber = b.PageNumber,
1113
                                UserID = d.UserID,
1114
                                UserName = d.UserName,
1115
                                IsConsolidate = isConsolidate
1116

    
1117
                            });
1118
                        });
1119
                    }
1120
                });
1121
                MarkupList.ItemsSource = null;
1122
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1123

    
1124
                FilterUpdate();
1125
            }
1126
        }
1127

    
1128
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1129
        {
1130
            if (MarkupInfoSmallList.Count == 0)
1131
            {
1132
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1133
                {
1134
                    if (d.MarkupList != null)
1135
                    {
1136
                        d.MarkupList.ForEach(b =>
1137
                        {
1138
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1139
                            {
1140
                                Id = b.ID,
1141
                                Data = b.Data,
1142
                                Data_Type = b.Data_Type,
1143
                                PageNumber = b.PageNumber,
1144
                                UserID = d.UserID,
1145
                                UserName = d.UserName,
1146
                            });
1147
                        });
1148
                    }
1149
                });
1150
                MarkupList.ItemsSource = null;
1151
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1152
            }
1153

    
1154
            switch (eventType)
1155
            {
1156
                case Event_Type.Create:
1157
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1158
                    {
1159
                        Id = res.CommentID,
1160
                        Data = res.ConvertData,
1161
                        Data_Type = res.DATA_TYPE,
1162
                        PageNumber = CurrentPage.PageNumber,
1163
                        UserID = App.ViewInfo.UserID,
1164
                        UserName = App.UserName,
1165
                    });
1166
                    break;
1167
                case Event_Type.Delete:
1168
                    if(CommentID == null) //user information list delete btn
1169
                    {
1170
                        foreach (var delItem in item.MarkupList)
1171
                        {
1172
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1173
                        }
1174
                    }
1175
                    else //delete, cut, 
1176
                    {
1177
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1178
                    }                    
1179
                    break;
1180
                case Event_Type.Thumb://이동 회전
1181
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1182
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1183
                    {
1184
                        Id = res.CommentID,
1185
                        Data = res.ConvertData,
1186
                        Data_Type = res.DATA_TYPE,
1187
                        PageNumber = CurrentPage.PageNumber,
1188
                        UserID = App.ViewInfo.UserID,
1189
                        UserName = App.UserName,
1190
                    });
1191
                    break;
1192
                default:
1193
                    break;
1194
            }
1195

    
1196
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1197

    
1198
            bool IsConsolidation = false;
1199
            string UserId = null;
1200

    
1201
            if (commentUser.SelectedValue != null)
1202
            {
1203
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1204
                {
1205
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1206
                }
1207
                else
1208
                {
1209
                    IsConsolidation = true;
1210
                }
1211
            }
1212

    
1213
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1214
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1215
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1216

    
1217
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1218

    
1219
            FilterUpdate();
1220
        }
1221

    
1222
        private void FilterUpdate(string selectUser = null)
1223
        {
1224
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1225

    
1226
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1227
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1228

    
1229

    
1230
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1231
 
1232
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1233
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1234

    
1235
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1236
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1237

    
1238
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1239
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1240

    
1241
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1242
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1243
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1244
        }
1245

    
1246
        
1247

    
1248
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1249
        {
1250
            MarkupList.ItemsSource = null;
1251
            txtSearch.Text = string.Empty;
1252

    
1253
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1254

    
1255
            bool IsConsolidation = false;
1256
            string userName = null;
1257

    
1258
            if (commentUser.SelectedValue != null)
1259
            {
1260
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1261
                {
1262
                    userName = commentUser.SelectedValue.ToString();
1263
                }
1264
                else
1265
                {
1266
                    IsConsolidation = true;
1267
                }
1268
            }
1269

    
1270
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1271
                                   .WhereIf(userName != null, d => d.UserName == userName)
1272
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1273
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1274

    
1275
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1276

    
1277
            FilterUpdate();
1278
        }
1279

    
1280
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1281
        {
1282
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1283
        }
1284

    
1285
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1286
        {
1287
            string search_str = txtSearch.Text;
1288

    
1289
            if(string.IsNullOrWhiteSpace(search_str))
1290
            {
1291
                return;
1292
            }
1293

    
1294
            var sel_type = commentType.SelectedItem;
1295
            var sel_user = commentUser.SelectedItem;
1296
            var sel_page = commentPage.SelectedItem;
1297
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1298
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1299
            if (sel_page != null)
1300
            {
1301
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1302
            }
1303
            if (sel_type != null)
1304
            {
1305
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1306
            }
1307
            if (sel_user != null)
1308
            {
1309
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1310
            }
1311
            foreach (var item in list)
1312
            {
1313
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1314

    
1315
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1316
                {
1317
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1318
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1319
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1320
                        {
1321
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1322

    
1323
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1324
                            {
1325
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1326
                                {
1327
                                    small_list.Add(item);
1328
                                }
1329
                            }
1330
                        }
1331
                        break;
1332
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1333
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1334
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1335
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1336
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1337
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1338
                        {
1339
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1340

    
1341
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1342
                            {
1343
                                if (instance.ArrowText.Contains(search_str))
1344
                                {
1345
                                    small_list.Add(item);
1346
                                }
1347
                            }
1348
                        }
1349
                        break;
1350
                }
1351
            }
1352

    
1353
            MarkupList.ItemsSource = null;
1354
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1355
        }
1356

    
1357
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1358
        {
1359
            if(e.Key == Key.Enter || e.Key == Key.Return)
1360
            {
1361
                btnSearch_Click(sender, new RoutedEventArgs());
1362
            }
1363
        }
1364

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