markus / KCOM / Common / SelectionSet.cs @ d62c0439
이력 | 보기 | 이력해설 | 다운로드 (5.23 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.Common |
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 |
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 |
foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>()) |
62 |
{ |
63 |
res.Add(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo); |
64 |
} |
65 |
} |
66 |
} |
67 |
|
68 |
return res; |
69 |
} |
70 |
} |
71 |
|
72 |
/// <summary> |
73 |
/// select item which's bouding rectangle is inside of given rect |
74 |
/// </summary> |
75 |
/// <author>humkyung</author> |
76 |
/// <date>2018.06.14</date> |
77 |
/// <param name="rect"></param> |
78 |
public void SelectItemByRect(Rect rect, MainMenu mainMenu) |
79 |
{ |
80 |
var selected = |
81 |
from comment in ViewerDataModel.Instance.MarkupControls_USER |
82 |
where comment.Visibility != Visibility.Hidden && rect.Contains(comment.ItemRect) |
83 |
select comment; |
84 |
if (selected.Count() > 0) |
85 |
{ |
86 |
this.UnSelect(mainMenu); /// unselect alreay selected items |
87 |
|
88 |
foreach(var comment in selected) mainMenu.Control_Style(comment); |
89 |
|
90 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
91 |
adornerSet.AddRange(selected); |
92 |
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
93 |
mainMenu.SelectLayer.Children.Add(final); |
94 |
} |
95 |
} |
96 |
|
97 |
/// <summary> |
98 |
/// unselect selected items |
99 |
/// </summary> |
100 |
/// <param name="mainMenu"></param> |
101 |
public void UnSelect(MainMenu mainMenu) |
102 |
{ |
103 |
try |
104 |
{ |
105 |
Logger.sendCheckLog("pageNavigator_PageChanging_ReleaseAdorner", 1); |
106 |
if (mainMenu.SelectLayer.Children.Count > 0) |
107 |
{ |
108 |
foreach (var item in mainMenu.SelectLayer.Children) |
109 |
{ |
110 |
if (item.GetType().Name == "AdornerFinal") |
111 |
{ |
112 |
(item as AdornerFinal).unRegister(); |
113 |
|
114 |
foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>()) |
115 |
{ |
116 |
if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData)) |
117 |
{ |
118 |
if (InnerItem.DrawingData.GetType().Name == "PolygonControl") |
119 |
{ |
120 |
if ((InnerItem.DrawingData as PolygonControl).CommentID == null) |
121 |
{ |
122 |
(InnerItem.DrawingData as PolygonControl).CommentID = Commons.shortGuid(); |
123 |
} |
124 |
} |
125 |
|
126 |
ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo); |
127 |
} |
128 |
} |
129 |
} |
130 |
} |
131 |
mainMenu.SelectLayer.Children.Clear(); |
132 |
} |
133 |
} |
134 |
catch (Exception ex) |
135 |
{ |
136 |
Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0); |
137 |
} |
138 |
} |
139 |
|
140 |
/// <summary> |
141 |
/// Control Select |
142 |
/// </summary> |
143 |
/// <author>humkyung</author> |
144 |
/// <date>2019.06.13</date> |
145 |
/// <param name="Control"></param> |
146 |
/// <param name="dragrect"></param> |
147 |
/// <returns></returns> |
148 |
public Boolean SelectControl(CommentUserInfo control, Rect dragrect) |
149 |
{ |
150 |
return dragrect.Contains(control.ItemRect); |
151 |
} |
152 |
} |
153 |
} |