프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 6c687be8

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