프로젝트

일반

사용자정보

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

markus / KCOM / Common / SelectionSet.cs @ 077896be

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

1
using KCOM.Common;
2
using KCOM.Controls;
3
using KCOM.Views;
4
using MarkupToPDF.Common;
5
using MarkupToPDF.Controls.Parsing;
6
using MarkupToPDF.Controls.Polygon;
7
using Newtonsoft.Json;
8
using Newtonsoft.Json.Converters;
9
using Newtonsoft.Json.Linq;
10
using Newtonsoft.Json.Serialization;
11
using System;
12
using System.Collections;
13
using System.Collections.Generic;
14
using System.ComponentModel;
15
using System.Data;
16
using System.IO;
17
using System.Linq;
18
using System.Reflection;
19
using System.Runtime.Serialization.Formatters;
20
using System.Runtime.Serialization.Formatters.Binary;
21
using System.Runtime.Serialization.Json;
22
using System.Text;
23
using System.Windows;
24
using System.Windows.Media;
25
using System.Xml;
26
using System.Xml.Serialization;
27

    
28
namespace KCOM
29
{
30
    public class SelectionSet
31
    {
32
        private static readonly SelectionSet _instance = new SelectionSet();
33

    
34
        // Explicit static constructor to tell C# compiler
35
        // not to mark type as beforefieldinit
36
        static SelectionSet()
37
        {
38
        }
39

    
40
        private SelectionSet()
41
        {
42
        }
43

    
44
        public static SelectionSet Instance
45
        {
46
            get
47
            {
48
                return _instance;
49
            }
50
        }
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>
121
        /// Control Select
122
        /// </summary>
123
        /// <author>humkyung</author>
124
        /// <date>2019.06.13</date>
125
        /// <param name="Control"></param>
126
        /// <param name="dragrect"></param>
127
        /// <returns></returns>
128
        public Boolean SelectControl(CommentUserInfo control, Rect dragrect)
129
        {
130
            return dragrect.Contains(control.ItemRect);
131
        }
132
    }
133
}
클립보드 이미지 추가 (최대 크기: 500 MB)