프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 53880c83

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

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

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

    
34
        private void Sample_Loaded(object sender, RoutedEventArgs e)
35
        {
36
            //측정
37
            //Stopwatch sw = new Stopwatch();
38
            //sw.Start();
39
            InitializeComponent();
40
            //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
41

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

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

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

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

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

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

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

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

    
112
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
113
        {
114
            if (rdoFavoritePages.IsChecked == true)
115
                expCommentPages.IsExpanded = false;
116

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

    
129
        private void SetCommentPages_Favorite()
130
        {
131
            ThumbnailSet();
132
            //_UsersCommentPagesList
133
            //var result = (from A in _UsersCommentPagesList
134
            //              from B in _FavoriteSet
135
            //              where A.PageNumber.Contains(B.PageNo)
136
            //              select A).ToList();
137
            //_UsersCommentPagesList = result;
138

    
139
            SetCommentPages();
140

    
141
        }
142

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

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

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

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

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

    
179
        public bool GotoPageFlag = false;
180

    
181
        /// <summary>
182
        /// 해당 썸네일로 이동
183
        /// </summary>
184
        /// <param name="_pageNumber"></param>
185
        public void GotoPage(int _pageNumber)
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

    
201
        public void setPageChange(ThumbnailItem thumbnailItem)
202
        {
203
            if (thumbnailItem != null)
204
            {
205
                if (PageChanging != null)
206
                {
207
                    //강인구 수정(페이지가 같을 경우 이동 안함)
208
                    if (CurrentPage != null && CurrentPage == thumbnailItem)
209
                    {
210
                        return;
211
                    }
212

    
213
                    this.CurrentPage = _NextPage;
214
                    _NextPage = thumbnailItem;
215
                    PageChanging(this, new PageChangeEventArgs
216
                    {
217
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
218
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
219
                        PageUri = null
220
                    });
221
                }
222
            }
223
        }
224

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

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

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

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

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

    
261
                    if (rotationNum > 0) // 1, 2, 3
262
                    {
263
                        for(int i = 0; i < rotationNum; i++)
264
                        {
265
                            drawingPannelRotate(true);
266
                        }
267
                    }
268
                    else if(rotationNum < 0)// -1, -2, -3
269
                    {
270
                        for (int i = 0; i < -rotationNum; i++)
271
                        {
272
                            drawingPannelRotate(false);
273
                        }
274
                    }                    
275
                }
276
            }
277
        }
278
     
279
        public void drawingPannelRotate(bool Flag)
280
        {
281
            var instanceMain = this.ParentOfType<MainWindow>();
282

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

    
306
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
307
            {
308
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
309
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
310
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
311
            }
312
        
313
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
314
            {
315
                instanceMain.dzMainMenu.translate.X = 0;
316
                instanceMain.dzMainMenu.translate.Y = 0;
317
            }
318
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
319
            {
320
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
321
                instanceMain.dzMainMenu.translate.Y = 0;
322
            }
323
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
324
            {
325
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
326
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
327
            }
328
            else
329
            {
330
                instanceMain.dzMainMenu.translate.X = 0;
331
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
332
            }
333

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

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

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

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

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

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

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

    
383
                //txtCurentPageNo.Text = (_itemIndex + 1).ToString();
384

    
385
                //txtCurentPageNo.Text = this.CurrentPage.PageNumber.ToString();
386

    
387
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
388

    
389
                if (_DocPages.Count() > 0)
390
                {   
391
                    var _page = _DocPages.First();
392

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

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

    
409
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
410
        {
411
            SetCommentPages();
412
        }
413

    
414

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

    
426
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
427
        {
428
            #region 기존 색상 제거 작업
429
            foreach (var item in this._thumbnailItems)
430
            {
431
                item.DisplayColorItems.Clear();
432
            } 
433
            #endregion
434

    
435

    
436

    
437
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
438

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

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

    
449
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
450

    
451
            UsersCommentPagesList.ForEach(user =>
452
            {
453
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
454
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
455

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

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

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

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

    
477

    
478

    
479
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
480
            if (data.Count() != 0)
481
            {
482
                if (Convert.ToBoolean(data.First().isConSolidation))
483
                {
484
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
485
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
486
                    this.lstSelectComment.ItemsSource = data;
487
                }
488
                else
489
                {
490
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
491
                }
492
            }
493
            else
494
            {
495
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
496
            }
497
            //this.ImgListbox.ItemsSource = null;
498
            this.ImgListbox.ItemsSource = this._thumbnailItems;
499
            var template = this.ImgListbox.ItemTemplate;
500
            this.ImgListbox.ItemTemplate = null;
501
            this.ImgListbox.ItemTemplate = template;
502
            this.ImgListbox.UpdateLayout();
503
        }
504

    
505
        private void ThumbnailSet()
506
        {
507
            if (!_Initialize) return;
508

    
509
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
510
            List<int> _selectComment = new List<int>();
511
            if (this.lstSelectComment.ItemsSource != null)
512
            {
513
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
514
                             where commentPage.IsSelected == true
515
                             select commentPage.PageNumber;
516

    
517
                foreach (var item in _pages)
518
                {
519
                    item.ForEach(pp => _selectComment.Add(pp));
520
                }
521

    
522
                _selectComment.Distinct();
523
            }
524

    
525
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
526
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
527
            //this._PageList.ForEach(page =>
528
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
529
            {
530
                var _pageNo = page.PAGE_NUMBER;
531
                bool _addFlag = false;
532

    
533
                if (rdoFavoritePages.IsChecked == false)
534
                {
535
                    if (_selectComment.Count() > 0)
536
                    {
537
                        if ((rdoAllPages.IsChecked == true)
538
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
539
                        {
540
                            _addFlag = true;
541
                        }
542
                    }
543
                    else
544
                    {
545
                        //if (App.ViewInfo.IsCustomPage)
546
                        //{
547
                        //    //_addFlag = false;
548

    
549
                        //    //App.ViewInfo.IsCustomPage = false;
550
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
551
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
552
                        //    this.rdoAllPages.IsChecked = false;
553
                        //    this.rdoFavoritePages.IsChecked = true;
554
                        //    //SetCommentPages();                        
555
                        //}
556
                        //else
557
                        //{
558
                        _addFlag = true;
559
                        //}
560
                    }
561
                }
562

    
563

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

    
586

    
587

    
588
                //this._thumbnailItems.Add(new ThumbnailItem
589
                //{
590
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
591

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

    
594
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
595
                //    //DisplayColorItems = pageColor,
596
                //    PageNumber = Convert.ToInt32(_pageNo),
597
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
598
                //});
599
            });
600

    
601
            //txtTotPageNo.Text = this._PageList.Count().ToString();
602

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

    
605
            if (ImgListbox.ItemsSource == null)
606
            {
607
                ImgListbox.ItemsSource = this._thumbnailItems;
608

    
609
                this._thumbnailItems.ToList().ForEach(data =>
610
                {
611
                    data.Width = ImgListbox.ActualWidth;
612
                });
613

    
614
                if (ImgListbox.Items.Count > 0)
615
                {
616
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
617
                    int StartPageIdx = 1;
618
                    //if (App.ViewInfo.IsCustomPage)
619
                    //{
620
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
621
                    //}
622
                    //else
623
                    //{
624

    
625
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
626
                    {
627
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
628
                    }
629
                    else
630
                    {
631
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
632
                    }
633
                    //}
634
                }
635
            }
636
            else
637
            {
638
                ImgListbox.UpdateLayout();
639
                ImgListbox.ItemsSource = this._thumbnailItems;
640
            }
641
        }
642

    
643
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
644
        {
645
            if (e.ClickCount >= 2)
646
            {
647
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
648
                GotoPage(selectItem.PageNumber);
649
                MarkupToPDF.Controls.Parsing.LayerControl control = new MarkupToPDF.Controls.Parsing.LayerControl();
650
                var result = control.markupParse_GetBaseControl(selectItem.Data);
651
                Rect rect = new Rect(new Point(result.StartPoint.X-100, result.StartPoint.Y-100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));             
652
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
653
                //bool isGO = false;
654

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

    
666
                //};
667
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
668

    
669
                //GotoPage(gogogo.SelectedItem as MarkupList)
670
            }
671
        }
672

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

    
684
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
685
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
686

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

    
690
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
691
                    var markuplist = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
692
                    markuplist.ForEach(d =>
693
                    {
694
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
695
                        {
696
                            Data = d.Data,
697
                            Data_Type = d.Data_Type,
698
                            PageNumber = d.PageNumber,
699
                            UserID = temp.UserID,
700
                            UserName = temp.UserName,
701
                        });
702
                    });
703
                    gogogo.ItemsSource = null;
704
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
705
                    
706
                }                
707
            }
708
            else
709
            {
710
                MarkupInfoSmallList.Clear();
711
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
712
                {
713
                    var markuplist = ViewerDataModel.Instance.MarkupList_USER.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
714

    
715
                    markuplist.ForEach(b =>
716
                    {
717
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
718
                        {
719

    
720
                            Data = b.Data,
721
                            Data_Type = b.Data_Type,
722
                            PageNumber = b.PageNumber,
723
                            UserID = d.UserID,
724
                            UserName = d.UserName,
725
                        });
726
                    });
727

    
728
                });
729
                gogogo.ItemsSource = null;
730
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); 
731
            }
732
        }
733

    
734
        public class MarkupInfoItemSmall
735
        {
736
            public string Id { get; set; }
737
            public string UserName { get; set; }
738
            public string UserID { get; set; }
739
            public int PageNumber { get; set; }
740
            public string Data { get; set; }
741
            public int Data_Type { get; set; }
742
        }
743

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

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

    
779
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
780
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
781

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

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

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

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

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

    
885
                    this.ParentOfType<KCOM.Views.MainMenu>().SelecteItemByRect(rect);
886
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
887
                }
888
                catch (Exception ex)
889
                {
890
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
891
                }
892
            }
893
        }
894
        public void MarkupListReload()
895
        {
896
            ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
897
            {
898
                if (d.MarkupList != null)
899
                {
900
                    d.MarkupList.ForEach(b =>
901
                    {
902
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
903
                        {
904
                            Id = b.ID,
905
                            Data = b.Data,
906
                            Data_Type = b.Data_Type,
907
                            PageNumber = b.PageNumber,
908
                            UserID = d.UserID,
909
                            UserName = d.UserName,
910
                        });
911
                    });
912
                }
913
            });
914
            gogogo.ItemsSource = null;
915
            gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
916

    
917
            commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
918
            commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
919
        }
920
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
921
        {
922
            if (MarkupInfoSmallList.Count == 0)
923
            {
924
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
925
                {
926
                    if (d.MarkupList != null)
927
                    {
928
                        d.MarkupList.ForEach(b =>
929
                        {
930
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
931
                            {
932
                                Id = b.ID,
933
                                Data = b.Data,
934
                                Data_Type = b.Data_Type,
935
                                PageNumber = b.PageNumber,
936
                                UserID = d.UserID,
937
                                UserName = d.UserName,
938
                            });
939
                        });
940
                    }
941
                });
942
                gogogo.ItemsSource = null;
943
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
944

    
945
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d=>d).ToList();
946
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
947
            }
948
        }
949

    
950
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
951
        {
952
            gogogo.ItemsSource = null;
953
            tbSearch.Text = string.Empty;
954
            if (e.AddedItems.Count >0)
955
            {
956
                
957
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
958
            }
959
            else
960
            {
961
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
962
            }
963
        }
964

    
965
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
966
        {
967
            gogogo.ItemsSource = null;
968
            tbSearch.Text = string.Empty;
969
            if (e.AddedItems.Count > 0)
970
            {
971
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
972
            }
973
            else
974
            {
975
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
976
            }
977
        }
978

    
979
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
980
        {
981
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
982
        }
983

    
984
        private void btnSearch_Click(object sender, RoutedEventArgs e)
985
        {
986
            string search_str = tbSearch.Text;
987
            var sel_type = commentType.SelectedItem;
988
            var sel_user = commentUser.SelectedItem;
989
            var sel_page = commentPage.SelectedItem;
990
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
991
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
992
            if(sel_page !=null)
993
            {
994
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
995
            }
996
            if(sel_type !=null)
997
            {
998
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
999
            }
1000
            if (sel_user != null)
1001
            {
1002
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1003
            }
1004
            foreach (var item in list)
1005
            {
1006
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
1007
                
1008
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1009
                {                    
1010
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1011
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1012
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1013
                        {
1014
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1015
                            if (instance.Text.Contains(search_str))
1016
                            {                                
1017
                                small_list.Add(item);
1018
                            }
1019
                        }
1020
                        break;
1021
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1022
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1023
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1024
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1025
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1026
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1027
                        {
1028
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1029
                            if (instance.ArrowText.Contains(search_str))
1030
                            {
1031
                                small_list.Add(item);
1032
                            }
1033
                        }
1034
                        break;
1035
                    
1036
                }
1037
                
1038
            }
1039
            
1040
            gogogo.ItemsSource = null;
1041
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1042
            tbSearch.Text = string.Empty;
1043
        }
1044
        
1045
    }
1046
}
클립보드 이미지 추가 (최대 크기: 500 MB)