프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (44 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 Telerik.Windows.Controls;
15

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

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

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

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

    
48
        //private void ImgListbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
49
        //{
50

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

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

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

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

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

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

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

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

    
133
        private void SetCommentPages_Favorite()
134
        {
135
            ThumbnailSet();            
136
            SetCommentPages();
137
        }
138

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

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

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

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

    
164
                int nextpage = ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
165
                if(_PageNo != nextpage)
166
                {
167
                    GotoPage(nextpage);
168
                }
169
                
170
            }
171
        }
172

    
173
        public bool GotoPageFlag = false;
174

    
175
        /// <summary>
176
        /// 해당 썸네일로 이동
177
        /// </summary>
178
        /// <param name="_pageNumber"></param>
179
        public void GotoPage(int _pageNumber)
180
        {
181
            try
182
            {
183
                int _PageNo = -1;
184
                if (int.TryParse(_pageNumber.ToString(), out _PageNo))
185
                {
186
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
187
                    if (_page.Count() > 0)
188
                    {
189
                        ThumbnailItem _item = _page.First();
190
                        setPageChange(_item);
191
                        //this.ImgListbox.SelectedIndex = _pageNumber - 1;                        
192
                        //this.ImgListbox.ScrollIntoView(_item);
193
                    }
194
                }
195
            }
196
            catch(Exception ex)
197
            {
198
                Logger.sendResLog("GotoPage", ex.Message, 0);
199
            }
200
            
201
        }
202

    
203
        public void setPageChange(ThumbnailItem thumbnailItem)
204
        {
205
            Logger.sendCheckLog("setPageChange", 1);
206
            if (thumbnailItem != null)
207
            {
208
                if (PageChanging != null)
209
                {                    
210
                    //if(CurrentPage != null && CurrentPage.PageNumber == _NextPage.PageNumber)
211
                    //{
212
                    //    return;
213
                    //}
214
                    this.CurrentPage = _NextPage;
215
                    _NextPage = thumbnailItem;
216
                    PageChanging(this, new PageChangeEventArgs
217
                    {
218
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
219
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
220
                        PageUri = null
221
                    });
222
                }
223
            }
224
        }
225

    
226
        public void GotoPageTALK(int _pageNumber, int _angle)
227
        {
228
            int _PageNo = -1;
229

    
230
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
231
            {
232
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
233
                if (_page.Count() > 0)
234
                {
235
                    ThumbnailItem _item = _page.First();
236
                    setPageChangeTALK(_item, _angle);
237
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
238
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
239
                }
240
            }
241
        }
242

    
243
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
244
        {
245
            if (thumbnailItem != null)
246
            {
247
                if (PageChanging != null)
248
                {
249
                   this.CurrentPage = _NextPage;
250
                    _NextPage = thumbnailItem;
251
                    PageChanging(this, new PageChangeEventArgs
252
                    {
253
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
254
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
255
                        PageUri = null
256
                    });
257

    
258
                    var instanceMain = this.ParentOfType<MainWindow>();
259

    
260
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
261

    
262
                    if (rotationNum > 0) // 1, 2, 3
263
                    {
264
                        for (int i = 0; i < rotationNum; i++)
265
                        {
266
                            drawingPannelRotate(true);
267
                        }
268
                    }
269
                    else if (rotationNum < 0)// -1, -2, -3
270
                    {
271
                        for (int i = 0; i < -rotationNum; i++)
272
                        {
273
                            drawingPannelRotate(false);
274
                        }
275
                    }
276
                }
277
            }
278
        }
279

    
280
        public void drawingPannelRotate(bool Flag)
281
        {
282
            var instanceMain = this.ParentOfType<MainWindow>();
283

    
284
            if (Flag)
285
            {
286
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
287
                {
288
                    instanceMain.dzMainMenu.rotate.Angle = 0;
289
                }
290
                else
291
                {
292
                    instanceMain.dzMainMenu.rotate.Angle += 90;
293
                }
294
            }
295
            else
296
            {
297
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
298
                {
299
                    instanceMain.dzMainMenu.rotate.Angle = 270;
300
                }
301
                else
302
                {
303
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
304
                }
305
            }
306

    
307
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
308
            {
309
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
310
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
311
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
312
            }
313

    
314
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
315
            {
316
                instanceMain.dzMainMenu.translate.X = 0;
317
                instanceMain.dzMainMenu.translate.Y = 0;
318
            }
319
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
320
            {
321
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
322
                instanceMain.dzMainMenu.translate.Y = 0;
323
            }
324
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
325
            {
326
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
327
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
328
            }
329
            else
330
            {
331
                instanceMain.dzMainMenu.translate.X = 0;
332
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
333
            }
334

    
335
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
336
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
337
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
338
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
339
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
340
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
341

    
342
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
343
            {
344
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
345

    
346
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
347
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
348
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
349

    
350
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
351
                if (rotationdoc != null)
352
                {
353
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
354
                }
355
                else
356
                {
357
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
358
                }
359
                instanceMain.dzMainMenu.pageNavigator.setPageChange(data);
360
            });
361
        }
362

    
363
        public void SetNextPage()
364
        {
365
            CurrentPage = _NextPage;
366
            PageChange(_NextPage);
367
        }
368

    
369
        private void PageChange(ThumbnailItem thumbitem)
370
        {            
371
            if (PageChanged != null)
372
            {
373
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
374
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
375
                var _itemIndex = _thumbnailItems.IndexOf(thumbitem);
376
                //ImgListbox.SelectedItem(_thumbitem, true);
377
                ImgListbox.SelectedItem = thumbitem;
378

    
379
                if (_itemIndex < _thumbnailItems.Count() - 1)
380
                    ImgListbox.ScrollIntoView(_itemIndex);
381
                else
382
                    ImgListbox.ScrollIntoView(_thumbnailItems.Count() - 1);
383

    
384
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
385

    
386
                if (_DocPages.Count() > 0)
387
                {
388
                    var _page = _DocPages.First();
389

    
390
                    PageChanged(this, new PageChangeEventArgs
391
                    {
392
                        CurrentPage = _page,
393
                        PageUri = uri,
394
                        PageNumber = thumbitem.PageNumber
395
                    });
396
                    ImgListbox.SelectedItem = thumbitem;
397

    
398
                }
399
                else
400
                {
401
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
402
                }
403
            }
404
        }
405

    
406
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
407
        {
408
            SetCommentPages();
409
        }
410

    
411

    
412
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
413
        {
414
            SetCommentPages();
415
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
416
        }
417
        public void SetCommentPages()
418
        {
419
            ThumbnailSet();
420
            SetCommentList(_UsersCommentPagesList.ToList());
421
        }
422

    
423
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
424
        {
425
            Logger.sendCheckLog("SetCommentList", 1);
426
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
427
            #region 기존 색상 제거 작업
428
            foreach (var item in this._thumbnailItems)
429
            {
430
                item.DisplayColorItems.Clear();
431
            }
432
            #endregion
433

    
434
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
435
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
436

    
437
            _UsersCommentPagesList.ToList().ForEach(item =>
438
            {
439
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
440

    
441
                if (_comm.Count() == 0)
442
                {
443
                    _delItem.Add(item);
444
                }
445
            });
446

    
447
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
448

    
449
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
450
            UsersCommentPagesList.ForEach(user =>
451
            {
452
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
453
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
454

    
455
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
456

    
457
                if (_commLst.Count() == 0)
458
                {
459
                    _UsersCommentPagesList.Add(user);
460
                }
461
                else
462
                {
463
                    if (_commLst.First().PageNumber != user.PageNumber)
464
                        _commLst.First().PageNumber = user.PageNumber;
465
                }
466

    
467
                user.PageNumber.ForEach(page =>
468
                {
469
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
470

    
471
                    if (_items.Count() > 0)
472
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
473
                });
474
            });
475

    
476

    
477
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
478
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
479
            if (data.Count() != 0)
480
            {
481
                if (Convert.ToBoolean(data.First().isConSolidation))
482
                {
483
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
484
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
485
                    this.lstSelectComment.ItemsSource = data;
486
                }
487
                else
488
                {
489
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
490
                }
491
            }
492
            else
493
            {
494
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
495
            }
496
            //this.ImgListbox.ItemsSource = null;
497
            Logger.sendCheckLog("SetCommentList_ImgListbox 설정", 1);
498

    
499
       
500
                this.ImgListbox.ItemsSource = this._thumbnailItems;
501
                var template = this.ImgListbox.ItemTemplate;
502
                this.ImgListbox.ItemTemplate = null;
503
                this.ImgListbox.ItemTemplate = template;
504
               //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_Start", 1);
505
                //this.ImgListbox.UpdateLayout();
506
                //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_End", 1);
507
           
508
        }
509

    
510
        private void ThumbnailSet()
511
        {
512
            Logger.sendCheckLog("ThumbnailSet", 1);
513
            if (!_Initialize) return;
514

    
515
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
516
            List<int> _selectComment = new List<int>();
517
            if (this.lstSelectComment.ItemsSource != null)
518
            {
519
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
520
                             where commentPage.IsSelected == true
521
                             select commentPage.PageNumber;
522

    
523
                foreach (var item in _pages)
524
                {
525
                    item.ForEach(pp => _selectComment.Add(pp));
526
                }
527

    
528
                _selectComment.Distinct();
529
            }
530

    
531
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
532
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
533
            //this._PageList.ForEach(page =>
534
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
535
            {
536
                var _pageNo = page.PAGE_NUMBER;
537
                bool _addFlag = false;
538

    
539
                if (rdoFavoritePages.IsChecked == false)
540
                {
541
                    if (_selectComment.Count() > 0)
542
                    {
543
                        if ((rdoAllPages.IsChecked == true)
544
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
545
                        {
546
                            _addFlag = true;
547
                        }
548
                    }
549
                    else
550
                    {
551
                        //if (App.ViewInfo.IsCustomPage)
552
                        //{
553
                        //    //_addFlag = false;
554

    
555
                        //    //App.ViewInfo.IsCustomPage = false;
556
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
557
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
558
                        //    this.rdoAllPages.IsChecked = false;
559
                        //    this.rdoFavoritePages.IsChecked = true;
560
                        //    //SetCommentPages();                        
561
                        //}
562
                        //else
563
                        //{
564
                        _addFlag = true;
565
                        //}
566
                    }
567
                }
568

    
569

    
570
                if (_addFlag)
571
                {
572
                    this._thumbnailItems.Add(new ThumbnailItem
573
                    {
574
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
575
                        PageNumber = _pageNo,
576
                        Angle = page.PAGE_ANGLE,
577
                    });
578
                }
579
                else
580
                {
581
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
582
                    {
583
                        this._thumbnailItems.Add(new ThumbnailItem
584
                        {
585
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
586
                            PageNumber = _pageNo,
587
                            Angle = page.PAGE_ANGLE,
588
                        });
589
                    }
590
                }
591

    
592

    
593

    
594
                //this._thumbnailItems.Add(new ThumbnailItem
595
                //{
596
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
597

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

    
600
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
601
                //    //DisplayColorItems = pageColor,
602
                //    PageNumber = Convert.ToInt32(_pageNo),
603
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
604
                //});
605
            });
606

    
607
            //txtTotPageNo.Text = this._PageList.Count().ToString();
608

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

    
611
            if (ImgListbox.ItemsSource == null)
612
            {
613
                ImgListbox.ItemsSource = this._thumbnailItems;
614

    
615
                this._thumbnailItems.ToList().ForEach(data =>
616
                {
617
                    data.Width = ImgListbox.ActualWidth;
618
                });
619

    
620
                if (ImgListbox.Items.Count > 0)
621
                {
622
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
623
                    int StartPageIdx = 1;
624
                    //if (App.ViewInfo.IsCustomPage)
625
                    //{
626
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
627
                    //}
628
                    //else
629
                    //{
630

    
631
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
632
                    {
633
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
634
                    }
635
                    else
636
                    {
637
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
638
                    }
639
                    //}
640
                }
641
            }
642
            else
643
            {
644
                ImgListbox.UpdateLayout();
645
                ImgListbox.ItemsSource = this._thumbnailItems;
646
            }
647
        }
648

    
649
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
650
        {
651
            if (e.ClickCount >= 2)
652
            {
653
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
654
                GotoPage(selectItem.PageNumber);
655
                var result = MarkupParser.GetBaseControl(selectItem.Data);
656
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
657
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
658
                //bool isGO = false;
659

    
660
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
661
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
662
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
663
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
664
                //{
665
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
666
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
667
                //    {
668
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
669
                //    }
670

    
671
                //};
672
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
673

    
674
                //GotoPage(gogogo.SelectedItem as MarkupList)
675
            }
676
        }
677

    
678
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
679
        {
680
            tbSearch.Text = string.Empty;
681
            if (e.AddedItems.Count > 0)
682
            {
683
                if (commentUser.Items.Count > 0)
684
                {
685
                    MarkupInfoSmallList.Clear();
686
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
687
                    //d.PageNumber
688

    
689
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
690
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
691

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

    
695
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
696
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
697
                    markuplist.ForEach(d =>
698
                    {
699
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
700
                        {
701
                            Data = d.Data,
702
                            Data_Type = d.Data_Type,
703
                            PageNumber = d.PageNumber,
704
                            UserID = temp.UserID,
705
                            UserName = temp.UserName,
706
                        });
707
                    });
708
                    gogogo.ItemsSource = null;
709
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
710

    
711
                }
712
            }
713
            else
714
            {
715
                MarkupInfoSmallList.Clear();
716
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
717
                {
718
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
719

    
720
                    markuplist.ForEach(b =>
721
                    {
722
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
723
                        {
724

    
725
                            Data = b.Data,
726
                            Data_Type = b.Data_Type,
727
                            PageNumber = b.PageNumber,
728
                            UserID = d.UserID,
729
                            UserName = d.UserName,
730
                        });
731
                    });
732

    
733
                });
734
                gogogo.ItemsSource = null;
735
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
736
            }
737
        }
738

    
739
        public class MarkupInfoItemSmall
740
        {
741
            public string Id { get; set; }
742
            public string UserName { get; set; }
743
            public string UserID { get; set; }
744
            public int PageNumber { get; set; }
745
            public string Data { get; set; }
746
            public int Data_Type { get; set; }
747
        }
748

    
749
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
750
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
751
        {
752
            get
753
            {
754
                if (_MarkupInfoSmallList == null)
755
                {
756
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
757
                }
758
                return _MarkupInfoSmallList;
759
            }
760
            set
761
            {
762

    
763
                _MarkupInfoSmallList = value;
764
                RaisePropertyChanged("MarkupInfoSmallList");
765
            }
766
        }
767

    
768
        /// <summary>
769
        /// goto page and select item selected by user
770
        /// </summary>
771
        /// <param name="sender"></param>
772
        /// <param name="e"></param>
773
        private void RadButton_Click(object sender, RoutedEventArgs e)
774
        {
775
            var clickButtonItem = sender as RadButton;
776
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
777
            {
778
                try
779
                {
780
                    Rect rect = new Rect();
781
                    Point s_point = new Point();
782
                    Point e_point = new Point();
783

    
784
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
785
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
786

    
787
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
788
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
789
                    {
790
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
791
                            {
792
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
793
                                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));
794
                            }
795
                            break;
796
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
797
                            {
798
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
799
                                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));
800
                            }
801
                            break;
802
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
803
                            {
804
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
805
                                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));
806
                            }
807
                            break;
808
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
809
                            {
810
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
811

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

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

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

    
869
                                foreach (Point A in instance.PointSet)
870
                                {
871
                                    if (s_point == new Point())
872
                                    {
873
                                        s_point = A;
874
                                        e_point = A;
875
                                    }
876
                                    s_point.X = Math.Min(s_point.X, A.X);
877
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
878
                                    e_point.X = Math.Max(e_point.X, A.X);
879
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
880
                                }
881
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
882
                            }
883
                            break;
884
                        default:
885
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
886
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
887
                            break;
888
                    }
889

    
890
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
891
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
892
                }
893
                catch (Exception ex)
894
                {
895
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
896
                }
897
            }
898
        }
899

    
900
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
901
        {
902
            if (MarkupInfoSmallList.Count == 0)
903
            {
904
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
905
                {
906
                    if (d.MarkupList != null)
907
                    {
908
                        d.MarkupList.ForEach(b =>
909
                        {
910
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
911
                            {
912
                                Id = b.ID,
913
                                Data = b.Data,
914
                                Data_Type = b.Data_Type,
915
                                PageNumber = b.PageNumber,
916
                                UserID = d.UserID,
917
                                UserName = d.UserName,
918
                            });
919
                        });
920
                    }
921
                });
922
                gogogo.ItemsSource = null;
923
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
924

    
925
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
926
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
927
            }
928
        }
929

    
930
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
931
        {
932
            gogogo.ItemsSource = null;
933
            tbSearch.Text = string.Empty;
934
            if (e.AddedItems.Count > 0)
935
            {
936

    
937
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
938
            }
939
            else
940
            {
941
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
942
            }
943
        }
944

    
945
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
946
        {
947
            gogogo.ItemsSource = null;
948
            tbSearch.Text = string.Empty;
949
            if (e.AddedItems.Count > 0)
950
            {
951
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
952
            }
953
            else
954
            {
955
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
956
            }
957
        }
958

    
959
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
960
        {
961
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
962
        }
963

    
964
        private void btnSearch_Click(object sender, RoutedEventArgs e)
965
        {
966
            string search_str = tbSearch.Text;
967
            var sel_type = commentType.SelectedItem;
968
            var sel_user = commentUser.SelectedItem;
969
            var sel_page = commentPage.SelectedItem;
970
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
971
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
972
            if (sel_page != null)
973
            {
974
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
975
            }
976
            if (sel_type != null)
977
            {
978
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
979
            }
980
            if (sel_user != null)
981
            {
982
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
983
            }
984
            foreach (var item in list)
985
            {
986
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
987

    
988
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
989
                {
990
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
991
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
992
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
993
                        {
994
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
995
                            if (instance.Text.Contains(search_str))
996
                            {
997
                                small_list.Add(item);
998
                            }
999
                        }
1000
                        break;
1001
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1002
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1003
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1004
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1005
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1006
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1007
                        {
1008
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1009
                            if (instance.ArrowText.Contains(search_str))
1010
                            {
1011
                                small_list.Add(item);
1012
                            }
1013
                        }
1014
                        break;
1015

    
1016
                }
1017

    
1018
            }
1019

    
1020
            gogogo.ItemsSource = null;
1021
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1022
            tbSearch.Text = string.Empty;
1023
        }
1024
    }
1025
}
클립보드 이미지 추가 (최대 크기: 500 MB)