프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 99b9f32a

이력 | 보기 | 이력해설 | 다운로드 (59.9 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
#if !_SEC
194
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
195

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

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

    
202
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath, App.PageStorage.LocalStorage,Common.ViewerDataModel.Instance.OriginalTempFile);
203
#endif
204
            App.splashScreen.Close();
205

    
206
        }
207

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

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

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

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

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

    
233
                //});
234
            }
235
        }
236

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

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

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

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

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

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

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

    
291
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
292
            }
293
        }
294

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

    
311
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
312
        { 
313
                var number = selectItem.PageNumber;
314

    
315
                if (ViewerDataModel.Instance.SyncPageNumber != number)
316
                {
317
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
318

    
319
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
320

    
321
                    PageChanging(this, new PageChangeEventArgs
322
                    {
323
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
324
                        PageNumber = number,
325
                        PageUri = null
326
                    });
327
                }
328
        }
329

    
330
        public bool GotoPageFlag = false;
331

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

    
342
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
343
                    if (_page.Count() > 0)
344
                    {
345
                        ThumbnailItem thumbnailitem = _page.First();
346
                        if (PageChanging != null)
347
                        {
348

    
349
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
350
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
351

    
352
                                ImgListbox.SelectedItem = thumbnailitem;
353

    
354

    
355
                                if (navigationTab.SelectedIndex != 0)
356
                                {
357
                                    PageChange(thumbnailitem);
358
                                }
359

    
360
                            });
361
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
362
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
363
                            //    ImgListbox.ScrollIntoView(_itemIndex);
364
                            //else
365
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
366
                        }
367
                    }
368

    
369
                //}).ConfigureAwait(false);
370
            }
371
            catch(Exception ex)
372
            {
373
                //Logger.sendResLog("GotoPage", ex.Message, 0);
374
            }
375
        }
376

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

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

    
410
        public void GotoPageTALK(int _pageNumber, int _angle)
411
        {
412
            int _PageNo = -1;
413

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

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

    
442
                    var instanceMain = this.ParentOfType<MainWindow>();
443

    
444
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
445

    
446
                    if (rotationNum > 0) // 1, 2, 3
447
                    {
448
                        for (int i = 0; i < rotationNum; i++)
449
                        {
450
                            drawingPannelRotate(true);
451
                        }
452
                    }
453
                    else if (rotationNum < 0)// -1, -2, -3
454
                    {
455
                        for (int i = 0; i < -rotationNum; i++)
456
                        {
457
                            drawingPannelRotate(false);
458
                        }
459
                    }
460
                }
461
            }
462
        }
463

    
464
        public void drawingPannelRotate(bool Flag)
465
        {
466
            var instanceMain = this.ParentOfType<MainWindow>();
467

    
468
            if (Flag)
469
            {
470
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
471
                {
472
                    instanceMain.dzMainMenu.rotate.Angle = 0;
473
                }
474
                else
475
                {
476
                    instanceMain.dzMainMenu.rotate.Angle += 90;
477
                }
478
            }
479
            else
480
            {
481
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
482
                {
483
                    instanceMain.dzMainMenu.rotate.Angle = 270;
484
                }
485
                else
486
                {
487
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
488
                }
489
            }
490

    
491
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
492
            {
493
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
494
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
495
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
496
            }
497

    
498
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
499
            {
500
                instanceMain.dzMainMenu.translate.X = 0;
501
                instanceMain.dzMainMenu.translate.Y = 0;
502
            }
503
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
504
            {
505
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
506
                instanceMain.dzMainMenu.translate.Y = 0;
507
            }
508
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
509
            {
510
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
511
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
512
            }
513
            else
514
            {
515
                instanceMain.dzMainMenu.translate.X = 0;
516
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
517
            }
518

    
519
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
520
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
521
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
522
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
523
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
524
            ViewerDataModel.Instance.MarkupAngle = instanceMain.dzMainMenu.rotate.Angle;
525

    
526
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
527
            {
528
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
529

    
530
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
531
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
532
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
533

    
534
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
535
                if (rotationdoc != null)
536
                {
537
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
538
                }
539
                else
540
                {
541
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
542
                }
543
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
544
            });
545
        }
546

    
547
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
548
        {
549
            SetCommentPages();
550
        }
551

    
552
        public async void SetCommentPages(object obj = null)
553
        {
554
            //ThumbnailSetAsync();
555
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
556
        }
557

    
558
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
559
        {
560
            Logger.sendCheckLog("SetCommentList", 1);
561
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
562
#region 기존 색상 제거 작업
563

    
564
            foreach (var item in this._thumbnailItems)
565
            {
566
                if (item.DisplayColorItems != null)
567
                {
568
                    item.DisplayColorItems.Clear();
569
                }
570
            }
571
#endregion
572

    
573
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
574
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
575

    
576
            this.UsersCommentPagesList.ToList().ForEach(item =>
577
            {
578
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
579

    
580
                if (_comm.Count() == 0)
581
                {
582
                    _delItem.Add(item);
583
                }
584

    
585
                if (cts != null)
586
                {
587
                    if (cts.Value.IsCancellationRequested)
588
                        return;
589
                }
590
            });
591

    
592
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
593

    
594
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
595
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
596

    
597
            UsersCommentPagesList.ForEach(user =>
598
            {
599
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
600
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
601

    
602
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
603

    
604
                if (_commLst.Count() == 0)
605
                {
606
                    this.UsersCommentPagesList.Add(user);
607
                }
608
                else
609
                {
610
                    if (_commLst.First().PageNumber != user.PageNumber)
611
                        _commLst.First().PageNumber = user.PageNumber;
612
                }
613

    
614
                user.PageNumber.ForEach(page =>
615
                {
616
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
617

    
618
                    if (_items.Count() > 0)
619
                    {
620
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
621
                        
622
                    }
623

    
624
                    if (cts != null)
625
                    {
626
                        if (cts.Value.IsCancellationRequested)
627
                            return;
628
                    }
629
                });
630
            });
631

    
632
            foreach (var item in this._thumbnailItems)
633
            {
634
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
635
            }
636

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

    
640
            if (data.Count() != 0)
641
            {
642
                if (Convert.ToBoolean(data.First().isConSolidation))
643
                {
644
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
645
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
646
                    this.lstSelectComment.ItemsSource = data;
647
                }
648
            }
649

    
650
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
651
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
652

    
653

    
654
            //var template = this.ImgListbox.ItemTemplate;
655
            //this.ImgListbox.ItemTemplate = null;
656
            //this.ImgListbox.ItemTemplate = template;
657

    
658
        }
659

    
660
        List<int> FilterPages = null;
661

    
662
        private void ThumbnailSetAsync()
663
        {
664
            Logger.sendCheckLog("ThumbnailSet", 1);
665

    
666
            if (FilteredThumbnail == null)
667
            {
668
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
669

    
670
                var pageList = ViewerDataModel.Instance.Document_Info;
671

    
672
                var items = from page in pageList
673
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
674
                            select new ThumbnailItem
675
                            {
676
                                //ImageUri = new Uri(pageLink),
677
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
678
                                PageNumber = page.PAGE_NUMBER,
679
                                Angle = page.PAGE_ANGLE
680
                            };
681

    
682
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
683
                FilteredThumbnail = new CollectionViewSource();
684
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
685

    
686
                FilteredThumbnail.Source = _thumbnailItems;
687

    
688
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
689
                  {
690
                      System.Diagnostics.Debug.WriteLine("ect");
691
                  };
692

    
693
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
694

    
695
                FilteredThumbnail.Filter += (snd, evt) =>
696
                {
697
                    if (FilterPages?.Count() > 0 && evt.Item != null)
698
                    {
699
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
700
                    }
701
                    else
702
                    {
703
                        evt.Accepted = false;
704
                    }
705
                };
706

    
707
            }
708

    
709
            FilterPages.Clear();
710

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

    
732
                    if (commentPages?.Count() > 0)
733
                    {
734
                        FilterPages = (from thumb in _thumbnailItems
735
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
736
                                       select thumb.PageNumber).ToList();
737
                    }
738
                }
739
            }
740

    
741
            if (FilterPages != null)
742
            {
743
                if(FilteredThumbnail == null)
744
                {
745
                    System.Diagnostics.Debug.WriteLine("filter null");
746
                }
747

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

    
753
                FilteredThumbnail.View.Refresh();
754

    
755
                if (FilterPages.Count() > 0)
756
                {
757
                    if (_thumbnailItems.Count() > 0)
758
                    {
759
                        ImgListbox.SelectedItem = _thumbnailItems[0];
760
                    }
761

    
762
                    //SetCommentList(UsersCommentPagesList.ToList());
763
                }
764
                else
765
                {
766
                    ImgListbox.SelectedItem = null;
767
                }
768

    
769
                if (ThumbInitialized != null)
770
                {
771
                    ThumbInitialized(this, new EventArgs());
772
                    ThumbInitialized = null;
773
                }
774
            }
775
        }
776

    
777

    
778
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
779
        {
780
            if (e.ClickCount >= 2)
781
            {
782
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
783

    
784
                GotoPage(selectItem.PageNumber);
785

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

    
788
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
789
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
790
                //bool isGO = false;
791

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

    
803
                //};
804
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
805

    
806
                //GotoPage(MarkupList.SelectedItem as MarkupList)
807
            }
808
        }
809

    
810
        public class MarkupInfoItemSmall
811
        {
812
            public string Id { get; set; }
813
            public string UserName { get; set; }
814
            public string UserID { get; set; }
815
            public int PageNumber { get; set; }
816
            public string Data { get; set; }
817
            public int Data_Type { get; set; }
818
            public bool IsConsolidate { get; set; }
819
        }
820

    
821
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
822
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
823
        {
824
            get
825
            {
826
                if (_MarkupInfoSmallList == null)
827
                {
828
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
829
                }
830
                return _MarkupInfoSmallList;
831
            }
832
            set
833
            {
834

    
835
                _MarkupInfoSmallList = value;
836
                RaisePropertyChanged("MarkupInfoSmallList");
837
            }
838
        }
839

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

    
856
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
857
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
858

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

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

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

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

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

    
962
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
963
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
964
                }
965
                catch (Exception ex)
966
                {
967
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
968
                }
969
            }
970
        }
971

    
972
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
973
        {
974
            var clickButtonItem = sender as RadButton;
975
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
976
            {
977
                try
978
                {
979
             
980

    
981
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
982
                    MarkupList.SelectedItem = gaza;
983

    
984
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
985
                }
986
                catch (Exception ex)
987
                {
988
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
989
                }
990
            }
991
        }
992

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

    
1001
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
1002

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

    
1005
        //    if (commentList.Count() > 0)
1006
        //    {
1007
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
1008
        //        #region markup list grid select items
1009

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

    
1012
        //        if (infoItem.Count() > 0)
1013
        //        {
1014

    
1015
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
1016
        //            gridMarkup.SelectedItems.Clear();
1017
        //            gridMarkup.SelectedItems.Add(infoItem.First());
1018
        //        }
1019

    
1020
        //        #endregion
1021

    
1022
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
1023

    
1024
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
1025
        //        {
1026
        //            GotoSelectedMarkup(CommentIdList);
1027
        //        }
1028
        //        else
1029
        //        {
1030
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
1031

    
1032
        //            handler = (snd, evt) =>
1033
        //            {
1034
        //                GotoSelectedMarkup(CommentIdList);
1035
        //                pageNavigator.PageChanged -= handler;
1036
        //            };
1037

    
1038
        //            pageNavigator.PageChanged += handler;
1039

    
1040
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
1041
        //        }
1042
        //    }
1043
        //}
1044

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

    
1054
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1055
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1056

    
1057
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1058
        //    {
1059
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1060
        //        commentUserInfo.AddRange(selectOrderComments);
1061

    
1062
        //        if (commentUserInfo?.Count() > 0)
1063
        //        {
1064
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1065

    
1066
        //            try
1067
        //            {
1068
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1069
        //                {
1070
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1071
        //                    {
1072
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1073
        //                    } 
1074

    
1075
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1076
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1077
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1078
        //                }
1079

    
1080
        //                Rect rect = commentUserInfo.First().ItemRect;
1081

    
1082
        //                foreach (var UserInfo in commentUserInfo)
1083
        //                {
1084
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1085
        //                }
1086

    
1087
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1088

    
1089
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1090
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1091
        //                //rect.Transform(matrix);
1092

    
1093
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1094
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1095
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1096
        //                double positionX = 0;
1097
        //                double positionY = 0;
1098

    
1099
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1100
        //                {
1101
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1102
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1103
        //                }
1104

    
1105
        //                main.zoomAndPanControl.ContentScale = newScale;
1106
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1107
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1108

    
1109

    
1110
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1111

    
1112
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1113

    
1114
        //                if (pageAngle == 90)
1115
        //                {
1116
        //                    pageAngle = 270;
1117
        //                }
1118
        //                else
1119
        //                {
1120
        //                    pageAngle = 90;
1121
        //                }
1122

    
1123
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1124
        //                {
1125
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1126
        //                    rect.Transform(matrix);
1127

    
1128
        //                    main.zoomAndPanControl.ZoomTo(rect);
1129
        //                }
1130
        //                else
1131
        //                {
1132
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1133

    
1134
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1135
        //                    rect.Transform(matrix);
1136

    
1137

    
1138
        //                    main.zoomAndPanControl.ZoomTo(rect);
1139
        //                }
1140
        //            }
1141
        //            catch (Exception ex)
1142
        //            {
1143
        //                main.DialogMessage_Alert(ex.Message, "Error");
1144
        //            }
1145
        //        }
1146
        //    }
1147
        //}
1148

    
1149
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1150
        {
1151
            LoadMakupList();
1152
        }
1153

    
1154
        public void LoadMakupList()
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, Event_Type 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 Event_Type.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 Event_Type.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 Event_Type.Thumb://이동 회전
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)