프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ e0cfc73c

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

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

    
17
namespace KCOM.Controls
18
{
19
    /// <summary>
20
    /// Interaction logic for PageNavigator.xaml
21
    /// </summary>
22
    public partial class Sample : UserControl, INotifyPropertyChanged
23
    {
24
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
25
        public event PropertyChangedEventHandler PropertyChanged;
26
        public Sample()
27
        {
28
            //InitializeComponent();   
29
            App.splashString(ISplashMessage.SAMPLE);
30
            this.Loaded += Sample_Loaded;
31
            //_Initialize = true;
32

    
33
            //lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
34
            //ImgListbox.MouseDoubleClick += ImgListbox_MouseDoubleClick;
35
        }
36

    
37
        private void Sample_Loaded(object sender, RoutedEventArgs e)
38
        {
39
            if(!_Initialize)
40
            {
41
                InitializeComponent();
42
                //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
43

    
44
                _Initialize = true;
45
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
46
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
47
            }            
48
        }
49

    
50
        //private void ImgListbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
51
        //{
52

    
53
        //    if (ImgListbox.SelectedItem !=null && (ImgListbox.SelectedItem as ThumbnailItem).PageNumber == CurrentPage.PageNumber)
54
        //    {
55
        //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ScaleToFit();
56
        //    }
57
        //}
58

    
59
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
60
        private List<DOCPAGE> _PageList = null;
61
        private string _DefaultUri = null;
62
        public ThumbnailItem CurrentPage = null;
63
        public ThumbnailItem _NextPage = null;
64
        public int PageCount = 0;
65

    
66
        private bool _Initialize;
67
        public event EventHandler<PageChangeEventArgs> PageChanged;
68
        public event EventHandler<PageChangeEventArgs> PageChanging;
69
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
70
        public class PageChangeEventArgs : EventArgs
71
        {
72
            public DOCPAGE CurrentPage { get; set; }
73
            public string PageUri { get; set; }
74
            public int PageNumber { get; set; }
75
        }
76

    
77
        private bool _IsFitOn { get; set; }
78
        public bool IsFitOn
79
        {
80
            get
81
            {
82
                return _IsFitOn;
83
            }
84
            set
85
            {
86
                _IsFitOn = value;
87
                RaisePropertyChanged("IsFitOn");
88
            }
89
        }
90

    
91
        public void RaisePropertyChanged(string propName)
92
        {
93
            if (PropertyChanged != null)
94
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
95
        }
96

    
97
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
98
        {
99
            Logger.sendCheckLog("SetPageNavi", 1);
100
            this._PageList = PageList;
101
            this._DefaultUri = DefaultUri;
102
            ThumbnailSet();
103
            this.PageCount = PageList.Count();
104
            //ThumbNmailSet();
105
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
106
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
107
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
108
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
109
        }
110
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
111
        {
112
            Logger.sendCheckLog("rdoCommented_Checked", 1);
113
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
114
            SetCommentPages();
115
        }
116

    
117
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
118
        {
119
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
120
            if (rdoFavoritePages.IsChecked == true)
121
                expCommentPages.IsExpanded = false;
122

    
123
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
124
            if (_FavoriteSet.Count > 0)
125
            {
126
                SetCommentPages_Favorite(); //수정    
127
            }
128
            else
129
            {
130
                rdoAllPages.IsChecked = true;
131
                rdoFavoritePages.IsChecked = false;
132
            }
133
        }
134

    
135
        private void SetCommentPages_Favorite()
136
        {
137
            ThumbnailSet();            
138
            SetCommentPages();
139
        }
140

    
141
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
142
        {
143
            //txtThumbCount.Visibility = Visibility.Collapsed;            
144
        }
145

    
146
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
147
        {
148
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
149
            rdoAllPages.IsChecked = false;
150
            rdoFavoritePages.IsChecked = false;
151
            //txtThumbCount.Visibility = Visibility.Visible;
152
            SetCommentPages();
153
        }
154

    
155
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
156
        {            
157
            if (ImgListbox.SelectedItem != null)
158
            {
159
                int _PageNo = -1;
160

    
161
                if (this.CurrentPage != null)
162
                {
163
                    _PageNo = this.CurrentPage.PageNumber;
164
                };
165

    
166
                int nextpage = ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
167
                if(_PageNo != nextpage)
168
                {
169
                    GotoPage(nextpage);
170
                }
171
                
172
            }
173
            var border = VisualTreeHelper.GetChild(ImgListbox, 0);
174
            if(border!= null)
175
            {
176
                IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
177

    
178
            }
179
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
180
            //ImgListbox.ScrollIntoView(ImgListbox.SelectedItem);
181
        }
182

    
183
        public bool GotoPageFlag = false;
184

    
185
        /// <summary>
186
        /// 해당 썸네일로 이동
187
        /// </summary>
188
        /// <param name="_pageNumber"></param>
189
        public void GotoPage(int _pageNumber)
190
        {
191
            try
192
            {
193
                int _PageNo = -1;
194
                if (int.TryParse(_pageNumber.ToString(), out _PageNo))
195
                {
196
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
197
                    if (_page.Count() > 0)
198
                    {
199
                        ThumbnailItem _item = _page.First();
200
                        setPageChange(_item);
201
                        //this.ImgListbox.SelectedIndex = _pageNumber - 1;                        
202
                        //this.ImgListbox.ScrollIntoView(_item);
203
                    }
204
                }
205
            }
206
            catch(Exception ex)
207
            {
208
                Logger.sendResLog("GotoPage", ex.Message, 0);
209
            }
210
            
211
        }
212

    
213
        public void setPageChange(ThumbnailItem thumbnailItem)
214
        {
215
            Logger.sendCheckLog("setPageChange", 1);
216
            if (thumbnailItem != null)
217
            {
218
                if (PageChanging != null)
219
                {                    
220
                    //if(CurrentPage != null && CurrentPage.PageNumber == _NextPage.PageNumber)
221
                    //{
222
                    //    return;
223
                    //}
224
                    this.CurrentPage = _NextPage;
225
                    _NextPage = thumbnailItem;
226
                    PageChanging(this, new PageChangeEventArgs
227
                    {
228
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
229
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
230
                        PageUri = null
231
                    });
232
                }
233
            }
234
        }
235

    
236
        public void GotoPageTALK(int _pageNumber, int _angle)
237
        {
238
            int _PageNo = -1;
239

    
240
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
241
            {
242
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
243
                if (_page.Count() > 0)
244
                {
245
                    ThumbnailItem _item = _page.First();
246
                    setPageChangeTALK(_item, _angle);
247
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
248
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
249
                }
250
            }
251
        }
252

    
253
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
254
        {
255
            if (thumbnailItem != null)
256
            {
257
                if (PageChanging != null)
258
                {
259
                   this.CurrentPage = _NextPage;
260
                    _NextPage = thumbnailItem;
261
                    PageChanging(this, new PageChangeEventArgs
262
                    {
263
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
264
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
265
                        PageUri = null
266
                    });
267

    
268
                    var instanceMain = this.ParentOfType<MainWindow>();
269

    
270
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
271

    
272
                    if (rotationNum > 0) // 1, 2, 3
273
                    {
274
                        for (int i = 0; i < rotationNum; i++)
275
                        {
276
                            drawingPannelRotate(true);
277
                        }
278
                    }
279
                    else if (rotationNum < 0)// -1, -2, -3
280
                    {
281
                        for (int i = 0; i < -rotationNum; i++)
282
                        {
283
                            drawingPannelRotate(false);
284
                        }
285
                    }
286
                }
287
            }
288
        }
289

    
290
        public void drawingPannelRotate(bool Flag)
291
        {
292
            var instanceMain = this.ParentOfType<MainWindow>();
293

    
294
            if (Flag)
295
            {
296
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
297
                {
298
                    instanceMain.dzMainMenu.rotate.Angle = 0;
299
                }
300
                else
301
                {
302
                    instanceMain.dzMainMenu.rotate.Angle += 90;
303
                }
304
            }
305
            else
306
            {
307
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
308
                {
309
                    instanceMain.dzMainMenu.rotate.Angle = 270;
310
                }
311
                else
312
                {
313
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
314
                }
315
            }
316

    
317
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
318
            {
319
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
320
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
321
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
322
            }
323

    
324
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
325
            {
326
                instanceMain.dzMainMenu.translate.X = 0;
327
                instanceMain.dzMainMenu.translate.Y = 0;
328
            }
329
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
330
            {
331
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
332
                instanceMain.dzMainMenu.translate.Y = 0;
333
            }
334
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
335
            {
336
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
337
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
338
            }
339
            else
340
            {
341
                instanceMain.dzMainMenu.translate.X = 0;
342
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
343
            }
344

    
345
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
346
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
347
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
348
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
349
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
350
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
351

    
352
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
353
            {
354
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
355

    
356
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
357
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
358
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
359

    
360
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
361
                if (rotationdoc != null)
362
                {
363
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
364
                }
365
                else
366
                {
367
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
368
                }
369
                instanceMain.dzMainMenu.pageNavigator.setPageChange(data);
370
            });
371
        }
372

    
373
        public void SetNextPage()
374
        {
375
            CurrentPage = _NextPage;
376
            PageChange(_NextPage);
377
        }
378

    
379
        private void PageChange(ThumbnailItem thumbitem)
380
        {            
381
            if (PageChanged != null)
382
            {
383
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
384
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
385
                var _itemIndex = _thumbnailItems.IndexOf(thumbitem);
386
                //ImgListbox.SelectedItem(_thumbitem, true);
387
                ImgListbox.SelectedItem = thumbitem;
388

    
389
                if (_itemIndex < _thumbnailItems.Count() - 1)
390
                    ImgListbox.ScrollIntoView(_itemIndex);
391
                else
392
                    ImgListbox.ScrollIntoView(_thumbnailItems.Count() - 1);
393

    
394
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
395

    
396
                if (_DocPages.Count() > 0)
397
                {
398
                    var _page = _DocPages.First();
399

    
400
                    PageChanged(this, new PageChangeEventArgs
401
                    {
402
                        CurrentPage = _page,
403
                        PageUri = uri,
404
                        PageNumber = thumbitem.PageNumber
405
                    });
406
                    ImgListbox.SelectedItem = thumbitem;
407

    
408
                }
409
                else
410
                {
411
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
412
                }
413
            }
414
        }
415

    
416
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
417
        {
418
            SetCommentPages();
419
        }
420

    
421

    
422
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
423
        {
424
            SetCommentPages();
425
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
426
        }
427
        public void SetCommentPages()
428
        {
429
            ThumbnailSet();
430
            SetCommentList(_UsersCommentPagesList.ToList());
431
        }
432

    
433
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
434
        {
435
            Logger.sendCheckLog("SetCommentList", 1);
436
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
437
            #region 기존 색상 제거 작업
438
            foreach (var item in this._thumbnailItems)
439
            {
440
                item.DisplayColorItems.Clear();
441
            }
442
            #endregion
443

    
444
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
445
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
446

    
447
            _UsersCommentPagesList.ToList().ForEach(item =>
448
            {
449
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
450

    
451
                if (_comm.Count() == 0)
452
                {
453
                    _delItem.Add(item);
454
                }
455
            });
456

    
457
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
458

    
459
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
460
            UsersCommentPagesList.ForEach(user =>
461
            {
462
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
463
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
464

    
465
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
466

    
467
                if (_commLst.Count() == 0)
468
                {
469
                    _UsersCommentPagesList.Add(user);
470
                }
471
                else
472
                {
473
                    if (_commLst.First().PageNumber != user.PageNumber)
474
                        _commLst.First().PageNumber = user.PageNumber;
475
                }
476

    
477
                user.PageNumber.ForEach(page =>
478
                {
479
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
480

    
481
                    if (_items.Count() > 0)
482
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
483
                });
484
            });
485

    
486

    
487
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
488
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
489
            if (data.Count() != 0)
490
            {
491
                if (Convert.ToBoolean(data.First().isConSolidation))
492
                {
493
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
494
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
495
                    this.lstSelectComment.ItemsSource = data;
496
                }
497
                else
498
                {
499
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
500
                }
501
            }
502
            else
503
            {
504
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
505
            }
506
            //this.ImgListbox.ItemsSource = null;
507
            Logger.sendCheckLog("SetCommentList_ImgListbox 설정", 1);
508

    
509
       
510
                this.ImgListbox.ItemsSource = this._thumbnailItems;
511
                var template = this.ImgListbox.ItemTemplate;
512
                this.ImgListbox.ItemTemplate = null;
513
                this.ImgListbox.ItemTemplate = template;
514
               //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_Start", 1);
515
                //this.ImgListbox.UpdateLayout();
516
                //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_End", 1);
517
           
518
        }
519

    
520
        private void ThumbnailSet()
521
        {
522
            Logger.sendCheckLog("ThumbnailSet", 1);
523
            if (!_Initialize) return;
524

    
525
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
526
            List<int> _selectComment = new List<int>();
527
            if (this.lstSelectComment.ItemsSource != null)
528
            {
529
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
530
                             where commentPage.IsSelected == true
531
                             select commentPage.PageNumber;
532

    
533
                foreach (var item in _pages)
534
                {
535
                    item.ForEach(pp => _selectComment.Add(pp));
536
                }
537

    
538
                _selectComment.Distinct();
539
            }
540

    
541
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
542
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
543
            //this._PageList.ForEach(page =>
544
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
545
            {
546
                var _pageNo = page.PAGE_NUMBER;
547
                bool _addFlag = false;
548

    
549
                if (rdoFavoritePages.IsChecked == false)
550
                {
551
                    if (_selectComment.Count() > 0)
552
                    {
553
                        if ((rdoAllPages.IsChecked == true)
554
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
555
                        {
556
                            _addFlag = true;
557
                        }
558
                    }
559
                    else
560
                    {
561
                        //if (App.ViewInfo.IsCustomPage)
562
                        //{
563
                        //    //_addFlag = false;
564

    
565
                        //    //App.ViewInfo.IsCustomPage = false;
566
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
567
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
568
                        //    this.rdoAllPages.IsChecked = false;
569
                        //    this.rdoFavoritePages.IsChecked = true;
570
                        //    //SetCommentPages();                        
571
                        //}
572
                        //else
573
                        //{
574
                        _addFlag = true;
575
                        //}
576
                    }
577
                }
578

    
579

    
580
                if (_addFlag)
581
                {
582
                    this._thumbnailItems.Add(new ThumbnailItem
583
                    {
584
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
585
                        PageNumber = _pageNo,
586
                        Angle = page.PAGE_ANGLE,
587
                    });
588
                }
589
                else
590
                {
591
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
592
                    {
593
                        this._thumbnailItems.Add(new ThumbnailItem
594
                        {
595
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
596
                            PageNumber = _pageNo,
597
                            Angle = page.PAGE_ANGLE,
598
                        });
599
                    }
600
                }
601

    
602

    
603

    
604
                //this._thumbnailItems.Add(new ThumbnailItem
605
                //{
606
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
607

    
608
                //    //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"),
609

    
610
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
611
                //    //DisplayColorItems = pageColor,
612
                //    PageNumber = Convert.ToInt32(_pageNo),
613
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
614
                //});
615
            });
616

    
617
            //txtTotPageNo.Text = this._PageList.Count().ToString();
618

    
619
            //txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString());
620

    
621
            if (ImgListbox.ItemsSource == null)
622
            {
623
                ImgListbox.ItemsSource = this._thumbnailItems;
624

    
625
                this._thumbnailItems.ToList().ForEach(data =>
626
                {
627
                    data.Width = ImgListbox.ActualWidth;
628
                    data.Height = ImgListbox.ActualHeight;
629
                });
630

    
631
                if (ImgListbox.Items.Count > 0)
632
                {
633
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
634
                    int StartPageIdx = 1;
635
                    //if (App.ViewInfo.IsCustomPage)
636
                    //{
637
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
638
                    //}
639
                    //else
640
                    //{
641

    
642
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
643
                    {
644
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
645
                    }
646
                    else
647
                    {
648
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
649
                    }
650
                    //}
651
                }
652
            }
653
            else
654
            {
655
                ImgListbox.UpdateLayout();
656
                ImgListbox.ItemsSource = this._thumbnailItems;
657
            }
658
        }
659

    
660
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
661
        {
662
            if (e.ClickCount >= 2)
663
            {
664
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
665
                GotoPage(selectItem.PageNumber);
666
                var result = MarkupParser.GetBaseControl(selectItem.Data);
667
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
668
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
669
                //bool isGO = false;
670

    
671
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
672
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
673
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
674
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
675
                //{
676
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
677
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
678
                //    {
679
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
680
                //    }
681

    
682
                //};
683
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
684

    
685
                //GotoPage(gogogo.SelectedItem as MarkupList)
686
            }
687
        }
688

    
689
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
690
        {
691
            tbSearch.Text = string.Empty;
692
            if (e.AddedItems.Count > 0)
693
            {
694
                if (commentUser.Items.Count > 0)
695
                {
696
                    MarkupInfoSmallList.Clear();
697
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
698
                    //d.PageNumber
699

    
700
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
701
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
702

    
703
                    //gogogo.ItemsSource = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
704
                    //gogogo.ItemsSource = ViewerDataModel.Instance._markupInfoList.Where(d=>d.UserName ==  sender as RadCombo
705

    
706
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
707
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
708
                    markuplist.ForEach(d =>
709
                    {
710
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
711
                        {
712
                            Data = d.Data,
713
                            Data_Type = d.Data_Type,
714
                            PageNumber = d.PageNumber,
715
                            UserID = temp.UserID,
716
                            UserName = temp.UserName,
717
                        });
718
                    });
719
                    gogogo.ItemsSource = null;
720
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
721

    
722
                }
723
            }
724
            else
725
            {
726
                MarkupInfoSmallList.Clear();
727
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
728
                {
729
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
730

    
731
                    markuplist.ForEach(b =>
732
                    {
733
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
734
                        {
735

    
736
                            Data = b.Data,
737
                            Data_Type = b.Data_Type,
738
                            PageNumber = b.PageNumber,
739
                            UserID = d.UserID,
740
                            UserName = d.UserName,
741
                        });
742
                    });
743

    
744
                });
745
                gogogo.ItemsSource = null;
746
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
747
            }
748
        }
749

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

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

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

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

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

    
798
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
799
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
800
                    {
801
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
802
                            {
803
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
804
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
805
                            }
806
                            break;
807
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
808
                            {
809
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
810
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
811
                            }
812
                            break;
813
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
814
                            {
815
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
816
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
817
                            }
818
                            break;
819
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
820
                            {
821
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
822

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

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

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

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

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

    
911
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
912
        {
913
            if (MarkupInfoSmallList.Count == 0)
914
            {
915
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
916
                {
917
                    if (d.MarkupList != null)
918
                    {
919
                        d.MarkupList.ForEach(b =>
920
                        {
921
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
922
                            {
923
                                Id = b.ID,
924
                                Data = b.Data,
925
                                Data_Type = b.Data_Type,
926
                                PageNumber = b.PageNumber,
927
                                UserID = d.UserID,
928
                                UserName = d.UserName,
929
                            });
930
                        });
931
                    }
932
                });
933
                gogogo.ItemsSource = null;
934
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
935

    
936
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
937
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
938
            }
939
        }
940

    
941
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
942
        {
943
            gogogo.ItemsSource = null;
944
            tbSearch.Text = string.Empty;
945
            if (e.AddedItems.Count > 0)
946
            {
947

    
948
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
949
            }
950
            else
951
            {
952
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
953
            }
954
        }
955

    
956
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
957
        {
958
            gogogo.ItemsSource = null;
959
            tbSearch.Text = string.Empty;
960
            if (e.AddedItems.Count > 0)
961
            {
962
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
963
            }
964
            else
965
            {
966
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
967
            }
968
        }
969

    
970
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
971
        {
972
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
973
        }
974

    
975
        private void btnSearch_Click(object sender, RoutedEventArgs e)
976
        {
977
            string search_str = tbSearch.Text;
978
            var sel_type = commentType.SelectedItem;
979
            var sel_user = commentUser.SelectedItem;
980
            var sel_page = commentPage.SelectedItem;
981
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
982
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
983
            if (sel_page != null)
984
            {
985
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
986
            }
987
            if (sel_type != null)
988
            {
989
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
990
            }
991
            if (sel_user != null)
992
            {
993
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
994
            }
995
            foreach (var item in list)
996
            {
997
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
998

    
999
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1000
                {
1001
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1002
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1003
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1004
                        {
1005
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1006
                            if (instance.Text.Contains(search_str))
1007
                            {
1008
                                small_list.Add(item);
1009
                            }
1010
                        }
1011
                        break;
1012
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1013
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1014
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1015
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1016
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1017
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1018
                        {
1019
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1020
                            if (instance.ArrowText.Contains(search_str))
1021
                            {
1022
                                small_list.Add(item);
1023
                            }
1024
                        }
1025
                        break;
1026

    
1027
                }
1028

    
1029
            }
1030

    
1031
            gogogo.ItemsSource = null;
1032
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1033
            tbSearch.Text = string.Empty;
1034
        }
1035
    }
1036
}
클립보드 이미지 추가 (최대 크기: 500 MB)