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