markus / KCOM / Extensions / MarkupVisitHelper.cs @ 03960fa5
이력 | 보기 | 이력해설 | 다운로드 (7.54 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 |
var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First()); |
28 |
|
29 |
if (commentList.Count() > 0) |
30 |
{ |
31 |
|
32 |
var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator; |
33 |
|
34 |
/// 페이지가 틀린 경우 먼저 페이지를 변경한다. |
35 |
if (pageNavigator.CurrentPage.PageNumber != commentList.First().PageNumber) |
36 |
{ |
37 |
EventHandler<EventArgs> handler = null; |
38 |
|
39 |
/// 페이지 변경 후 다시 호출 |
40 |
handler = (snd, evt) => |
41 |
{ |
42 |
ViewerDataModel.Instance.PageLoaded -= handler; |
43 |
|
44 |
Task.Delay(100).ConfigureAwait(true); |
45 |
|
46 |
GotoMarkup(CommentIdList); |
47 |
}; |
48 |
|
49 |
ViewerDataModel.Instance.PageLoaded += handler; |
50 |
|
51 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(commentList.First().PageNumber); |
52 |
} |
53 |
else |
54 |
{ |
55 |
//하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다. |
56 |
#region markup list grid select items |
57 |
|
58 |
var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0); |
59 |
|
60 |
if (infoItem.Count() > 0) |
61 |
{ |
62 |
|
63 |
var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup; |
64 |
gridMarkup.SelectedItems.Clear(); |
65 |
gridMarkup.SelectedItems.Add(infoItem.First()); |
66 |
} |
67 |
|
68 |
#endregion |
69 |
|
70 |
GotoSelectedMarkup(CommentIdList); |
71 |
|
72 |
} |
73 |
} |
74 |
} |
75 |
|
76 |
private static void GotoSelectedMarkup(IEnumerable<string> CommentIdList) |
77 |
{ |
78 |
var instance = Common.ViewerDataModel.Instance; |
79 |
|
80 |
var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList(); |
81 |
var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList(); |
82 |
|
83 |
if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0) |
84 |
{ |
85 |
commentUserInfo.ForEach(x => x.IsSelected = true); |
86 |
commentUserInfo.AddRange(selectOrderComments); |
87 |
|
88 |
if (commentUserInfo?.Count() > 0) |
89 |
{ |
90 |
var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
91 |
|
92 |
try |
93 |
{ |
94 |
if (Common.ViewerDataModel.Instance.Angle != 0) |
95 |
{ |
96 |
for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++) |
97 |
{ |
98 |
Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true); |
99 |
} |
100 |
|
101 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0; |
102 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0; |
103 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0; |
104 |
} |
105 |
|
106 |
Rect rect = commentUserInfo.First().ItemRect; |
107 |
|
108 |
foreach (var UserInfo in commentUserInfo) |
109 |
{ |
110 |
rect = Rect.Union(rect, UserInfo.ItemRect); |
111 |
UserInfo.OnMouseHover(); |
112 |
} |
113 |
|
114 |
SelectionSet.Instance.SelectItemByRect(rect, main); |
115 |
|
116 |
var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2); |
117 |
//var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle); |
118 |
//rect.Transform(matrix); |
119 |
|
120 |
double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width; |
121 |
double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height; |
122 |
double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY); |
123 |
double positionX = 0; |
124 |
double positionY = 0; |
125 |
|
126 |
if (Common.ViewerDataModel.Instance.Angle == 90) |
127 |
{ |
128 |
positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X; |
129 |
positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y; |
130 |
} |
131 |
//else if (Common.ViewerDataModel.Instance.Angle == 270) |
132 |
//{ |
133 |
// positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X *4; |
134 |
// positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y * 4; |
135 |
//} |
136 |
|
137 |
main.zoomAndPanControl.ContentScale = newScale; |
138 |
main.zoomAndPanControl.ContentOffsetX = positionX; |
139 |
main.zoomAndPanControl.ContentOffsetY = positionY; |
140 |
|
141 |
|
142 |
var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height); |
143 |
|
144 |
double pageAngle = Common.ViewerDataModel.Instance.Angle; |
145 |
|
146 |
if (pageAngle == 90) |
147 |
{ |
148 |
pageAngle = 270; |
149 |
} |
150 |
else |
151 |
{ |
152 |
pageAngle = 90; |
153 |
} |
154 |
|
155 |
if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height)) |
156 |
{ |
157 |
var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle); |
158 |
rect.Transform(matrix); |
159 |
|
160 |
main.zoomAndPanControl.ZoomTo(rect); |
161 |
} |
162 |
else |
163 |
{ |
164 |
rect.Inflate(rect.Width * 3, rect.Height * 3); |
165 |
|
166 |
var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle); |
167 |
rect.Transform(matrix); |
168 |
|
169 |
|
170 |
main.zoomAndPanControl.ZoomTo(rect); |
171 |
} |
172 |
} |
173 |
catch (Exception ex) |
174 |
{ |
175 |
main.DialogMessage_Alert(ex.Message, "Error"); |
176 |
} |
177 |
} |
178 |
} |
179 |
} |
180 |
|
181 |
} |
182 |
} |