markus / KCOM / Extensions / MarkupVisitHelper.cs @ 1edefbdf
이력 | 보기 | 이력해설 | 다운로드 (8.68 KB)
1 |
using KCOM.Common; |
---|---|
2 |
using KCOM.Controls; |
3 |
using System; |
4 |
using System.Collections.Generic; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
using System.Windows; |
9 |
|
10 |
namespace KCOM |
11 |
{ |
12 |
/// <summary> |
13 |
/// Markup 이동 |
14 |
/// </summary> |
15 |
public static class MarkupHelper |
16 |
{ |
17 |
/// <summary> |
18 |
/// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출 |
19 |
/// </summary> |
20 |
/// <param name="CommentIdList"></param> |
21 |
public static void GotoMarkup(IEnumerable<string> CommentIdList) |
22 |
{ |
23 |
var instance = Common.ViewerDataModel.Instance; |
24 |
|
25 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
26 |
|
27 |
List<IKCOM.MarkupItem> commentList = new List<IKCOM.MarkupItem>(); |
28 |
|
29 |
foreach (var markupInfo in instance._markupInfoList) |
30 |
{ |
31 |
var comments = markupInfo.MarkupList.Where(f => f.ID == CommentIdList.First()); |
32 |
|
33 |
if (comments.Count() > 0) |
34 |
{ |
35 |
instance.SystemMain.dzMainMenu.gridViewMarkup.SelectedItem = markupInfo; |
36 |
commentList.AddRange(comments); |
37 |
} |
38 |
} |
39 |
|
40 |
if (commentList.Count() > 0) |
41 |
{ |
42 |
|
43 |
var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator; |
44 |
|
45 |
/// 페이지가 틀린 경우 먼저 페이지를 변경한다. |
46 |
if (pageNavigator.CurrentPage.PageNumber != commentList.First().PageNumber) |
47 |
{ |
48 |
EventHandler<EventArgs> handler = null; |
49 |
|
50 |
/// 페이지 변경 후 다시 호출 |
51 |
handler = (snd, evt) => |
52 |
{ |
53 |
ViewerDataModel.Instance.PageLoaded -= handler; |
54 |
|
55 |
Task.Delay(100).ConfigureAwait(true); |
56 |
|
57 |
GotoMarkup(CommentIdList); |
58 |
}; |
59 |
|
60 |
ViewerDataModel.Instance.PageLoaded += handler; |
61 |
|
62 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(commentList.First().PageNumber); |
63 |
} |
64 |
else |
65 |
{ |
66 |
//하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다. |
67 |
#region markup list grid select items |
68 |
/// 이전에 선택하도록 수정함 |
69 |
//var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0); |
70 |
|
71 |
//if (infoItem.Count() > 0) |
72 |
//{ |
73 |
|
74 |
// var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup; |
75 |
// gridMarkup.SelectedItems.Clear(); |
76 |
// gridMarkup.SelectedItems.Add(infoItem.First()); |
77 |
//} |
78 |
|
79 |
#endregion |
80 |
|
81 |
GotoSelectedMarkup(CommentIdList); |
82 |
|
83 |
} |
84 |
} |
85 |
} |
86 |
|
87 |
public static MarkupToPDF.Common.CommentUserInfo VisualCommentUserInfoFind(string id) |
88 |
{ |
89 |
MarkupToPDF.Common.CommentUserInfo result = null; |
90 |
|
91 |
var instance = Common.ViewerDataModel.Instance; |
92 |
|
93 |
var selectOrderComments = instance.MarkupControls.Where(x => id == x.CommentID).ToList(); |
94 |
|
95 |
if(selectOrderComments.Count() > 0) |
96 |
{ |
97 |
result= selectOrderComments.First(); |
98 |
} |
99 |
|
100 |
var commentUserInfo = instance.MarkupControls_USER.Where(x => id == x.CommentID).ToList(); |
101 |
|
102 |
if (commentUserInfo.Count() > 0) |
103 |
{ |
104 |
result = commentUserInfo.First(); |
105 |
} |
106 |
|
107 |
return result; |
108 |
} |
109 |
|
110 |
private static void GotoSelectedMarkup(IEnumerable<string> CommentIdList) |
111 |
{ |
112 |
var instance = Common.ViewerDataModel.Instance; |
113 |
|
114 |
var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList(); |
115 |
var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList(); |
116 |
|
117 |
if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0) |
118 |
{ |
119 |
commentUserInfo.ForEach(x => x.IsSelected = true); |
120 |
commentUserInfo.AddRange(selectOrderComments); |
121 |
|
122 |
if (commentUserInfo?.Count() > 0) |
123 |
{ |
124 |
var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
125 |
|
126 |
try |
127 |
{ |
128 |
if (Common.ViewerDataModel.Instance.MarkupAngle != 0) |
129 |
{ |
130 |
for (int i = 0; i < (Common.ViewerDataModel.Instance.MarkupAngle / 90); i++) |
131 |
{ |
132 |
Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true); |
133 |
} |
134 |
|
135 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0; |
136 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0; |
137 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0; |
138 |
} |
139 |
|
140 |
Rect rect = commentUserInfo.First().ItemRect; |
141 |
|
142 |
foreach (var UserInfo in commentUserInfo) |
143 |
{ |
144 |
rect = Rect.Union(rect, UserInfo.ItemRect); |
145 |
UserInfo.OnMouseHover(); |
146 |
} |
147 |
|
148 |
SelectionSet.Instance.SelectItemByRect(rect, main); |
149 |
|
150 |
var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2); |
151 |
//var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle); |
152 |
//rect.Transform(matrix); |
153 |
|
154 |
double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width; |
155 |
double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height; |
156 |
double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY); |
157 |
double positionX = 0; |
158 |
double positionY = 0; |
159 |
|
160 |
if (Common.ViewerDataModel.Instance.MarkupAngle == 90) |
161 |
{ |
162 |
positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X; |
163 |
positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y; |
164 |
} |
165 |
//else if (Common.ViewerDataModel.Instance.Angle == 270) |
166 |
//{ |
167 |
// positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X *4; |
168 |
// positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y * 4; |
169 |
//} |
170 |
|
171 |
main.zoomAndPanControl.ContentScale = newScale; |
172 |
main.zoomAndPanControl.ContentOffsetX = positionX; |
173 |
main.zoomAndPanControl.ContentOffsetY = positionY; |
174 |
|
175 |
|
176 |
var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height); |
177 |
|
178 |
double pageAngle = Common.ViewerDataModel.Instance.MarkupAngle; |
179 |
|
180 |
if (pageAngle == 90) |
181 |
{ |
182 |
pageAngle = 270; |
183 |
} |
184 |
else |
185 |
{ |
186 |
pageAngle = 90; |
187 |
} |
188 |
|
189 |
if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height)) |
190 |
{ |
191 |
var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle); |
192 |
rect.Transform(matrix); |
193 |
|
194 |
main.zoomAndPanControl.ZoomTo(rect); |
195 |
} |
196 |
else |
197 |
{ |
198 |
rect.Inflate(rect.Width * 3, rect.Height * 3); |
199 |
|
200 |
var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle); |
201 |
rect.Transform(matrix); |
202 |
|
203 |
|
204 |
main.zoomAndPanControl.ZoomTo(rect); |
205 |
} |
206 |
} |
207 |
catch (Exception ex) |
208 |
{ |
209 |
main.DialogMessage_Alert(ex.Message, "Error"); |
210 |
} |
211 |
} |
212 |
} |
213 |
} |
214 |
|
215 |
} |
216 |
} |