프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 944be2fa

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

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

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

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

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

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

    
50
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
51
        private List<DOCPAGE> _PageList = null;
52
        private string _DefaultUri = null;
53
        public ThumbnailItem CurrentPage = null;
54
        ///public ThumbnailItem _NextPage = null;
55
        public int PageCount = 0;
56

    
57
        private bool _Initialize;
58
        public event EventHandler<PageChangeEventArgs> PageChanged;
59
        public event EventHandler<PageChangeEventArgs> PageChanging;
60
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
61
        public class PageChangeEventArgs : EventArgs
62
        {
63
            public DOCPAGE CurrentPage { get; set; }
64
            public string PageUri { get; set; }
65
            public int PageNumber { get; set; }
66
        }
67

    
68
        private bool _IsFitOn { get; set; }
69
        public bool IsFitOn
70
        {
71
            get
72
            {
73
                return _IsFitOn;
74
            }
75
            set
76
            {
77
                _IsFitOn = value;
78
                RaisePropertyChanged("IsFitOn");
79
            }
80
        }
81

    
82
        public void RaisePropertyChanged(string propName)
83
        {
84
            if (PropertyChanged != null)
85
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
86
        }
87

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

    
108
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
109
        {
110
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
111
            if (rdoFavoritePages.IsChecked == true)
112
                expCommentPages.IsExpanded = false;
113

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

    
126
        private void SetCommentPages_Favorite()
127
        {
128
            ThumbnailSet();            
129
            SetCommentPages();
130
        }
131

    
132
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
133
        {
134
            //txtThumbCount.Visibility = Visibility.Collapsed;            
135
        }
136

    
137
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
138
        {
139
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
140
            rdoAllPages.IsChecked = false;
141
            rdoFavoritePages.IsChecked = false;
142
            //txtThumbCount.Visibility = Visibility.Visible;
143
            SetCommentPages();
144
        }
145

    
146
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
147
        {            
148
            if (ImgListbox.SelectedItem != null)
149
            {
150
                int _CurrentPageNo = -1;
151
                if (this.CurrentPage != null) _CurrentPageNo = this.CurrentPage.PageNumber;
152

    
153
                int iPageNo = ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
154
                if(_CurrentPageNo != iPageNo)
155
                {
156
                    ///this.CurrentPage = this._NextPage;
157
                    ///this._NextPage = thumbnailItem;
158
                    PageChanging(this, new PageChangeEventArgs
159
                    {
160
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
161
                        PageNumber = iPageNo,
162
                        PageUri = null
163
                    });
164
                }
165
            }
166

    
167
            var border = VisualTreeHelper.GetChild(ImgListbox, 0);
168
            if(border!= null)
169
            {
170
                IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
171

    
172
            }
173
        }
174

    
175
        public bool GotoPageFlag = false;
176

    
177
        /// <summary>
178
        /// 해당 썸네일로 이동
179
        /// </summary>
180
        /// <param name="_pageNumber">이동할 페이지 번호</param>
181
        public void GotoPage(int _pageNumber)
182
        {
183
            try
184
            {
185
                var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
186
                if (_page.Count() > 0)
187
                {
188
                    ThumbnailItem thumbnailitem = _page.First();
189
                    if (PageChanging != null)
190
                    {
191
                        var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
192
                        ImgListbox.SelectedItem = thumbnailitem;
193

    
194
                        if (_itemIndex < _thumbnailItems.Count() - 1)
195
                            ImgListbox.ScrollIntoView(_itemIndex);
196
                        else
197
                            ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
198
                    }
199
                }
200
            }
201
            catch(Exception ex)
202
            {
203
                Logger.sendResLog("GotoPage", ex.Message, 0);
204
            }
205
        }
206

    
207
        /// <summary>
208
        /// 주어진 페이지로 변경한다
209
        /// </summary>
210
        /// <param name="iPageNo">변경할 페이지 번호</param>
211
        public void ChangePage(int iPageNo)
212
        {
213
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
214
            if ((PageChanged != null) && (thumbitem != null))
215
            {
216
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
217
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
218

    
219
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
220
                if (_DocPages.Count() > 0)
221
                {
222
                    var _page = _DocPages.First();
223

    
224
                    PageChanged(this, new PageChangeEventArgs
225
                    {
226
                        CurrentPage = _page,
227
                        PageUri = uri,
228
                        PageNumber = thumbitem.PageNumber
229
                    });
230
                    ImgListbox.SelectedItem = thumbitem;
231
                    this.CurrentPage = thumbitem;
232
                }
233
                else
234
                {
235
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
236
                }
237
            }
238
        }
239

    
240
        public void GotoPageTALK(int _pageNumber, int _angle)
241
        {
242
            int _PageNo = -1;
243

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

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

    
272
                    var instanceMain = this.ParentOfType<MainWindow>();
273

    
274
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
275

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

    
294
        public void drawingPannelRotate(bool Flag)
295
        {
296
            var instanceMain = this.ParentOfType<MainWindow>();
297

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

    
321
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
322
            {
323
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
324
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
325
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
326
            }
327

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

    
349
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
350
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
351
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
352
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
353
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
354
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
355

    
356
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
357
            {
358
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
359

    
360
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
361
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
362
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
363

    
364
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
365
                if (rotationdoc != null)
366
                {
367
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
368
                }
369
                else
370
                {
371
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
372
                }
373
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
374
            });
375
        }
376

    
377
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
378
        {
379
            SetCommentPages();
380
        }
381

    
382

    
383
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
384
        {
385
            SetCommentPages();
386
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
387
        }
388
        public void SetCommentPages()
389
        {
390
            ThumbnailSet();
391
            SetCommentList(_UsersCommentPagesList.ToList());
392
        }
393

    
394
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
395
        {
396
            Logger.sendCheckLog("SetCommentList", 1);
397
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
398
            #region 기존 색상 제거 작업
399
            foreach (var item in this._thumbnailItems)
400
            {
401
                item.DisplayColorItems.Clear();
402
            }
403
            #endregion
404

    
405
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
406
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
407

    
408
            _UsersCommentPagesList.ToList().ForEach(item =>
409
            {
410
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
411

    
412
                if (_comm.Count() == 0)
413
                {
414
                    _delItem.Add(item);
415
                }
416
            });
417

    
418
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
419

    
420
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
421
            UsersCommentPagesList.ForEach(user =>
422
            {
423
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
424
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
425

    
426
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
427

    
428
                if (_commLst.Count() == 0)
429
                {
430
                    _UsersCommentPagesList.Add(user);
431
                }
432
                else
433
                {
434
                    if (_commLst.First().PageNumber != user.PageNumber)
435
                        _commLst.First().PageNumber = user.PageNumber;
436
                }
437

    
438
                user.PageNumber.ForEach(page =>
439
                {
440
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
441

    
442
                    if (_items.Count() > 0)
443
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
444
                });
445
            });
446

    
447

    
448
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
449
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
450
            if (data.Count() != 0)
451
            {
452
                if (Convert.ToBoolean(data.First().isConSolidation))
453
                {
454
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
455
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
456
                    this.lstSelectComment.ItemsSource = data;
457
                }
458
                else
459
                {
460
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
461
                }
462
            }
463
            else
464
            {
465
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
466
            }
467
            //this.ImgListbox.ItemsSource = null;
468
            Logger.sendCheckLog("SetCommentList_ImgListbox 설정", 1);
469

    
470
       
471
                this.ImgListbox.ItemsSource = this._thumbnailItems;
472
                var template = this.ImgListbox.ItemTemplate;
473
                this.ImgListbox.ItemTemplate = null;
474
                this.ImgListbox.ItemTemplate = template;
475
               //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_Start", 1);
476
                //this.ImgListbox.UpdateLayout();
477
                //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_End", 1);
478
           
479
        }
480

    
481
        private void ThumbnailSet()
482
        {
483
            Logger.sendCheckLog("ThumbnailSet", 1);
484
            if (!_Initialize) return;
485

    
486
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
487
            List<int> _selectComment = new List<int>();
488
            if (this.lstSelectComment.ItemsSource != null)
489
            {
490
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
491
                             where commentPage.IsSelected == true
492
                             select commentPage.PageNumber;
493

    
494
                foreach (var item in _pages)
495
                {
496
                    item.ForEach(pp => _selectComment.Add(pp));
497
                }
498

    
499
                _selectComment.Distinct();
500
            }
501

    
502
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
503
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
504
            //this._PageList.ForEach(page =>
505
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
506
            {
507
                var _pageNo = page.PAGE_NUMBER;
508
                bool _addFlag = false;
509

    
510
                if (rdoFavoritePages.IsChecked == false)
511
                {
512
                    if (_selectComment.Count() > 0)
513
                    {
514
                        if ((rdoAllPages.IsChecked == true)
515
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
516
                        {
517
                            _addFlag = true;
518
                        }
519
                    }
520
                    else
521
                    {
522
                        //if (App.ViewInfo.IsCustomPage)
523
                        //{
524
                        //    //_addFlag = false;
525

    
526
                        //    //App.ViewInfo.IsCustomPage = false;
527
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
528
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
529
                        //    this.rdoAllPages.IsChecked = false;
530
                        //    this.rdoFavoritePages.IsChecked = true;
531
                        //    //SetCommentPages();                        
532
                        //}
533
                        //else
534
                        //{
535
                        _addFlag = true;
536
                        //}
537
                    }
538
                }
539

    
540

    
541
                if (_addFlag)
542
                {
543
                    this._thumbnailItems.Add(new ThumbnailItem
544
                    {
545
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
546
                        PageNumber = _pageNo,
547
                        Angle = page.PAGE_ANGLE,
548
                    });
549
                }
550
                else
551
                {
552
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
553
                    {
554
                        this._thumbnailItems.Add(new ThumbnailItem
555
                        {
556
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
557
                            PageNumber = _pageNo,
558
                            Angle = page.PAGE_ANGLE,
559
                        });
560
                    }
561
                }
562

    
563

    
564

    
565
                //this._thumbnailItems.Add(new ThumbnailItem
566
                //{
567
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
568

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

    
571
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
572
                //    //DisplayColorItems = pageColor,
573
                //    PageNumber = Convert.ToInt32(_pageNo),
574
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
575
                //});
576
            });
577

    
578
            //txtTotPageNo.Text = this._PageList.Count().ToString();
579

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

    
582
            if (ImgListbox.ItemsSource == null)
583
            {
584
                ImgListbox.ItemsSource = this._thumbnailItems;
585

    
586
                this._thumbnailItems.ToList().ForEach(data =>
587
                {
588
                    data.Width = ImgListbox.ActualWidth;
589
                    data.Height = ImgListbox.ActualHeight;
590
                });
591

    
592
                if (ImgListbox.Items.Count > 0)
593
                {
594
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
595
                    int StartPageIdx = 1;
596
                    //if (App.ViewInfo.IsCustomPage)
597
                    //{
598
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
599
                    //}
600
                    //else
601
                    //{
602

    
603
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
604
                    {
605
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
606
                    }
607
                    else
608
                    {
609
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
610
                    }
611
                    //}
612
                }
613
            }
614
            else
615
            {
616
                ImgListbox.UpdateLayout();
617
                ImgListbox.ItemsSource = this._thumbnailItems;
618
            }
619
        }
620

    
621
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
622
        {
623
            if (e.ClickCount >= 2)
624
            {
625
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
626
                GotoPage(selectItem.PageNumber);
627
                var result = MarkupParser.GetBaseControl(selectItem.Data);
628
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
629
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
630
                //bool isGO = false;
631

    
632
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
633
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
634
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
635
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
636
                //{
637
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
638
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
639
                //    {
640
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
641
                //    }
642

    
643
                //};
644
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
645

    
646
                //GotoPage(gogogo.SelectedItem as MarkupList)
647
            }
648
        }
649

    
650
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
651
        {
652
            tbSearch.Text = string.Empty;
653
            if (e.AddedItems.Count > 0)
654
            {
655
                if (commentUser.Items.Count > 0)
656
                {
657
                    MarkupInfoSmallList.Clear();
658
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
659
                    //d.PageNumber
660

    
661
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
662
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
663

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

    
667
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
668
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
669
                    markuplist.ForEach(d =>
670
                    {
671
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
672
                        {
673
                            Data = d.Data,
674
                            Data_Type = d.Data_Type,
675
                            PageNumber = d.PageNumber,
676
                            UserID = temp.UserID,
677
                            UserName = temp.UserName,
678
                        });
679
                    });
680
                    gogogo.ItemsSource = null;
681
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
682

    
683
                }
684
            }
685
            else
686
            {
687
                MarkupInfoSmallList.Clear();
688
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
689
                {
690
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
691

    
692
                    markuplist.ForEach(b =>
693
                    {
694
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
695
                        {
696

    
697
                            Data = b.Data,
698
                            Data_Type = b.Data_Type,
699
                            PageNumber = b.PageNumber,
700
                            UserID = d.UserID,
701
                            UserName = d.UserName,
702
                        });
703
                    });
704

    
705
                });
706
                gogogo.ItemsSource = null;
707
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
708
            }
709
        }
710

    
711
        public class MarkupInfoItemSmall
712
        {
713
            public string Id { get; set; }
714
            public string UserName { get; set; }
715
            public string UserID { get; set; }
716
            public int PageNumber { get; set; }
717
            public string Data { get; set; }
718
            public int Data_Type { get; set; }
719
        }
720

    
721
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
722
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
723
        {
724
            get
725
            {
726
                if (_MarkupInfoSmallList == null)
727
                {
728
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
729
                }
730
                return _MarkupInfoSmallList;
731
            }
732
            set
733
            {
734

    
735
                _MarkupInfoSmallList = value;
736
                RaisePropertyChanged("MarkupInfoSmallList");
737
            }
738
        }
739

    
740
        /// <summary>
741
        /// goto page and select item selected by user
742
        /// </summary>
743
        /// <param name="sender"></param>
744
        /// <param name="e"></param>
745
        private void RadButton_Click(object sender, RoutedEventArgs e)
746
        {
747
            var clickButtonItem = sender as RadButton;
748
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
749
            {
750
                try
751
                {
752
                    Rect rect = new Rect();
753
                    Point s_point = new Point();
754
                    Point e_point = new Point();
755

    
756
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
757
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
758

    
759
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
760
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
761
                    {
762
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
763
                            {
764
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
765
                                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));
766
                            }
767
                            break;
768
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
769
                            {
770
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
771
                                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));
772
                            }
773
                            break;
774
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
775
                            {
776
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
777
                                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));
778
                            }
779
                            break;
780
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
781
                            {
782
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
783

    
784
                                foreach (Point A in instance.PointSet)
785
                                {
786
                                    if (s_point == new Point())
787
                                    {
788
                                        s_point = A;
789
                                        e_point = A;
790
                                    }
791
                                    s_point.X = Math.Min(s_point.X, A.X);
792
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
793
                                    e_point.X = Math.Max(e_point.X, A.X);
794
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
795
                                }
796
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
797
                            }
798
                            break;
799
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
800
                            {
801
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
802

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

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

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

    
862
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
863
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
864
                }
865
                catch (Exception ex)
866
                {
867
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
868
                }
869
            }
870
        }
871

    
872
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
873
        {
874
            if (MarkupInfoSmallList.Count == 0)
875
            {
876
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
877
                {
878
                    if (d.MarkupList != null)
879
                    {
880
                        d.MarkupList.ForEach(b =>
881
                        {
882
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
883
                            {
884
                                Id = b.ID,
885
                                Data = b.Data,
886
                                Data_Type = b.Data_Type,
887
                                PageNumber = b.PageNumber,
888
                                UserID = d.UserID,
889
                                UserName = d.UserName,
890
                            });
891
                        });
892
                    }
893
                });
894
                gogogo.ItemsSource = null;
895
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
896

    
897
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
898
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
899
            }
900
        }
901

    
902
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
903
        {
904
            gogogo.ItemsSource = null;
905
            tbSearch.Text = string.Empty;
906
            if (e.AddedItems.Count > 0)
907
            {
908

    
909
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
910
            }
911
            else
912
            {
913
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
914
            }
915
        }
916

    
917
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
918
        {
919
            gogogo.ItemsSource = null;
920
            tbSearch.Text = string.Empty;
921
            if (e.AddedItems.Count > 0)
922
            {
923
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
924
            }
925
            else
926
            {
927
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
928
            }
929
        }
930

    
931
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
932
        {
933
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
934
        }
935

    
936
        private void btnSearch_Click(object sender, RoutedEventArgs e)
937
        {
938
            string search_str = tbSearch.Text;
939
            var sel_type = commentType.SelectedItem;
940
            var sel_user = commentUser.SelectedItem;
941
            var sel_page = commentPage.SelectedItem;
942
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
943
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
944
            if (sel_page != null)
945
            {
946
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
947
            }
948
            if (sel_type != null)
949
            {
950
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
951
            }
952
            if (sel_user != null)
953
            {
954
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
955
            }
956
            foreach (var item in list)
957
            {
958
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
959

    
960
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
961
                {
962
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
963
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
964
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
965
                        {
966
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
967
                            if (instance.Text.Contains(search_str))
968
                            {
969
                                small_list.Add(item);
970
                            }
971
                        }
972
                        break;
973
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
974
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
975
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
976
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
977
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
978
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
979
                        {
980
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
981
                            if (instance.ArrowText.Contains(search_str))
982
                            {
983
                                small_list.Add(item);
984
                            }
985
                        }
986
                        break;
987

    
988
                }
989

    
990
            }
991

    
992
            gogogo.ItemsSource = null;
993
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
994
            tbSearch.Text = string.Empty;
995
        }
996
    }
997
}
클립보드 이미지 추가 (최대 크기: 500 MB)