프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 873011c4

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

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

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

    
34

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

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

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

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

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

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

    
70

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

    
76

    
77
            }            
78
        }
79

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

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

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

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

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

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

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

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

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

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

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

    
136
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
137

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

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

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

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

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

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

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

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

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

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

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

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

    
202
            App.splashScreen.Close();
203

    
204
        }
205

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

    
210
            if (items.Count() > 0)
211
            {
212
                //Dispatcher.BeginInvoke((Action)delegate ()
213
                //{
214
                items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
215
                System.Diagnostics.Debug.WriteLine($"no:{e.PageNo} {e.Path}");
216

    
217
                if(e.IsLast)
218
                {
219
                    (sender as IIpc.IIpcServer).IpcThumbnailReceived -= WcfServer_IpcThumbnailReceived;
220
                    //(sender as IIpc.IIpcServer).Stop();
221
                }
222

    
223
                //if (e.PageNo > 2 && ImgListbox.Items.Count > 0)
224
                //{
225

    
226
                //    ImgListbox.IsScrollIntoViewEnabled = true;
227
                //    //ImgListbox.BringIntoView();
228
                //    ImgListbox.ScrollIntoView(0);
229
                //}
230

    
231
                //});
232
            }
233
        }
234

    
235
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
236
        {
237
            Logger.sendCheckLog("rdoCommented_Checked", 1);
238
            SetCommentPages();
239
        }
240

    
241
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
242
        {
243
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
244
            //if (rdoFavoritePages.IsChecked == true)
245
            //    expCommentPages.IsExpanded = false;
246

    
247
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
248
            //if (_FavoriteSet.Count > 0)
249
            //{
250
            //    SetCommentPages(); //수정    
251
            //}
252
            //else
253
            //{
254
            //    rdoAllPages.IsChecked = true;
255
            //    rdoFavoritePages.IsChecked = false;
256
            //}
257
        }
258

    
259
        private async void ShowPageChange(object sender, RoutedEventArgs e)
260
        {
261
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
262
            if (IsInitialized)
263
            {
264
                //ThumbnailSetAsync();
265
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
266
            }
267
        }
268

    
269
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
270
        {
271
            //txtThumbCount.Visibility = Visibility.Collapsed;            
272
        }
273

    
274
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
275
        {
276
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
277
            rdoAllPages.IsChecked = false;
278
            rdoFavoritePages.IsChecked = false;
279
            //txtThumbCount.Visibility = Visibility.Visible;
280
            SetCommentPages();
281
        }
282

    
283
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
284
        {
285
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
286
            {
287
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
288

    
289
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
290
            }
291
        }
292

    
293
        /// <summary>
294
        /// called when image list box's selection is changed
295
        /// </summary>
296
        /// <param name="sender"></param>
297
        /// <param name="e"></param>
298
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
299
        {
300

    
301
            //Search Panel의 Key Up/Down 추가로 인한 if 문 주석
302
            //if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
303
            //{
304
            //    if (ImgListbox.SelectedItem != null)
305
            //    {
306
            //        PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
307
            //    }
308
            //}
309

    
310
            if (ImgListbox.SelectedItem != null)
311
            {
312
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
313
            }
314
        }
315

    
316
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
317
        { 
318
                var number = selectItem.PageNumber;
319

    
320
                if (ViewerDataModel.Instance.SyncPageNumber != number)
321
                {
322
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
323

    
324
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
325

    
326
                    PageChanging(this, new PageChangeEventArgs
327
                    {
328
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
329
                        PageNumber = number,
330
                        PageUri = null
331
                    });
332
                }
333
        }
334

    
335
        public bool GotoPageFlag = false;
336

    
337
        /// <summary>
338
        /// 해당 썸네일로 이동
339
        /// </summary>
340
        /// <param name="_pageNumber">이동할 페이지 번호</param>
341
        public void GotoPage(int _pageNumber)
342
        {
343
            try
344
            {
345
                //System.Threading.Tasks.Task.Factory.StartNew(() => { 
346

    
347
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
348
                    if (_page.Count() > 0)
349
                    {
350
                        ThumbnailItem thumbnailitem = _page.First();
351
                        if (PageChanging != null)
352
                        {
353

    
354
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
355
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
356

    
357
                                ImgListbox.SelectedItem = thumbnailitem;
358

    
359

    
360
                                if (navigationTab.SelectedIndex != 0)
361
                                {
362
                                    PageChange(thumbnailitem);
363
                                }
364

    
365
                            });
366
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
367
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
368
                            //    ImgListbox.ScrollIntoView(_itemIndex);
369
                            //else
370
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
371
                        }
372
                    }
373

    
374
                //}).ConfigureAwait(false);
375
            }
376
            catch(Exception ex)
377
            {
378
                //Logger.sendResLog("GotoPage", ex.Message, 0);
379
            }
380
        }
381

    
382
        /// <summary>
383
        /// 주어진 페이지로 변경한다
384
        /// </summary>
385
        /// <param name="iPageNo">변경할 페이지 번호</param>
386
        public void ChangePage(int iPageNo)
387
        {
388
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
389
            if ((PageChanged != null) && (thumbitem != null))
390
            {
391
                var uri = thumbitem.PageUri.ToString();
392
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
393

    
394
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
395
                if (_DocPages != null)
396
                {
397
                    PageChanged(this, new PageChangeEventArgs
398
                    {
399
                        CurrentPage = _DocPages,
400
                        PageUri = uri,
401
                        PageNumber = thumbitem.PageNumber
402
                    });
403
                    //ImgListbox.SelectedItem = thumbitem;                    
404
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
405
                    
406
                    this.CurrentPage = thumbitem;
407
                }
408
                else
409
                {
410
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
411
                }
412
            }
413
        }
414

    
415
        public void GotoPageTALK(int _pageNumber, int _angle)
416
        {
417
            int _PageNo = -1;
418

    
419
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
420
            {
421
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
422
                if (_page.Count() > 0)
423
                {
424
                    ThumbnailItem _item = _page.First();
425
                    setPageChangeTALK(_item, _angle);
426
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
427
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
428
                }
429
            }
430
        }
431

    
432
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
433
        {
434
            if (thumbnailItem != null)
435
            {
436
                if (PageChanging != null)
437
                {
438
                    ///this.CurrentPage = _NextPage;
439
                    ///_NextPage = thumbnailItem;
440
                    PageChanging(this, new PageChangeEventArgs
441
                    {
442
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
443
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
444
                        PageUri = null
445
                    });
446

    
447
                    var instanceMain = this.ParentOfType<MainWindow>();
448

    
449
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
450

    
451
                    if (rotationNum > 0) // 1, 2, 3
452
                    {
453
                        for (int i = 0; i < rotationNum; i++)
454
                        {
455
                            drawingPannelRotate(true);
456
                        }
457
                    }
458
                    else if (rotationNum < 0)// -1, -2, -3
459
                    {
460
                        for (int i = 0; i < -rotationNum; i++)
461
                        {
462
                            drawingPannelRotate(false);
463
                        }
464
                    }
465
                }
466
            }
467
        }
468

    
469
        public void drawingPannelRotate(bool Flag)
470
        {
471
            var instanceMain = this.ParentOfType<MainWindow>();
472

    
473
            if (Flag)
474
            {
475
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
476
                {
477
                    instanceMain.dzMainMenu.rotate.Angle = 0;
478
                }
479
                else
480
                {
481
                    instanceMain.dzMainMenu.rotate.Angle += 90;
482
                }
483
            }
484
            else
485
            {
486
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
487
                {
488
                    instanceMain.dzMainMenu.rotate.Angle = 270;
489
                }
490
                else
491
                {
492
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
493
                }
494
            }
495

    
496
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
497
            {
498
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
499
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
500
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
501
            }
502

    
503
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
504
            {
505
                instanceMain.dzMainMenu.translate.X = 0;
506
                instanceMain.dzMainMenu.translate.Y = 0;
507
            }
508
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
509
            {
510
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
511
                instanceMain.dzMainMenu.translate.Y = 0;
512
            }
513
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
514
            {
515
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
516
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
517
            }
518
            else
519
            {
520
                instanceMain.dzMainMenu.translate.X = 0;
521
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
522
            }
523

    
524
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
525
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
526
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
527
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
528
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
529
            ViewerDataModel.Instance.MarkupAngle = instanceMain.dzMainMenu.rotate.Angle;
530

    
531
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
532
            {
533
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
534

    
535
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
536
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
537
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
538

    
539
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
540
                if (rotationdoc != null)
541
                {
542
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
543
                }
544
                else
545
                {
546
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
547
                }
548
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
549
            });
550
        }
551

    
552
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
553
        {
554
            SetCommentPages();
555
        }
556

    
557
        public async void SetCommentPages(object obj = null)
558
        {
559
            //ThumbnailSetAsync();
560
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
561
        }
562

    
563
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
564
        {
565
            Logger.sendCheckLog("SetCommentList", 1);
566
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
567
            #region 기존 색상 제거 작업
568

    
569
            foreach (var item in this._thumbnailItems)
570
            {
571
                if (item.DisplayColorItems != null)
572
                {
573
                    item.DisplayColorItems.Clear();
574
                }
575
            }
576
            #endregion
577

    
578
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
579
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
580

    
581
            this.UsersCommentPagesList.ToList().ForEach(item =>
582
            {
583
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
584

    
585
                if (_comm.Count() == 0)
586
                {
587
                    _delItem.Add(item);
588
                }
589

    
590
                if (cts != null)
591
                {
592
                    if (cts.Value.IsCancellationRequested)
593
                        return;
594
                }
595
            });
596

    
597
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
598

    
599
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
600
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
601

    
602
            UsersCommentPagesList.ForEach(user =>
603
            {
604
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
605
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
606

    
607
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
608

    
609
                if (_commLst.Count() == 0)
610
                {
611
                    this.UsersCommentPagesList.Add(user);
612
                }
613
                else
614
                {
615
                    if (_commLst.First().PageNumber != user.PageNumber)
616
                        _commLst.First().PageNumber = user.PageNumber;
617
                }
618

    
619
                user.PageNumber.ForEach(page =>
620
                {
621
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
622

    
623
                    if (_items.Count() > 0)
624
                    {
625
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
626
                        
627
                    }
628

    
629
                    if (cts != null)
630
                    {
631
                        if (cts.Value.IsCancellationRequested)
632
                            return;
633
                    }
634
                });
635
            });
636

    
637
            foreach (var item in this._thumbnailItems)
638
            {
639
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
640
            }
641

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

    
645
            if (data.Count() != 0)
646
            {
647
                if (Convert.ToBoolean(data.First().isConSolidation))
648
                {
649
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
650
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
651
                    this.lstSelectComment.ItemsSource = data;
652
                }
653
            }
654

    
655
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
656
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
657

    
658

    
659
            //var template = this.ImgListbox.ItemTemplate;
660
            //this.ImgListbox.ItemTemplate = null;
661
            //this.ImgListbox.ItemTemplate = template;
662

    
663
        }
664

    
665
        List<int> FilterPages = null;
666

    
667
        private void ThumbnailSetAsync()
668
        {
669
            Logger.sendCheckLog("ThumbnailSet", 1);
670

    
671
            if (FilteredThumbnail == null)
672
            {
673
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
674

    
675
                var pageList = ViewerDataModel.Instance.Document_Info;
676

    
677
                var items = from page in pageList
678
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
679
                            select new ThumbnailItem
680
                            {
681
                                //ImageUri = new Uri(pageLink),
682
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
683
                                PageNumber = page.PAGE_NUMBER,
684
                                Angle = page.PAGE_ANGLE
685
                            };
686

    
687
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
688
                FilteredThumbnail = new CollectionViewSource();
689
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
690

    
691
                FilteredThumbnail.Source = _thumbnailItems;
692

    
693
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
694
                  {
695
                      System.Diagnostics.Debug.WriteLine("ect");
696
                  };
697

    
698
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
699

    
700
                FilteredThumbnail.Filter += (snd, evt) =>
701
                {
702
                    if (FilterPages?.Count() > 0 && evt.Item != null)
703
                    {
704
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
705
                    }
706
                    else
707
                    {
708
                        evt.Accepted = false;
709
                    }
710
                };
711

    
712
            }
713

    
714
            FilterPages.Clear();
715

    
716
            if (rdoAllPages.IsChecked == true)
717
            {
718
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
719
            }
720
            else if (rdoFavoritePages.IsChecked == true)
721
            {
722
                if (_FavoriteSet != null)
723
                {
724
                    FilterPages = (from thumb in _thumbnailItems
725
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
726
                                select thumb.PageNumber).ToList();
727
                }
728
            }
729
            else if (rdoCommentPages.IsChecked == true)
730
            {
731
                if (this.lstSelectComment.ItemsSource != null)
732
                {
733
                    var commentPages = (from commentPage in this.UsersCommentPagesList
734
                                        where commentPage.IsSelected == true
735
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
736

    
737
                    if (commentPages?.Count() > 0)
738
                    {
739
                        FilterPages = (from thumb in _thumbnailItems
740
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
741
                                       select thumb.PageNumber).ToList();
742
                    }
743
                }
744
            }
745

    
746
            if (FilterPages != null)
747
            {
748
                if(FilteredThumbnail == null)
749
                {
750
                    System.Diagnostics.Debug.WriteLine("filter null");
751
                }
752

    
753
                if (FilteredThumbnail.View == null)
754
                {
755
                    System.Diagnostics.Debug.WriteLine("filter null");
756
                }
757

    
758
                FilteredThumbnail.View.Refresh();
759

    
760
                if (FilterPages.Count() > 0)
761
                {
762
                    if (_thumbnailItems.Count() > 0)
763
                    {
764
                        ImgListbox.SelectedItem = _thumbnailItems[0];
765
                    }
766

    
767
                    //SetCommentList(UsersCommentPagesList.ToList());
768
                }
769
                else
770
                {
771
                    ImgListbox.SelectedItem = null;
772
                }
773

    
774
                if (ThumbInitialized != null)
775
                {
776
                    ThumbInitialized(this, new EventArgs());
777
                    ThumbInitialized = null;
778
                }
779
            }
780
        }
781

    
782

    
783
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
784
        {
785
            if (e.ClickCount >= 2)
786
            {
787
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
788

    
789
                GotoPage(selectItem.PageNumber);
790

    
791
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.NewMarkupCancelToken());
792

    
793
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
794
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
795
                //bool isGO = false;
796

    
797
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
798
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
799
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
800
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
801
                //{
802
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
803
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
804
                //    {
805
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
806
                //    }
807

    
808
                //};
809
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
810

    
811
                //GotoPage(MarkupList.SelectedItem as MarkupList)
812
            }
813
        }
814

    
815
        public class MarkupInfoItemSmall
816
        {
817
            public string Id { get; set; }
818
            public string UserName { get; set; }
819
            public string UserID { get; set; }
820
            public int PageNumber { get; set; }
821
            public string Data { get; set; }
822
            public int Data_Type { get; set; }
823
            public bool IsConsolidate { get; set; }
824
        }
825

    
826
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
827
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
828
        {
829
            get
830
            {
831
                if (_MarkupInfoSmallList == null)
832
                {
833
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
834
                }
835
                return _MarkupInfoSmallList;
836
            }
837
            set
838
            {
839

    
840
                _MarkupInfoSmallList = value;
841
                RaisePropertyChanged("MarkupInfoSmallList");
842
            }
843
        }
844

    
845
        /// <summary>
846
        /// goto page and select item selected by user
847
        /// </summary>
848
        /// <param name="sender"></param>
849
        /// <param name="e"></param>
850
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
851
        {
852
            var clickButtonItem = sender as RadButton;
853
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
854
            {
855
                try
856
                {
857
                    Rect rect = new Rect();
858
                    Point s_point = new Point();
859
                    Point e_point = new Point();
860

    
861
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
862
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
863

    
864
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.NewMarkupCancelToken()); //언패킹작업
865
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
866
                    {
867
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
868
                            {
869
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
870
                                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));
871
                            }
872
                            break;
873
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
874
                            {
875
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
876
                                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));
877
                            }
878
                            break;
879
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
880
                            {
881
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
882
                                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));
883
                            }
884
                            break;
885
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
886
                            {
887
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
888

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

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

    
927
                                foreach (Point A in instance.PointSet)
928
                                {
929
                                    if (s_point == new Point())
930
                                    {
931
                                        s_point = A;
932
                                        e_point = A;
933
                                    }
934
                                    s_point.X = Math.Min(s_point.X, A.X);
935
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
936
                                    e_point.X = Math.Max(e_point.X, A.X);
937
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
938
                                }
939
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
940
                            }
941
                            break;
942
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
943
                            {
944
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
945

    
946
                                foreach (Point A in instance.PointSet)
947
                                {
948
                                    if (s_point == new Point())
949
                                    {
950
                                        s_point = A;
951
                                        e_point = A;
952
                                    }
953
                                    s_point.X = Math.Min(s_point.X, A.X);
954
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
955
                                    e_point.X = Math.Max(e_point.X, A.X);
956
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
957
                                }
958
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
959
                            }
960
                            break;
961
                        default:
962
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
963
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
964
                            break;
965
                    }
966

    
967
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
968
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
969
                }
970
                catch (Exception ex)
971
                {
972
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
973
                }
974
            }
975
        }
976

    
977
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
978
        {
979
            var clickButtonItem = sender as RadButton;
980
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
981
            {
982
                try
983
                {
984
             
985

    
986
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
987
                    MarkupList.SelectedItem = gaza;
988

    
989
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
990
                }
991
                catch (Exception ex)
992
                {
993
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
994
                }
995
            }
996
        }
997

    
998
        ///// <summary>
999
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
1000
        ///// </summary>
1001
        ///// <param name="CommentIdList"></param>
1002
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
1003
        //{
1004
        //    var instance = Common.ViewerDataModel.Instance;
1005

    
1006
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
1007

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

    
1010
        //    if (commentList.Count() > 0)
1011
        //    {
1012
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
1013
        //        #region markup list grid select items
1014

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

    
1017
        //        if (infoItem.Count() > 0)
1018
        //        {
1019

    
1020
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
1021
        //            gridMarkup.SelectedItems.Clear();
1022
        //            gridMarkup.SelectedItems.Add(infoItem.First());
1023
        //        }
1024

    
1025
        //        #endregion
1026

    
1027
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
1028

    
1029
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
1030
        //        {
1031
        //            GotoSelectedMarkup(CommentIdList);
1032
        //        }
1033
        //        else
1034
        //        {
1035
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
1036

    
1037
        //            handler = (snd, evt) =>
1038
        //            {
1039
        //                GotoSelectedMarkup(CommentIdList);
1040
        //                pageNavigator.PageChanged -= handler;
1041
        //            };
1042

    
1043
        //            pageNavigator.PageChanged += handler;
1044

    
1045
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
1046
        //        }
1047
        //    }
1048
        //}
1049

    
1050
        ///// <summary>
1051
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
1052
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
1053
        ///// </summary>
1054
        ///// <param name="CommentIdList"></param>
1055
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
1056
        //{
1057
        //    var instance = Common.ViewerDataModel.Instance;
1058

    
1059
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1060
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1061

    
1062
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1063
        //    {
1064
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1065
        //        commentUserInfo.AddRange(selectOrderComments);
1066

    
1067
        //        if (commentUserInfo?.Count() > 0)
1068
        //        {
1069
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1070

    
1071
        //            try
1072
        //            {
1073
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1074
        //                {
1075
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1076
        //                    {
1077
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1078
        //                    } 
1079
                            
1080
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1081
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1082
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1083
        //                }
1084

    
1085
        //                Rect rect = commentUserInfo.First().ItemRect;
1086

    
1087
        //                foreach (var UserInfo in commentUserInfo)
1088
        //                {
1089
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1090
        //                }
1091

    
1092
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1093

    
1094
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1095
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1096
        //                //rect.Transform(matrix);
1097

    
1098
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1099
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1100
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1101
        //                double positionX = 0;
1102
        //                double positionY = 0;
1103

    
1104
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1105
        //                {
1106
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1107
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1108
        //                }
1109

    
1110
        //                main.zoomAndPanControl.ContentScale = newScale;
1111
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1112
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1113

    
1114
              
1115
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1116

    
1117
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1118

    
1119
        //                if (pageAngle == 90)
1120
        //                {
1121
        //                    pageAngle = 270;
1122
        //                }
1123
        //                else
1124
        //                {
1125
        //                    pageAngle = 90;
1126
        //                }
1127

    
1128
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1129
        //                {
1130
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1131
        //                    rect.Transform(matrix);
1132

    
1133
        //                    main.zoomAndPanControl.ZoomTo(rect);
1134
        //                }
1135
        //                else
1136
        //                {
1137
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1138

    
1139
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1140
        //                    rect.Transform(matrix);
1141

    
1142

    
1143
        //                    main.zoomAndPanControl.ZoomTo(rect);
1144
        //                }
1145
        //            }
1146
        //            catch (Exception ex)
1147
        //            {
1148
        //                main.DialogMessage_Alert(ex.Message, "Error");
1149
        //            }
1150
        //        }
1151
        //    }
1152
        //}
1153

    
1154
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1155
        {
1156
            if (MarkupInfoSmallList.Count == 0)
1157
            {
1158
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1159
                {
1160
                    if (d.MarkupList != null)
1161
                    {
1162
                        d.MarkupList.ForEach(b =>
1163
                        {
1164
                            bool isConsolidate = false;
1165

    
1166
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1167
                            {
1168
                                isConsolidate = true;
1169
                            }
1170

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

    
1173
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1174
                            {
1175
                                Id = b.ID,
1176
                                Data = b.Data,
1177
                                Data_Type = b.Data_Type,
1178
                                PageNumber = b.PageNumber,
1179
                                UserID = d.UserID,
1180
                                UserName = d.UserName,
1181
                                IsConsolidate = isConsolidate
1182

    
1183
                            });
1184
                        });
1185
                    }
1186
                });
1187
                MarkupList.ItemsSource = null;
1188
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1189

    
1190
                FilterUpdate();
1191
            }
1192
        }
1193

    
1194
        public void MarkupListUpdate(MarkupReturn res, EventType eventType, string CommentID, MarkupInfoItem item)
1195
        {
1196
            if (MarkupInfoSmallList.Count == 0)
1197
            {
1198
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1199
                {
1200
                    if (d.MarkupList != null)
1201
                    {
1202
                        d.MarkupList.ForEach(b =>
1203
                        {
1204
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1205
                            {
1206
                                Id = b.ID,
1207
                                Data = b.Data,
1208
                                Data_Type = b.Data_Type,
1209
                                PageNumber = b.PageNumber,
1210
                                UserID = d.UserID,
1211
                                UserName = d.UserName,
1212
                            });
1213
                        });
1214
                    }
1215
                });
1216
                MarkupList.ItemsSource = null;
1217
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1218
            }
1219

    
1220
            switch (eventType)
1221
            {
1222
                case EventType.Create:
1223
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1224
                    {
1225
                        Id = res.CommentID,
1226
                        Data = res.ConvertData,
1227
                        Data_Type = res.DATA_TYPE,
1228
                        PageNumber = CurrentPage.PageNumber,
1229
                        UserID = App.ViewInfo.UserID,
1230
                        UserName = App.UserName,
1231
                    });
1232
                    break;
1233
                case EventType.Delete:
1234
                    if(CommentID == null) //user information list delete btn
1235
                    {
1236
                        foreach (var delItem in item.MarkupList)
1237
                        {
1238
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1239
                        }
1240
                    }
1241
                    else //delete, cut, 
1242
                    {
1243
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1244
                    }                    
1245
                    break;
1246
                case EventType.Operation://이동 회전
1247
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1248
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1249
                    {
1250
                        Id = res.CommentID,
1251
                        Data = res.ConvertData,
1252
                        Data_Type = res.DATA_TYPE,
1253
                        PageNumber = CurrentPage.PageNumber,
1254
                        UserID = App.ViewInfo.UserID,
1255
                        UserName = App.UserName,
1256
                    });
1257
                    break;
1258
                default:
1259
                    break;
1260
            }
1261

    
1262
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1263

    
1264
            bool IsConsolidation = false;
1265
            string UserId = null;
1266

    
1267
            if (commentUser.SelectedValue != null)
1268
            {
1269
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1270
                {
1271
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1272
                }
1273
                else
1274
                {
1275
                    IsConsolidation = true;
1276
                }
1277
            }
1278

    
1279
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1280
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1281
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1282

    
1283
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1284

    
1285
            FilterUpdate();
1286
        }
1287

    
1288
        private void FilterUpdate(string selectUser = null)
1289
        {
1290
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1291

    
1292
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1293
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1294

    
1295

    
1296
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1297
 
1298
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1299
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1300

    
1301
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1302
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1303

    
1304
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1305
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1306

    
1307
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1308
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1309
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1310
        }
1311

    
1312
        
1313

    
1314
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1315
        {
1316
            MarkupList.ItemsSource = null;
1317
            txtSearch.Text = string.Empty;
1318

    
1319
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1320

    
1321
            bool IsConsolidation = false;
1322
            string userName = null;
1323

    
1324
            if (commentUser.SelectedValue != null)
1325
            {
1326
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1327
                {
1328
                    userName = commentUser.SelectedValue.ToString();
1329
                }
1330
                else
1331
                {
1332
                    IsConsolidation = true;
1333
                }
1334
            }
1335

    
1336
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1337
                                   .WhereIf(userName != null, d => d.UserName == userName)
1338
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1339
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1340

    
1341
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1342

    
1343
            FilterUpdate();
1344
        }
1345

    
1346
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1347
        {
1348
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1349
        }
1350

    
1351
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1352
        {
1353
            string search_str = txtSearch.Text;
1354

    
1355
            if(string.IsNullOrWhiteSpace(search_str))
1356
            {
1357
                return;
1358
            }
1359

    
1360
            var sel_type = commentType.SelectedItem;
1361
            var sel_user = commentUser.SelectedItem;
1362
            var sel_page = commentPage.SelectedItem;
1363
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1364
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1365
            if (sel_page != null)
1366
            {
1367
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1368
            }
1369
            if (sel_type != null)
1370
            {
1371
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1372
            }
1373
            if (sel_user != null)
1374
            {
1375
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1376
            }
1377
            foreach (var item in list)
1378
            {
1379
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.NewMarkupCancelToken());
1380

    
1381
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1382
                {
1383
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1384
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1385
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1386
                        {
1387
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1388

    
1389
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1390
                            {
1391
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1392
                                {
1393
                                    small_list.Add(item);
1394
                                }
1395
                            }
1396
                        }
1397
                        break;
1398
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1399
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1400
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1401
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1402
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1403
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1404
                        {
1405
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1406

    
1407
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1408
                            {
1409
                                if (instance.ArrowText.Contains(search_str))
1410
                                {
1411
                                    small_list.Add(item);
1412
                                }
1413
                            }
1414
                        }
1415
                        break;
1416
                }
1417
            }
1418

    
1419
            MarkupList.ItemsSource = null;
1420
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1421
        }
1422

    
1423
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1424
        {
1425
            if(e.Key == Key.Enter || e.Key == Key.Return)
1426
            {
1427
                btnSearch_Click(sender, new RoutedEventArgs());
1428
            }
1429
        }
1430

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