프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 8fb54282

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

1 787a4489 KangIngu
using IKCOM;
2
using KCOM.Common;
3
using KCOMDataModel.DataModel;
4 4eb052e4 ljiyeon
using MarkupToPDF.Common;
5 5529d2a2 humkyung
using MarkupToPDF.Controls.Parsing;
6 787a4489 KangIngu
using System;
7
using System.Collections.Generic;
8
using System.Collections.ObjectModel;
9
using System.ComponentModel;
10 0c997b99 ljiyeon
using System.Diagnostics;
11 787a4489 KangIngu
using System.Linq;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Input;
15 83a98e96 송근호
using System.Windows.Media;
16 787a4489 KangIngu
using Telerik.Windows.Controls;
17 4eb052e4 ljiyeon
using static MarkupToPDF.Controls.Parsing.MarkupParser;
18 787a4489 KangIngu
19
namespace KCOM.Controls
20
{
21
    /// <summary>
22
    /// Interaction logic for PageNavigator.xaml
23
    /// </summary>
24
    public partial class Sample : UserControl, INotifyPropertyChanged
25
    {
26 992a98b4 KangIngu
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
27 787a4489 KangIngu
        public event PropertyChangedEventHandler PropertyChanged;
28
        public Sample()
29 f65e6c02 taeseongkim
        {
30
            InitializeComponent();
31
32
            if (App.IsDesignMode)
33 2089959a taeseongkim
            {
34
                return;
35
            }
36
37 f65e6c02 taeseongkim
            //App.splashString(ISplashMessage.SAMPLE);
38 0c997b99 ljiyeon
            this.Loaded += Sample_Loaded;
39
        }
40
41
        private void Sample_Loaded(object sender, RoutedEventArgs e)
42
        {
43 afaa7c92 djkim
            if(!_Initialize)
44
            {
45
                _Initialize = true;
46 f65e6c02 taeseongkim
47 afaa7c92 djkim
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
48
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
49
            }            
50 787a4489 KangIngu
        }
51
52
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
53
        private List<DOCPAGE> _PageList = null;
54
        private string _DefaultUri = null;
55
        public ThumbnailItem CurrentPage = null;
56
        public int PageCount = 0;
57
        private bool _Initialize;
58
        public event EventHandler<PageChangeEventArgs> PageChanged;
59
        public event EventHandler<PageChangeEventArgs> PageChanging;
60 f65e6c02 taeseongkim
61
        private List<UsersCommentPagesMember> _UsersCommentPagesList;
62
63
        public List<UsersCommentPagesMember> UsersCommentPagesList
64
        {
65
            get {
66
                if(_UsersCommentPagesList == null)
67
                {
68
                    _UsersCommentPagesList = new List<UsersCommentPagesMember>();
69
                }
70
71
                return _UsersCommentPagesList; }
72
            set { _UsersCommentPagesList = value; }
73
        }
74
75 787a4489 KangIngu
        public class PageChangeEventArgs : EventArgs
76
        {
77
            public DOCPAGE CurrentPage { get; set; }
78
            public string PageUri { get; set; }
79
            public int PageNumber { get; set; }
80
        }
81
        private bool _IsFitOn { get; set; }
82
        public bool IsFitOn
83
        {
84
            get
85
            {
86
                return _IsFitOn;
87
            }
88
            set
89
            {
90
                _IsFitOn = value;
91
                RaisePropertyChanged("IsFitOn");
92
            }
93
        }
94
95
        public void RaisePropertyChanged(string propName)
96
        {
97
            if (PropertyChanged != null)
98
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
99
        }
100
101
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
102
        {
103
            this._PageList = PageList;
104
            this._DefaultUri = DefaultUri;
105
            ThumbnailSet();
106
            this.PageCount = PageList.Count();
107
            //ThumbNmailSet();
108
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
109
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
110
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
111
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
112
        }
113 39f0624f ljiyeon
114 787a4489 KangIngu
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
115
        {
116 548c696e ljiyeon
            Logger.sendCheckLog("rdoCommented_Checked", 1);
117 787a4489 KangIngu
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
118
            SetCommentPages();
119
        }
120
121
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
122
        {
123 548c696e ljiyeon
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
124 992a98b4 KangIngu
            if (rdoFavoritePages.IsChecked == true)
125
                expCommentPages.IsExpanded = false;
126
127 90e7968d ljiyeon
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
128 992a98b4 KangIngu
            if (_FavoriteSet.Count > 0)
129
            {
130
                SetCommentPages_Favorite(); //수정    
131
            }
132
            else
133
            {
134
                rdoAllPages.IsChecked = true;
135
                rdoFavoritePages.IsChecked = false;
136
            }
137
        }
138
139
        private void SetCommentPages_Favorite()
140
        {
141 90e7968d ljiyeon
            ThumbnailSet();            
142 992a98b4 KangIngu
            SetCommentPages();
143 787a4489 KangIngu
        }
144 992a98b4 KangIngu
145 787a4489 KangIngu
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
146
        {
147
            //txtThumbCount.Visibility = Visibility.Collapsed;            
148
        }
149
150
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
151
        {
152 548c696e ljiyeon
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
153 787a4489 KangIngu
            rdoAllPages.IsChecked = false;
154
            rdoFavoritePages.IsChecked = false;
155
            //txtThumbCount.Visibility = Visibility.Visible;
156
            SetCommentPages();
157
        }
158
159 129ca191 humkyung
        /// <summary>
160
        /// called when image list box's selection is changed
161
        /// </summary>
162
        /// <param name="sender"></param>
163
        /// <param name="e"></param>
164 787a4489 KangIngu
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
165 d7e20d2d taeseongkim
        {
166 dea506e2 taeseongkim
            if(e.AddedItems.Count > 0)
167 787a4489 KangIngu
            {
168 dea506e2 taeseongkim
                var number = (e.AddedItems[0] as KCOM.Common.ThumbnailItem).PageNumber;
169 d7e20d2d taeseongkim
170 dea506e2 taeseongkim
                ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
171 787a4489 KangIngu
172 dea506e2 taeseongkim
                this.CurrentPage = e.AddedItems[0] as KCOM.Common.ThumbnailItem;
173
174
                PageChanging(this, new PageChangeEventArgs
175 787a4489 KangIngu
                {
176 dea506e2 taeseongkim
                    CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
177
                    PageNumber = number,
178
                    PageUri = null
179
                });
180 787a4489 KangIngu
            }
181 dea506e2 taeseongkim
            
182
183
            //if (ImgListbox.SelectedItem != null)
184
            //{
185
            //    int _CurrentPageNo = -1;
186
            //    if (this.CurrentPage != null)
187
            //    {
188
            //        ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
189
190
            //        _CurrentPageNo = this.CurrentPage.PageNumber;
191
            //    }
192
193
            //    this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
194
            //    int iPageNo = this.CurrentPage.PageNumber;
195
            //    if(_CurrentPageNo != iPageNo)
196
            //    {
197
            //        PageChanging(this, new PageChangeEventArgs
198
            //        {
199
            //            CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
200
            //            PageNumber = iPageNo,
201
            //            PageUri = null
202
            //        });
203
            //    }
204
            //}
205 3908a575 humkyung
206 2d584f1a djkim
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
207
            //if (border != null)
208
            //{
209
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
210
211
            //}
212
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
213
214
            
215
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
216 787a4489 KangIngu
        }
217
218
        public bool GotoPageFlag = false;
219
220 b2a6b24a humkyung
        /// <summary>
221
        /// 해당 썸네일로 이동
222
        /// </summary>
223 3908a575 humkyung
        /// <param name="_pageNumber">이동할 페이지 번호</param>
224 787a4489 KangIngu
        public void GotoPage(int _pageNumber)
225
        {
226 90e7968d ljiyeon
            try
227 787a4489 KangIngu
            {
228 a1142a6b taeseongkim
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
229
230
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
231
                    if (_page.Count() > 0)
232 90e7968d ljiyeon
                    {
233 a1142a6b taeseongkim
                        ThumbnailItem thumbnailitem = _page.First();
234
                        if (PageChanging != null)
235
                        {
236
237
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
238
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
239
                                ImgListbox.SelectedItem = thumbnailitem;
240
                            });
241
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
242
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
243
                            //    ImgListbox.ScrollIntoView(_itemIndex);
244
                            //else
245
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
246
                        }
247 90e7968d ljiyeon
                    }
248 a1142a6b taeseongkim
249
                }).ConfigureAwait(true);
250 787a4489 KangIngu
            }
251 90e7968d ljiyeon
            catch(Exception ex)
252
            {
253
                Logger.sendResLog("GotoPage", ex.Message, 0);
254
            }
255
        }
256 787a4489 KangIngu
257 3908a575 humkyung
        /// <summary>
258
        /// 주어진 페이지로 변경한다
259
        /// </summary>
260
        /// <param name="iPageNo">변경할 페이지 번호</param>
261
        public void ChangePage(int iPageNo)
262 787a4489 KangIngu
        {
263 3908a575 humkyung
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
264
            if ((PageChanged != null) && (thumbitem != null))
265 787a4489 KangIngu
            {
266 d48260a2 djkim
                var uri = thumbitem.PageUri.ToString();
267
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
268 3908a575 humkyung
269 d48260a2 djkim
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
270
                if (_DocPages != null)
271 3908a575 humkyung
                {
272
                    PageChanged(this, new PageChangeEventArgs
273 787a4489 KangIngu
                    {
274 d48260a2 djkim
                        CurrentPage = _DocPages,
275 3908a575 humkyung
                        PageUri = uri,
276
                        PageNumber = thumbitem.PageNumber
277 787a4489 KangIngu
                    });
278 2d584f1a djkim
                    //ImgListbox.SelectedItem = thumbitem;                    
279
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
280
                    
281 944be2fa djkim
                    this.CurrentPage = thumbitem;
282 3908a575 humkyung
                }
283
                else
284
                {
285
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
286 787a4489 KangIngu
                }
287
            }
288
        }
289 64f6713a humkyung
290 d974f3f8 ljiyeon
        public void GotoPageTALK(int _pageNumber, int _angle)
291
        {
292
            int _PageNo = -1;
293
294
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
295
            {
296
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
297
                if (_page.Count() > 0)
298
                {
299
                    ThumbnailItem _item = _page.First();
300
                    setPageChangeTALK(_item, _angle);
301
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
302 6443ebfe djkim
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
303 d974f3f8 ljiyeon
                }
304
            }
305
        }
306
307
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
308
        {
309
            if (thumbnailItem != null)
310
            {
311
                if (PageChanging != null)
312 90e7968d ljiyeon
                {
313 3908a575 humkyung
                    ///this.CurrentPage = _NextPage;
314
                    ///_NextPage = thumbnailItem;
315 d974f3f8 ljiyeon
                    PageChanging(this, new PageChangeEventArgs
316
                    {
317
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
318
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
319
                        PageUri = null
320
                    });
321
322
                    var instanceMain = this.ParentOfType<MainWindow>();
323
324
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
325
326
                    if (rotationNum > 0) // 1, 2, 3
327
                    {
328 90e7968d ljiyeon
                        for (int i = 0; i < rotationNum; i++)
329 d974f3f8 ljiyeon
                        {
330
                            drawingPannelRotate(true);
331
                        }
332
                    }
333 90e7968d ljiyeon
                    else if (rotationNum < 0)// -1, -2, -3
334 d974f3f8 ljiyeon
                    {
335
                        for (int i = 0; i < -rotationNum; i++)
336
                        {
337
                            drawingPannelRotate(false);
338
                        }
339 90e7968d ljiyeon
                    }
340 d974f3f8 ljiyeon
                }
341
            }
342
        }
343 90e7968d ljiyeon
344 d974f3f8 ljiyeon
        public void drawingPannelRotate(bool Flag)
345
        {
346
            var instanceMain = this.ParentOfType<MainWindow>();
347
348
            if (Flag)
349
            {
350
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
351
                {
352
                    instanceMain.dzMainMenu.rotate.Angle = 0;
353
                }
354
                else
355
                {
356
                    instanceMain.dzMainMenu.rotate.Angle += 90;
357
                }
358
            }
359
            else
360
            {
361
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
362
                {
363
                    instanceMain.dzMainMenu.rotate.Angle = 270;
364
                }
365
                else
366
                {
367
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
368
                }
369
            }
370
371
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
372
            {
373
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
374
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
375
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
376
            }
377 90e7968d ljiyeon
378 d974f3f8 ljiyeon
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
379
            {
380
                instanceMain.dzMainMenu.translate.X = 0;
381
                instanceMain.dzMainMenu.translate.Y = 0;
382
            }
383
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
384
            {
385
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
386
                instanceMain.dzMainMenu.translate.Y = 0;
387
            }
388
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
389
            {
390
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
391
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
392
            }
393
            else
394
            {
395
                instanceMain.dzMainMenu.translate.X = 0;
396
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
397
            }
398
399
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
400
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
401
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
402
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
403
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
404
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
405
406
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
407
            {
408
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
409
410
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
411
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
412
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
413
414
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
415
                if (rotationdoc != null)
416
                {
417
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
418
                }
419
                else
420
                {
421
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
422
                }
423 3908a575 humkyung
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
424 d974f3f8 ljiyeon
            });
425
        }
426
427 787a4489 KangIngu
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
428
        {
429
            SetCommentPages();
430
        }
431 39f0624f ljiyeon
        
432 787a4489 KangIngu
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
433
        {
434
            SetCommentPages();
435 6c781c0c djkim
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
436 787a4489 KangIngu
        }
437 39f0624f ljiyeon
438 787a4489 KangIngu
        public void SetCommentPages()
439
        {
440
            ThumbnailSet();
441 f65e6c02 taeseongkim
            SetCommentList(UsersCommentPagesList.ToList());
442 787a4489 KangIngu
        }
443
444
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
445
        {
446 548c696e ljiyeon
            Logger.sendCheckLog("SetCommentList", 1);
447 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
448 787a4489 KangIngu
            #region 기존 색상 제거 작업
449
            foreach (var item in this._thumbnailItems)
450
            {
451
                item.DisplayColorItems.Clear();
452 122914ba ljiyeon
            }
453 787a4489 KangIngu
            #endregion
454
455 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
456 787a4489 KangIngu
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
457
458 f65e6c02 taeseongkim
            this.UsersCommentPagesList.ToList().ForEach(item =>
459 787a4489 KangIngu
            {
460
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
461
462
                if (_comm.Count() == 0)
463
                {
464
                    _delItem.Add(item);
465
                }
466
            });
467
468 f65e6c02 taeseongkim
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
469 787a4489 KangIngu
470 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
471 81e3a60f 송근호
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
472
473 787a4489 KangIngu
            UsersCommentPagesList.ForEach(user =>
474
            {
475
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
476
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
477
478 f65e6c02 taeseongkim
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
479 787a4489 KangIngu
480
                if (_commLst.Count() == 0)
481
                {
482 f65e6c02 taeseongkim
                    this.UsersCommentPagesList.Add(user);
483 787a4489 KangIngu
                }
484
                else
485
                {
486
                    if (_commLst.First().PageNumber != user.PageNumber)
487
                        _commLst.First().PageNumber = user.PageNumber;
488
                }
489
490
                user.PageNumber.ForEach(page =>
491
                {
492
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
493
494
                    if (_items.Count() > 0)
495 81e3a60f 송근호
                    {
496
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
497
                        
498
                    }
499
                        
500 787a4489 KangIngu
                });
501
            });
502
503 81e3a60f 송근호
            foreach (var item in this._thumbnailItems)
504
            {
505 8ff1bf3a 송근호
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
506 81e3a60f 송근호
            }
507
            
508 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
509 f65e6c02 taeseongkim
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
510 787a4489 KangIngu
            if (data.Count() != 0)
511
            {
512
                if (Convert.ToBoolean(data.First().isConSolidation))
513
                {
514
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
515
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
516
                    this.lstSelectComment.ItemsSource = data;
517
                }
518
                else
519
                {
520 f65e6c02 taeseongkim
                    this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
521 787a4489 KangIngu
                }
522
            }
523
            else
524
            {
525 f65e6c02 taeseongkim
                this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
526 787a4489 KangIngu
            }
527 f65e6c02 taeseongkim
528 81e3a60f 송근호
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
529 90e7968d ljiyeon
530 2d584f1a djkim
531 81e3a60f 송근호
            //var template = this.ImgListbox.ItemTemplate;
532
            //this.ImgListbox.ItemTemplate = null;
533
            //this.ImgListbox.ItemTemplate = template;
534 2d584f1a djkim
535 787a4489 KangIngu
        }
536
537
        private void ThumbnailSet()
538
        {
539 548c696e ljiyeon
            Logger.sendCheckLog("ThumbnailSet", 1);
540 787a4489 KangIngu
            if (!_Initialize) return;
541
542
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
543
            List<int> _selectComment = new List<int>();
544
            if (this.lstSelectComment.ItemsSource != null)
545
            {
546
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
547
                             where commentPage.IsSelected == true
548
                             select commentPage.PageNumber;
549
550
                foreach (var item in _pages)
551
                {
552
                    item.ForEach(pp => _selectComment.Add(pp));
553
                }
554
555
                _selectComment.Distinct();
556
            }
557
558
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
559
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
560
            //this._PageList.ForEach(page =>
561
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
562
            {
563
                var _pageNo = page.PAGE_NUMBER;
564
                bool _addFlag = false;
565
566 276fdd9b KangIngu
                if (rdoFavoritePages.IsChecked == false)
567 787a4489 KangIngu
                {
568 276fdd9b KangIngu
                    if (_selectComment.Count() > 0)
569 787a4489 KangIngu
                    {
570 276fdd9b KangIngu
                        if ((rdoAllPages.IsChecked == true)
571
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
572
                        {
573
                            _addFlag = true;
574
                        }
575 787a4489 KangIngu
                    }
576 276fdd9b KangIngu
                    else
577
                    {
578
                        //if (App.ViewInfo.IsCustomPage)
579
                        //{
580
                        //    //_addFlag = false;
581
582
                        //    //App.ViewInfo.IsCustomPage = false;
583
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
584
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
585
                        //    this.rdoAllPages.IsChecked = false;
586
                        //    this.rdoFavoritePages.IsChecked = true;
587
                        //    //SetCommentPages();                        
588
                        //}
589
                        //else
590
                        //{
591 787a4489 KangIngu
                        _addFlag = true;
592 276fdd9b KangIngu
                        //}
593
                    }
594 787a4489 KangIngu
                }
595
596
597 90e7968d ljiyeon
                if (_addFlag)
598 787a4489 KangIngu
                {
599
                    this._thumbnailItems.Add(new ThumbnailItem
600
                    {
601
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
602 cdfb57ff taeseongkim
                        PageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString()).Replace("jpg","png")),
603 787a4489 KangIngu
                        PageNumber = _pageNo,
604
                        Angle = page.PAGE_ANGLE,
605
                    });
606
                }
607
                else
608
                {
609 992a98b4 KangIngu
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
610
                    {
611
                        this._thumbnailItems.Add(new ThumbnailItem
612
                        {
613
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
614
                            PageNumber = _pageNo,
615
                            Angle = page.PAGE_ANGLE,
616
                        });
617
                    }
618 787a4489 KangIngu
                }
619
620
621
622
                //this._thumbnailItems.Add(new ThumbnailItem
623
                //{
624
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
625
626
                //    //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"),
627
628
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
629
                //    //DisplayColorItems = pageColor,
630
                //    PageNumber = Convert.ToInt32(_pageNo),
631
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
632
                //});
633
            });
634
635
            //txtTotPageNo.Text = this._PageList.Count().ToString();
636
637
            //txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString());
638
639
            if (ImgListbox.ItemsSource == null)
640
            {
641
                ImgListbox.ItemsSource = this._thumbnailItems;
642
643
                this._thumbnailItems.ToList().ForEach(data =>
644
                {
645
                    data.Width = ImgListbox.ActualWidth;
646 5984979a ljiyeon
                    data.Height = ImgListbox.ActualHeight;
647 787a4489 KangIngu
                });
648
649
                if (ImgListbox.Items.Count > 0)
650
                {
651
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
652
                    int StartPageIdx = 1;
653
                    //if (App.ViewInfo.IsCustomPage)
654
                    //{
655
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
656
                    //}
657
                    //else
658
                    //{
659
660
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
661
                    {
662
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
663
                    }
664
                    else
665
                    {
666
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
667
                    }
668
                    //}
669
                }
670
            }
671
            else
672
            {
673
                ImgListbox.UpdateLayout();
674
                ImgListbox.ItemsSource = this._thumbnailItems;
675
            }
676
        }
677
678
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
679
        {
680
            if (e.ClickCount >= 2)
681
            {
682 39f0624f ljiyeon
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
683 787a4489 KangIngu
                GotoPage(selectItem.PageNumber);
684 5529d2a2 humkyung
                var result = MarkupParser.GetBaseControl(selectItem.Data);
685 90e7968d ljiyeon
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
686 787a4489 KangIngu
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
687
                //bool isGO = false;
688
689
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
690
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
691
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
692
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
693
                //{
694
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
695
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
696
                //    {
697
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
698
                //    }
699
700
                //};
701
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
702
703 39f0624f ljiyeon
                //GotoPage(MarkupList.SelectedItem as MarkupList)
704 787a4489 KangIngu
            }
705
        }
706
707
        public class MarkupInfoItemSmall
708
        {
709
            public string Id { get; set; }
710
            public string UserName { get; set; }
711
            public string UserID { get; set; }
712
            public int PageNumber { get; set; }
713
            public string Data { get; set; }
714
            public int Data_Type { get; set; }
715 d7e20d2d taeseongkim
            public bool IsConsolidate { get; set; }
716 787a4489 KangIngu
        }
717
718
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
719
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
720
        {
721
            get
722
            {
723
                if (_MarkupInfoSmallList == null)
724
                {
725
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
726
                }
727
                return _MarkupInfoSmallList;
728
            }
729
            set
730
            {
731 90e7968d ljiyeon
732 787a4489 KangIngu
                _MarkupInfoSmallList = value;
733
                RaisePropertyChanged("MarkupInfoSmallList");
734
            }
735
        }
736
737 2aaf9645 humkyung
        /// <summary>
738
        /// goto page and select item selected by user
739
        /// </summary>
740
        /// <param name="sender"></param>
741
        /// <param name="e"></param>
742 2089959a taeseongkim
        private void RadButton_Click_OLD(object sender, RoutedEventArgs e)
743 787a4489 KangIngu
        {
744
            var clickButtonItem = sender as RadButton;
745
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
746
            {
747
                try
748
                {
749
                    Rect rect = new Rect();
750
                    Point s_point = new Point();
751
                    Point e_point = new Point();
752
753
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
754
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
755 2aaf9645 humkyung
756 787a4489 KangIngu
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
757
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
758
                    {
759
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
760
                            {
761
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
762
                                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));
763
                            }
764
                            break;
765
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
766
                            {
767
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
768
                                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));
769
                            }
770
                            break;
771
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
772
                            {
773
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
774
                                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));
775
                            }
776
                            break;
777
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
778
                            {
779
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
780
781
                                foreach (Point A in instance.PointSet)
782
                                {
783
                                    if (s_point == new Point())
784
                                    {
785
                                        s_point = A;
786
                                        e_point = A;
787
                                    }
788
                                    s_point.X = Math.Min(s_point.X, A.X);
789
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
790
                                    e_point.X = Math.Max(e_point.X, A.X);
791
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
792
                                }
793
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
794
                            }
795
                            break;
796
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
797
                            {
798
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
799
800
                                foreach (Point A in instance.PointSet)
801
                                {
802
                                    if (s_point == new Point())
803
                                    {
804
                                        s_point = A;
805
                                        e_point = A;
806
                                    }
807
                                    s_point.X = Math.Min(s_point.X, A.X);
808
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
809
                                    e_point.X = Math.Max(e_point.X, A.X);
810
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
811
                                }
812
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
813
                            }
814
                            break;
815
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
816
                            {
817
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
818
819
                                foreach (Point A in instance.PointSet)
820
                                {
821
                                    if (s_point == new Point())
822
                                    {
823
                                        s_point = A;
824
                                        e_point = A;
825
                                    }
826
                                    s_point.X = Math.Min(s_point.X, A.X);
827
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
828
                                    e_point.X = Math.Max(e_point.X, A.X);
829
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
830
                                }
831
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
832
                            }
833
                            break;
834
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
835
                            {
836
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
837
838
                                foreach (Point A in instance.PointSet)
839
                                {
840
                                    if (s_point == new Point())
841
                                    {
842
                                        s_point = A;
843
                                        e_point = A;
844
                                    }
845
                                    s_point.X = Math.Min(s_point.X, A.X);
846
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
847
                                    e_point.X = Math.Max(e_point.X, A.X);
848
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
849
                                }
850
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
851
                            }
852
                            break;
853
                        default:
854
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
855
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
856
                            break;
857
                    }
858
859 077896be humkyung
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
860 787a4489 KangIngu
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
861
                }
862
                catch (Exception ex)
863
                {
864 2aaf9645 humkyung
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
865 787a4489 KangIngu
                }
866
            }
867
        }
868
869 2089959a taeseongkim
870
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
871
        {
872
            var clickButtonItem = sender as RadButton;
873
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
874
            {
875
                try
876
                {
877
             
878
879
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
880
                    MarkupList.SelectedItem = gaza;
881
882 c7fde400 taeseongkim
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
883 2089959a taeseongkim
                }
884
                catch (Exception ex)
885
                {
886
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
887
                }
888
            }
889
        }
890
891 c7fde400 taeseongkim
        ///// <summary>
892
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
893
        ///// </summary>
894
        ///// <param name="CommentIdList"></param>
895
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
896
        //{
897
        //    var instance = Common.ViewerDataModel.Instance;
898
899
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
900
901
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
902
903
        //    if (commentList.Count() > 0)
904
        //    {
905
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
906
        //        #region markup list grid select items
907
908
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
909
910
        //        if (infoItem.Count() > 0)
911
        //        {
912
913
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
914
        //            gridMarkup.SelectedItems.Clear();
915
        //            gridMarkup.SelectedItems.Add(infoItem.First());
916
        //        }
917
918
        //        #endregion
919
920
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
921
922
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
923
        //        {
924
        //            GotoSelectedMarkup(CommentIdList);
925
        //        }
926
        //        else
927
        //        {
928
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
929
930
        //            handler = (snd, evt) =>
931
        //            {
932
        //                GotoSelectedMarkup(CommentIdList);
933
        //                pageNavigator.PageChanged -= handler;
934
        //            };
935
936
        //            pageNavigator.PageChanged += handler;
937
938
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
939
        //        }
940
        //    }
941
        //}
942
943
        ///// <summary>
944
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
945
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
946
        ///// </summary>
947
        ///// <param name="CommentIdList"></param>
948
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
949
        //{
950
        //    var instance = Common.ViewerDataModel.Instance;
951
952
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
953
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
954
955
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
956
        //    {
957
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
958
        //        commentUserInfo.AddRange(selectOrderComments);
959
960
        //        if (commentUserInfo?.Count() > 0)
961
        //        {
962
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
963
964
        //            try
965
        //            {
966
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
967
        //                {
968
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
969
        //                    {
970
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
971
        //                    } 
972 5beaf28e taeseongkim
                            
973 c7fde400 taeseongkim
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
974
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
975
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
976
        //                }
977 5beaf28e taeseongkim
978 c7fde400 taeseongkim
        //                Rect rect = commentUserInfo.First().ItemRect;
979 2089959a taeseongkim
980 c7fde400 taeseongkim
        //                foreach (var UserInfo in commentUserInfo)
981
        //                {
982
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
983
        //                }
984 2089959a taeseongkim
985 c7fde400 taeseongkim
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
986 2089959a taeseongkim
987 c7fde400 taeseongkim
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
988
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
989
        //                //rect.Transform(matrix);
990 2089959a taeseongkim
991 c7fde400 taeseongkim
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
992
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
993
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
994
        //                double positionX = 0;
995
        //                double positionY = 0;
996 2089959a taeseongkim
997 c7fde400 taeseongkim
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
998
        //                {
999
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1000
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1001
        //                }
1002 2089959a taeseongkim
1003 c7fde400 taeseongkim
        //                main.zoomAndPanControl.ContentScale = newScale;
1004
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1005
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1006 2089959a taeseongkim
1007
              
1008 c7fde400 taeseongkim
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1009
1010
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1011
1012
        //                if (pageAngle == 90)
1013
        //                {
1014
        //                    pageAngle = 270;
1015
        //                }
1016
        //                else
1017
        //                {
1018
        //                    pageAngle = 90;
1019
        //                }
1020
1021
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1022
        //                {
1023
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1024
        //                    rect.Transform(matrix);
1025
1026
        //                    main.zoomAndPanControl.ZoomTo(rect);
1027
        //                }
1028
        //                else
1029
        //                {
1030
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1031
1032
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1033
        //                    rect.Transform(matrix);
1034
1035
1036
        //                    main.zoomAndPanControl.ZoomTo(rect);
1037
        //                }
1038
        //            }
1039
        //            catch (Exception ex)
1040
        //            {
1041
        //                main.DialogMessage_Alert(ex.Message, "Error");
1042
        //            }
1043
        //        }
1044
        //    }
1045
        //}
1046 2089959a taeseongkim
1047 39f0624f ljiyeon
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1048 787a4489 KangIngu
        {
1049
            if (MarkupInfoSmallList.Count == 0)
1050
            {
1051
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1052
                {
1053
                    if (d.MarkupList != null)
1054
                    {
1055
                        d.MarkupList.ForEach(b =>
1056
                        {
1057 d7e20d2d taeseongkim
                            bool isConsolidate = false;
1058
1059
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1060
                            {
1061
                                isConsolidate = true;
1062
                            }
1063
1064
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1065
1066 787a4489 KangIngu
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1067
                            {
1068
                                Id = b.ID,
1069
                                Data = b.Data,
1070
                                Data_Type = b.Data_Type,
1071
                                PageNumber = b.PageNumber,
1072
                                UserID = d.UserID,
1073
                                UserName = d.UserName,
1074 d7e20d2d taeseongkim
                                IsConsolidate = isConsolidate
1075
1076 787a4489 KangIngu
                            });
1077
                        });
1078
                    }
1079
                });
1080 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1081
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1082 787a4489 KangIngu
1083 dea506e2 taeseongkim
                FilterUpdate();
1084 787a4489 KangIngu
            }
1085
        }
1086
1087 39f0624f ljiyeon
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1088 4eb052e4 ljiyeon
        {
1089
            if (MarkupInfoSmallList.Count == 0)
1090
            {
1091
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1092
                {
1093
                    if (d.MarkupList != null)
1094
                    {
1095
                        d.MarkupList.ForEach(b =>
1096
                        {
1097
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1098
                            {
1099
                                Id = b.ID,
1100
                                Data = b.Data,
1101
                                Data_Type = b.Data_Type,
1102
                                PageNumber = b.PageNumber,
1103
                                UserID = d.UserID,
1104
                                UserName = d.UserName,
1105
                            });
1106
                        });
1107
                    }
1108
                });
1109 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1110
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1111 4eb052e4 ljiyeon
            }
1112
1113
            switch (eventType)
1114
            {
1115
                case Event_Type.Create:
1116
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1117
                    {
1118
                        Id = res.CommentID,
1119
                        Data = res.ConvertData,
1120
                        Data_Type = res.DATA_TYPE,
1121
                        PageNumber = CurrentPage.PageNumber,
1122
                        UserID = App.ViewInfo.UserID,
1123
                        UserName = App.UserName,
1124
                    });
1125
                    break;
1126
                case Event_Type.Delete:
1127
                    if(CommentID == null) //user information list delete btn
1128
                    {
1129
                        foreach (var delItem in item.MarkupList)
1130
                        {
1131
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1132
                        }
1133
                    }
1134
                    else //delete, cut, 
1135
                    {
1136
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1137
                    }                    
1138
                    break;
1139 39f0624f ljiyeon
                case Event_Type.Thumb://이동 회전
1140 4eb052e4 ljiyeon
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1141
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1142
                    {
1143
                        Id = res.CommentID,
1144
                        Data = res.ConvertData,
1145
                        Data_Type = res.DATA_TYPE,
1146
                        PageNumber = CurrentPage.PageNumber,
1147
                        UserID = App.ViewInfo.UserID,
1148
                        UserName = App.UserName,
1149
                    });
1150
                    break;
1151
                default:
1152
                    break;
1153
            }
1154
1155 39f0624f ljiyeon
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1156 4eb052e4 ljiyeon
1157 d7e20d2d taeseongkim
            bool IsConsolidation = false;
1158
            string UserId = null;
1159
1160
            if (commentUser.SelectedValue != null)
1161
            {
1162
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1163
                {
1164
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1165
                }
1166
                else
1167
                {
1168
                    IsConsolidation = true;
1169
                }
1170
            }
1171 4eb052e4 ljiyeon
1172 d7e20d2d taeseongkim
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1173
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1174
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1175 39f0624f ljiyeon
1176 dea506e2 taeseongkim
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1177
1178
            FilterUpdate();
1179 4eb052e4 ljiyeon
        }
1180
1181 dea506e2 taeseongkim
        private void FilterUpdate(string selectUser = null)
1182
        {
1183
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1184
1185
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1186
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1187
1188
1189
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1190
 
1191
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1192
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1193
1194
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1195
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1196
1197
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1198
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1199
1200
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1201
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1202
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1203
        }
1204
1205
        
1206
1207 d7e20d2d taeseongkim
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1208 787a4489 KangIngu
        {
1209 39f0624f ljiyeon
            MarkupList.ItemsSource = null;
1210 2089959a taeseongkim
            txtSearch.Text = string.Empty;
1211 4eb052e4 ljiyeon
1212 39f0624f ljiyeon
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1213 4eb052e4 ljiyeon
1214 d7e20d2d taeseongkim
            bool IsConsolidation = false;
1215 dea506e2 taeseongkim
            string userName = null;
1216 d7e20d2d taeseongkim
1217
            if (commentUser.SelectedValue != null)
1218
            {
1219 dea506e2 taeseongkim
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1220 d7e20d2d taeseongkim
                {
1221 dea506e2 taeseongkim
                    userName = commentUser.SelectedValue.ToString();
1222 d7e20d2d taeseongkim
                }
1223
                else
1224
                {
1225
                    IsConsolidation = true;
1226
                }
1227
            }
1228 4eb052e4 ljiyeon
1229 d7e20d2d taeseongkim
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1230 dea506e2 taeseongkim
                                   .WhereIf(userName != null, d => d.UserName == userName)
1231 d7e20d2d taeseongkim
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1232
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1233 4eb052e4 ljiyeon
1234 d7e20d2d taeseongkim
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1235 dea506e2 taeseongkim
1236
            FilterUpdate();
1237 787a4489 KangIngu
        }
1238
1239
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1240
        {
1241
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1242
        }
1243 79f3f21a djkim
1244
        private void btnSearch_Click(object sender, RoutedEventArgs e)
1245
        {
1246 2089959a taeseongkim
            string search_str = txtSearch.Text;
1247
1248
            if(string.IsNullOrWhiteSpace(search_str))
1249
            {
1250
                return;
1251
            }
1252
1253 79f3f21a djkim
            var sel_type = commentType.SelectedItem;
1254
            var sel_user = commentUser.SelectedItem;
1255
            var sel_page = commentPage.SelectedItem;
1256
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1257
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1258 90e7968d ljiyeon
            if (sel_page != null)
1259 79f3f21a djkim
            {
1260
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1261
            }
1262 90e7968d ljiyeon
            if (sel_type != null)
1263 79f3f21a djkim
            {
1264
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1265
            }
1266
            if (sel_user != null)
1267
            {
1268
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1269
            }
1270
            foreach (var item in list)
1271
            {
1272
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
1273 90e7968d ljiyeon
1274 79f3f21a djkim
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1275 90e7968d ljiyeon
                {
1276 79f3f21a djkim
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1277
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1278
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1279
                        {
1280
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1281 2089959a taeseongkim
1282
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1283 90e7968d ljiyeon
                            {
1284 2089959a taeseongkim
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1285
                                {
1286
                                    small_list.Add(item);
1287
                                }
1288 79f3f21a djkim
                            }
1289
                        }
1290
                        break;
1291
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1292
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1293
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1294
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1295
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1296
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1297
                        {
1298
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1299 2089959a taeseongkim
1300
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1301 79f3f21a djkim
                            {
1302 2089959a taeseongkim
                                if (instance.ArrowText.Contains(search_str))
1303
                                {
1304
                                    small_list.Add(item);
1305
                                }
1306 79f3f21a djkim
                            }
1307
                        }
1308
                        break;
1309
                }
1310
            }
1311 90e7968d ljiyeon
1312 39f0624f ljiyeon
            MarkupList.ItemsSource = null;
1313
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1314 2089959a taeseongkim
        }
1315
1316
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1317
        {
1318
            if(e.Key == Key.Enter || e.Key == Key.Return)
1319
            {
1320
                btnSearch_Click(sender, new RoutedEventArgs());
1321
            }
1322 79f3f21a djkim
        }
1323 787a4489 KangIngu
    }
1324
}