프로젝트

일반

사용자정보

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

markus / KCOM / Common / SelectionSet.cs @ ecf8a079

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

1 959b3ef2 humkyung
using KCOM.Common;
2
using KCOM.Controls;
3
using KCOM.Views;
4
using MarkupToPDF.Common;
5
using MarkupToPDF.Controls.Parsing;
6 077896be humkyung
using MarkupToPDF.Controls.Polygon;
7 959b3ef2 humkyung
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 d62c0439 humkyung
namespace KCOM.Common
29 959b3ef2 humkyung
{
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 91efe37a humkyung
52 d62c0439 humkyung
        public List<CommentUserInfo> SelectedItems
53
        {
54
            get
55
            {
56
                List<CommentUserInfo> res = new List<CommentUserInfo>();
57
                foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children)
58
                {
59
                    if (item.GetType().Name == "AdornerFinal")
60
                    {
61 4913851c humkyung
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
62 d62c0439 humkyung
                        {
63
                            res.Add(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo);
64
                        }
65
                    }
66
                }
67
68
                return res;
69
            }
70
        }
71
72 91efe37a humkyung
        /// <summary>
73 b37ef4b3 humkyung
        /// select all controls
74
        ///  - unselect selected items
75
        ///  - adornerset을 생성하고 SelectLayer에 추가한다
76
        /// </summary>
77
        public void SelectAll()
78
        {
79
            /// 선택된 어도너가 있을 시 취소하고 전체 선택
80
            this.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
81
82
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
83
            var controls = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.GetType().Name != ""
84
            && data.Visibility != Visibility.Hidden).ToList();
85
86
            foreach (var item in controls) adornerSet.Add(item);
87
88
            if (adornerSet.Count > 0)
89
            {
90
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
91
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
92
            }
93
        }
94
95
        /// <summary>
96 077896be humkyung
        /// select item which's bouding rectangle is inside of given rect
97
        /// </summary>
98
        /// <author>humkyung</author>
99
        /// <date>2018.06.14</date>
100
        /// <param name="rect"></param>
101
        public void SelectItemByRect(Rect rect, MainMenu mainMenu)
102
        {
103
            var selected =
104
                from comment in ViewerDataModel.Instance.MarkupControls_USER
105
                where comment.Visibility != Visibility.Hidden && rect.Contains(comment.ItemRect)
106
                select comment;
107 85132173 humkyung
            if (selected.Any())
108 4eb052e4 ljiyeon
             {
109 077896be humkyung
                this.UnSelect(mainMenu);  /// unselect alreay selected items
110
111
                foreach(var comment in selected) mainMenu.Control_Style(comment);
112
113
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
114
                adornerSet.AddRange(selected);
115
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
116
                mainMenu.SelectLayer.Children.Add(final);
117
            }
118
        }
119
120
        /// <summary>
121
        /// unselect selected items
122
        /// </summary>
123
        /// <param name="mainMenu"></param>
124
        public void UnSelect(MainMenu mainMenu)
125
        {
126
            try
127
            {
128
                if (mainMenu.SelectLayer.Children.Count > 0)
129
                {
130
                    foreach (var item in mainMenu.SelectLayer.Children)
131
                    {
132 e2d3d2dc 이지연
                        if (item.GetType().Name == "AdornerFinal") 
133 077896be humkyung
                        {
134
                            (item as AdornerFinal).unRegister();
135
136 4913851c humkyung
                            foreach (var InnerItem in (item as AdornerFinal).Members.Cast<AdornerMember>())
137 077896be humkyung
                            {
138
                                if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
139
                                {
140
                                    if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
141
                                    {
142
                                        if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
143
                                        {
144
                                            (InnerItem.DrawingData as PolygonControl).CommentID = Commons.shortGuid();
145
                                        }
146
                                    }
147
148 26ec6226 taeseongkim
                                    var control = InnerItem.DrawingData as CommentUserInfo;
149
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(control);
150 fd452a01 swate0609
151 34ac8db7 humkyung
                                    #region Unselect하는데 Create 커맨드를 추가해야 하는지 이해되지 않음
152
                                    /*
153 f5407d37 swate0609
                                    var vUndoBeforeTargetItem =
154
                                        ViewerDataModel.Instance.UndoDataList.ToList().OrderBy(x => x.EventTime).LastOrDefault();
155 fd452a01 swate0609
156 873011c4 humkyung
                                    if (vUndoBeforeTargetItem != null && vUndoBeforeTargetItem.Event == EventType.Operation)
157 26ec6226 taeseongkim
                                    {
158 fd452a01 swate0609
159
                                    }
160
                                    else
161
                                    {
162 34ac8db7 humkyung
                                        MarkupToPDF.Common.UndoDataGroup UndoDataGroup = new UndoDataGroup()
163 fd452a01 swate0609
                                        {
164
                                            IsUndo = false,
165 873011c4 humkyung
                                            Event = EventType.Create,
166 fd452a01 swate0609
                                            EventTime = DateTime.Now,
167 b79d6e7f humkyung
                                            MarkupDataColl = new List<UndoData>()
168 fd452a01 swate0609
                                        };
169
170 34ac8db7 humkyung
                                        var _UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(control);
171
                                        UndoDataGroup.MarkupDataColl.Add(_UndoData);
172
                                        ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
173 fd452a01 swate0609
                                    }
174 26ec6226 taeseongkim
                                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
175 34ac8db7 humkyung
                                    */
176
                                    #endregion
177 077896be humkyung
                                }
178
                            }
179
                        }
180
                    }
181
                    mainMenu.SelectLayer.Children.Clear();
182
                }
183
            }
184
            catch (Exception ex)
185
            {
186 664ea2e1 taeseongkim
                //Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0);
187 077896be humkyung
            }
188
        }
189
190
        /// <summary>
191 91efe37a humkyung
        /// Control Select
192
        /// </summary>
193
        /// <author>humkyung</author>
194
        /// <date>2019.06.13</date>
195
        /// <param name="Control"></param>
196
        /// <param name="dragrect"></param>
197
        /// <returns></returns>
198
        public Boolean SelectControl(CommentUserInfo control, Rect dragrect)
199
        {
200
            return dragrect.Contains(control.ItemRect);
201
        }
202 959b3ef2 humkyung
    }
203
}
클립보드 이미지 추가 (최대 크기: 500 MB)