프로젝트

일반

사용자정보

개정판 077896be

ID077896be9351b86d4a3acb30e98dc01432c9bd17
상위 91efe37a
하위 f056e2f7

백흠경이(가) 5년 이상 전에 추가함

issue #534: Add UnSelect and SelectItemByRect method to SelectionSet

Change-Id: If006b652c6e29b07dab7db68213424a0ac2721dd

차이점 보기:

KCOM/Common/SelectionSet.cs
3 3
using KCOM.Views;
4 4
using MarkupToPDF.Common;
5 5
using MarkupToPDF.Controls.Parsing;
6
using MarkupToPDF.Controls.Polygon;
6 7
using Newtonsoft.Json;
7 8
using Newtonsoft.Json.Converters;
8 9
using Newtonsoft.Json.Linq;
......
49 50
        }
50 51

  
51 52
        /// <summary>
53
        /// select item which's bouding rectangle is inside of given rect
54
        /// </summary>
55
        /// <author>humkyung</author>
56
        /// <date>2018.06.14</date>
57
        /// <param name="rect"></param>
58
        public void SelectItemByRect(Rect rect, MainMenu mainMenu)
59
        {
60
            var selected =
61
                from comment in ViewerDataModel.Instance.MarkupControls_USER
62
                where comment.Visibility != Visibility.Hidden && rect.Contains(comment.ItemRect)
63
                select comment;
64
            if (selected.Count() > 0)
65
            {
66
                this.UnSelect(mainMenu);  /// unselect alreay selected items
67

  
68
                foreach(var comment in selected) mainMenu.Control_Style(comment);
69

  
70
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
71
                adornerSet.AddRange(selected);
72
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
73
                mainMenu.SelectLayer.Children.Add(final);
74
            }
75
        }
76

  
77
        /// <summary>
78
        /// unselect selected items
79
        /// </summary>
80
        /// <param name="mainMenu"></param>
81
        public void UnSelect(MainMenu mainMenu)
82
        {
83
            try
84
            {
85
                Logger.sendCheckLog("pageNavigator_PageChanging_ReleaseAdorner", 1);
86
                if (mainMenu.SelectLayer.Children.Count > 0)
87
                {
88
                    foreach (var item in mainMenu.SelectLayer.Children)
89
                    {
90
                        if (item.GetType().Name == "AdornerFinal")
91
                        {
92
                            (item as AdornerFinal).unRegister();
93

  
94
                            foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
95
                            {
96
                                if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
97
                                {
98
                                    if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
99
                                    {
100
                                        if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
101
                                        {
102
                                            (InnerItem.DrawingData as PolygonControl).CommentID = Commons.shortGuid();
103
                                        }
104
                                    }
105

  
106
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
107
                                }
108
                            }
109
                        }
110
                    }
111
                    mainMenu.SelectLayer.Children.Clear();
112
                }
113
            }
114
            catch (Exception ex)
115
            {
116
                Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0);
117
            }
118
        }
119

  
120
        /// <summary>
52 121
        /// Control Select
53 122
        /// </summary>
54 123
        /// <author>humkyung</author>
KCOM/Controls/CheckList.xaml.cs
887 887
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
888 888
            {
889 889
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
890
                menu.ReleaseAdorner();
890
                SelectionSet.Instance.UnSelect(menu);
891 891
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
892 892
                {
893 893
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
KCOM/Controls/Sample.xaml.cs
899 899
                            break;
900 900
                    }
901 901

  
902
                    this.ParentOfType<KCOM.Views.MainMenu>().SelecteItemByRect(rect);
902
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
903 903
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
904 904
                }
905 905
                catch (Exception ex)
KCOM/Controls/Symbol.xaml.cs
868 868
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
869 869
            {
870 870
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
871
                menu.ReleaseAdorner();
871
                SelectionSet.Instance.UnSelect(menu);
872 872
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
873 873
                {
874 874
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
KCOM/Events/Event_KeyEvent.cs
129 129
                                {
130 130
                                    tog.IsChecked = false;
131 131
                                }
132
                                
132

  
133 133
                                //선택된 어도너가 있을 시 취소하고 전체 선택
134
                                this.dzMainMenu.ReleaseAdorner();
134
                                SelectionSet.Instance.UnSelect(this.dzMainMenu);
135 135

  
136 136
                                UndoData = new Undo_data()
137 137
                                {
......
276 276
                                string[] delimiterChars2 = { "|OR|", "|SymbolID|" };
277 277
                                string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
278 278

  
279
                                this.dzMainMenu.ReleaseAdorner();
279
                                SelectionSet.Instance.UnSelect(this.dzMainMenu);
280 280

  
281 281
                                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
282 282

  
......
651 651
                            }
652 652
                        }
653 653

  
654
                        this.dzMainMenu.ReleaseAdorner();
654
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
655 655

  
656 656
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
657 657
                        if (this.dzMainMenu.currentControl != null)
KCOM/Events/Implementation/TopMenuEvent.cs
328 328
        {
329 329
            try
330 330
            {
331
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
331
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
332 332

  
333 333
                this.ParentOfType<MainWindow>().dzMainMenu.InkControl_Convert();
334 334

  
......
508 508
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
509 509
            {
510 510
                var menu = this.ParentOfType<MainWindow>().dzMainMenu;
511
                menu.ReleaseAdorner();
511
                SelectionSet.Instance.UnSelect(menu);
512 512
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
513 513
                {
514 514
                    RefactoryCommentReact(menu);
......
2765 2765
                string[] delimiterChars = { "|OR|" };
2766 2766
                string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
2767 2767

  
2768
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
2768
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
2769 2769

  
2770 2770
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2771 2771

  
KCOM/MainWindow.xaml.cs
520 520
                    string[] delimiterChars2 = { "|OR|", "|SymbolID|" };
521 521
                    string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
522 522

  
523
                    this.dzMainMenu.ReleaseAdorner();
523
                    SelectionSet.Instance.UnSelect(this.dzMainMenu);
524 524

  
525 525
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
526 526

  
KCOM/Views/MainMenu.xaml.cs
364 364
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
365 365
        {
366 366
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
367
            this.ReleaseAdorner();
367
            SelectionSet.Instance.UnSelect(this);
368 368

  
369 369
            Button content = (sender as Button);
370 370
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
......
420 420

  
421 421
            ////GC.Collect();
422 422
        }
423

  
424
        public void ReleaseAdorner()
425
        {
426
            try
427
            {
428
                Logger.sendCheckLog("pageNavigator_PageChanging_ReleaseAdorner", 1);
429
                if (SelectLayer.Children.Count > 0)
430
                {
431
                    foreach (var item in SelectLayer.Children)
432
                    {
433
                        if (item.GetType().Name == "AdornerFinal")
434
                        {
435
                            (item as AdornerFinal).unRegister();
436

  
437
                            foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
438
                            {
439
                                if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
440
                                {
441
                                    if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
442
                                    {
443
                                        if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
444
                                        {
445
                                            (InnerItem.DrawingData as PolygonControl).CommentID = Commons.shortGuid();
446
                                        }
447
                                    }
448

  
449
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
450
                                }
451
                            }
452
                        }
453
                    }
454
                    SelectLayer.Children.Clear();
455
                }
456
            }
457
            catch (Exception ex)
458
            {
459
                Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0);
460
            }            
461
        }
462

  
423
        
463 424
        public List<CommentUserInfo> AddAdorner()
464 425
        {
465 426
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
......
572 533

  
573 534
            InkControl_Convert();
574 535

  
575
            ReleaseAdorner();
536
            SelectionSet.Instance.UnSelect(this);
576 537
            ChangeCommentReact();
577 538

  
578 539
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
......
2907 2868

  
2908 2869
        }
2909 2870

  
2910
        /// <summary>
2911
        /// select item which's bouding rectangle is equal to given rectangle
2912
        /// </summary>
2913
        /// <author>humkyung</author>
2914
        /// <date>2018.06.14</date>
2915
        /// <param name="rect"></param>
2916
        public void SelecteItemByRect(Rect rect)
2917
        {
2918
            multi_Undo_Data = new Multi_Undo_data();
2919

  
2920
            UndoData = new Undo_data()
2921
            {
2922
                IsUndo = false,
2923
                Event = Event_Type.Select,
2924
                EventTime = DateTime.Now,
2925
                Markup_List = new List<Multi_Undo_data>()
2926
            };
2927
           
2928
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2929

  
2930
            CommentUserInfo selected = null;
2931
            double dMinDiff = double.MaxValue;
2932
            foreach (var item in Items)
2933
            {
2934
                Rect boundingBox = item.ItemRect;
2935
                double dx = rect.X - boundingBox.X;
2936
                double dy = rect.Y - boundingBox.Y;
2937
                double dxx = rect.Right - boundingBox.Right;
2938
                double dyy = rect.Bottom - boundingBox.Bottom;
2939
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2940
                if (dDiff < dMinDiff)
2941
                {
2942
                    dMinDiff = dDiff;
2943
                    selected = item;
2944
                }
2945
            }
2946

  
2947
            if (selected != null)
2948
            {
2949
                this.ReleaseAdorner();
2950

  
2951
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2952
                adornerSet.Add(selected);
2953
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2954

  
2955
                Control_Style(selected);
2956
                UndoData.Markup_List.Add(multi_Undo_Data);
2957
                multi_Undo_Data = new Multi_Undo_data();
2958

  
2959
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2960
                {
2961
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2962
                });
2963
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2964

  
2965
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2966
                SelectLayer.Children.Add(final);
2967
            }
2968
        }
2969

  
2970 2871
        private void ApplyDragSelectionRect()
2971 2872
        {
2972 2873
            multi_Undo_Data = new Multi_Undo_data();
......
3372 3273

  
3373 3274
                if (!ViewerDataModel.Instance.IsPressCtrl)
3374 3275
                {
3375
                    ReleaseAdorner();
3276
                    SelectionSet.Instance.UnSelect(this);
3376 3277
                }
3377 3278
            }
3378 3279
            if (mouseButtonDown == MouseButton.Middle)
......
3458 3359

  
3459 3360
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3460 3361
                    {
3461
                        ReleaseAdorner();
3362
                        SelectionSet.Instance.UnSelect(this);
3462 3363
                        final = new AdornerFinal(control);
3463 3364
                        //단일 컨트롤 언두 저장
3464 3365

  
......
5204 5105

  
5205 5106
                    if (!mouseOff)
5206 5107
                    {
5207
                        ReleaseAdorner();
5108
                        SelectionSet.Instance.UnSelect(this);
5208 5109
                    }
5209 5110
                }
5210 5111
                zoomAndPanControl.CaptureMouse();
......
6529 6430
            //   }
6530 6431
            Undo_data undo = new Undo_data();
6531 6432
            AdornerFinal final;
6532
            ReleaseAdorner();
6433
            SelectionSet.Instance.UnSelect(this);
6533 6434

  
6534 6435
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6535 6436
            if (undo == null)
......
6583 6484
                        }
6584 6485
                        final = new AdornerFinal(comment);
6585 6486
                        SelectLayer.Children.Add(final);
6586
                        ReleaseAdorner();
6487
                        SelectionSet.Instance.UnSelect(this);
6587 6488
                    }
6588 6489
                    break;
6589 6490
                case (Event_Type.Select):
6590 6491
                    {
6591
                        ReleaseAdorner();
6492
                        SelectionSet.Instance.UnSelect(this);
6592 6493
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6593 6494

  
6594 6495
                        foreach (var item in undo.Markup_List)
......
6671 6572
            AdornerFinal final;
6672 6573
            Undo_data redo = new Undo_data();
6673 6574
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6674
            ReleaseAdorner();
6575
            SelectionSet.Instance.UnSelect(this);
6675 6576
            if (redo == null)
6676 6577
                return;
6677 6578

  
......
6722 6623
                        }
6723 6624
                        final = new AdornerFinal(comment);
6724 6625
                        SelectLayer.Children.Add(final);
6725
                        ReleaseAdorner();
6626
                        SelectionSet.Instance.UnSelect(this);
6726 6627
                    }
6727 6628
                    break;
6728 6629
                case (Event_Type.Select):
......
7020 6921
                    string[] delimiterChars = { "|DZ|" };
7021 6922
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
7022 6923

  
7023
                    this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6924
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
7024 6925

  
7025 6926
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
7026 6927

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)