프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 22c025b3

이력 | 보기 | 이력해설 | 다운로드 (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 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
            //측정
38
            //Stopwatch sw = new Stopwatch();
39
            //sw.Start();
40
            InitializeComponent();
41
            //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
42

    
43
            _Initialize = true;
44
            lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_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
            Logger.sendCheckLog("ImgListbox_SelectionChanged", 1);
156
            if (ImgListbox.SelectedItem != null)
157
            {
158
                int _PageNo = -1;
159

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

    
165
                if (_PageNo != ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber))
166
                {
167
                    var _page = this._thumbnailItems.Where(item => item.PageNumber == (ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
168
                    if (_page.Count() > 0)
169
                    {
170
                        ThumbnailItem _item = _page.First();
171
                        setPageChange(_item);
172
                    }
173
                }
174
            }
175
        }
176

    
177
        public bool GotoPageFlag = false;
178

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

    
207
        public void setPageChange(ThumbnailItem thumbnailItem)
208
        {
209
            Logger.sendCheckLog("setPageChange", 1);
210
            if (thumbnailItem != null)
211
            {
212
                if (PageChanging != null)
213
                {
214
                    //강인구 수정(페이지가 같을 경우 이동 안함)
215
                    if (CurrentPage != null && CurrentPage == thumbnailItem)
216
                    {
217
                        return;
218
                    }
219

    
220
                    this.CurrentPage = _NextPage;
221
                    _NextPage = thumbnailItem;
222
                    PageChanging(this, new PageChangeEventArgs
223
                    {
224
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
225
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
226
                        PageUri = null
227
                    });
228
                }
229
            }
230
        }
231

    
232
        public void GotoPageTALK(int _pageNumber, int _angle)
233
        {
234
            int _PageNo = -1;
235

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

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

    
264
                    var instanceMain = this.ParentOfType<MainWindow>();
265

    
266
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
267

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

    
286
        public void drawingPannelRotate(bool Flag)
287
        {
288
            var instanceMain = this.ParentOfType<MainWindow>();
289

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

    
313
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
314
            {
315
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
316
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
317
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
318
            }
319

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

    
341
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
342
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
343
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
344
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
345
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
346
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
347

    
348
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
349
            {
350
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
351

    
352
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
353
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
354
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
355

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

    
369
        public void SetNextPage()
370
        {
371
            Logger.sendCheckLog("pageNavigator_PageChanging_SetNextPage", 1);
372
            CurrentPage = _NextPage;
373
            PageChange(_NextPage);
374
        }
375

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

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

    
392
                //txtCurentPageNo.Text = (_itemIndex + 1).ToString();
393

    
394
                //txtCurentPageNo.Text = this.CurrentPage.PageNumber.ToString();
395

    
396
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
397

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

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

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

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

    
423

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

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

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

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

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

    
459
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
460

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

    
467
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
468

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

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

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

    
488

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

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

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

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

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

    
540
                _selectComment.Distinct();
541
            }
542

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

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

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

    
581

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

    
604

    
605

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

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

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

    
619
            //txtTotPageNo.Text = this._PageList.Count().ToString();
620

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

    
623
            if (ImgListbox.ItemsSource == null)
624
            {
625
                ImgListbox.ItemsSource = this._thumbnailItems;
626

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1028
                }
1029

    
1030
            }
1031

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