프로젝트

일반

사용자정보

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

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

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