markus / KCOM / Events / UndoCommand.cs @ 2a2e72c2
이력 | 보기 | 이력해설 | 다운로드 (11.3 KB)
1 | d128ceb2 | humkyung | using MarkupToPDF.Common; |
---|---|---|---|
2 | using MarkupToPDF.Controls.Common; |
||
3 | using MarkupToPDF.Controls.Line; |
||
4 | using MarkupToPDF.Controls.Polygon; |
||
5 | using MarkupToPDF.Controls.Shape; |
||
6 | using MarkupToPDF.Controls.Text; |
||
7 | using MarkupToPDF.Controls.Etc; |
||
8 | using System; |
||
9 | using System.Collections.Generic; |
||
10 | using System.Linq; |
||
11 | using System.Text; |
||
12 | using System.Windows; |
||
13 | using System.Windows.Controls; |
||
14 | using System.Windows.Media; |
||
15 | using MarkupToPDF.Controls.Cad; |
||
16 | using KCOM.Common; |
||
17 | f816dd63 | humkyung | using KCOM.Controls; |
18 | 4eb052e4 | ljiyeon | using MarkupToPDF.Controls.Parsing; |
19 | d128ceb2 | humkyung | |
20 | namespace KCOM.Events |
||
21 | { |
||
22 | public class UndoCommand |
||
23 | { |
||
24 | private static readonly UndoCommand _instance = new UndoCommand(); |
||
25 | |||
26 | // Explicit static constructor to tell C# compiler |
||
27 | // not to mark type as beforefieldinit |
||
28 | static UndoCommand() |
||
29 | { |
||
30 | } |
||
31 | |||
32 | private UndoCommand() |
||
33 | { |
||
34 | } |
||
35 | |||
36 | public static UndoCommand Instance |
||
37 | { |
||
38 | get |
||
39 | { |
||
40 | return _instance; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /// <summary> |
||
45 | /// push undo data |
||
46 | /// </summary> |
||
47 | /// <author>humkyung</author> |
||
48 | /// <date>2019.06.14</date> |
||
49 | /// <param name="comments"></param> |
||
50 | e5bd2147 | swate0609 | //public void Push(ICollection<CommentUserInfo> comments, double dAngle, double dBeforeAngle = 0.0, List<Point> lstBeforePointSet = null) |
51 | //{ |
||
52 | 873011c4 | humkyung | // UndoData UndoData = new UndoData() |
53 | e5bd2147 | swate0609 | // { |
54 | // IsUndo = false, |
||
55 | 873011c4 | humkyung | // Event = EventType.Thumb, |
56 | e5bd2147 | swate0609 | // EventTime = DateTime.Now, |
57 | 873011c4 | humkyung | // MarkupDataColl = new List<Multi_UndoData>(), |
58 | e5bd2147 | swate0609 | // }; |
59 | |||
60 | 873011c4 | humkyung | // Multi_UndoData multi_UndoData = new Multi_UndoData(); |
61 | e5bd2147 | swate0609 | |
62 | // foreach (var comment in comments) |
||
63 | // { |
||
64 | 873011c4 | humkyung | // multi_UndoData.PointSet = new List<Point>(); |
65 | e5bd2147 | swate0609 | // var p_set = new List<Point>(); |
66 | |||
67 | // if (comment is TextControl) |
||
68 | // { |
||
69 | 873011c4 | humkyung | // multi_UndoData.PointSet.Add((comment as TextControl).StartPoint); |
70 | // multi_UndoData.PointSet.Add((comment as TextControl).EndPoint); |
||
71 | e5bd2147 | swate0609 | // } |
72 | |||
73 | // foreach (var point in (comment as IPath).PointSet) |
||
74 | // { |
||
75 | 873011c4 | humkyung | // multi_UndoData.PointSet.Add(point); |
76 | e5bd2147 | swate0609 | // } |
77 | |||
78 | // if (lstBeforePointSet != null) |
||
79 | 873011c4 | humkyung | // multi_UndoData.BeforePointSet = lstBeforePointSet; |
80 | e5bd2147 | swate0609 | |
81 | // if (comment is ArrowTextControl) |
||
82 | // { |
||
83 | 873011c4 | humkyung | // //multi_UndoData.Angle = dAngle = (comment as ArrowTextControl).CommentAngle; |
84 | // multi_UndoData.Angle = dAngle; |
||
85 | // multi_UndoData.BeforeAngle = dBeforeAngle; |
||
86 | e5bd2147 | swate0609 | // } |
87 | // else |
||
88 | // { |
||
89 | 873011c4 | humkyung | // multi_UndoData.Angle = dAngle; |
90 | // multi_UndoData.BeforeAngle = dBeforeAngle; |
||
91 | e5bd2147 | swate0609 | // } |
92 | |||
93 | 873011c4 | humkyung | // multi_UndoData.Markup = comment; |
94 | // UndoData.MarkupDataColl.Add(multi_UndoData); |
||
95 | e5bd2147 | swate0609 | // ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
96 | 873011c4 | humkyung | // MarkupParser.MarkupToString(multi_UndoData.Markup, App.ViewInfo.UserID), EventType.Thumb, null, null); |
97 | e5bd2147 | swate0609 | |
98 | 873011c4 | humkyung | // multi_UndoData = new Multi_UndoData(); |
99 | e5bd2147 | swate0609 | // } |
100 | // ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
||
101 | // { |
||
102 | // ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
103 | // }); |
||
104 | |||
105 | // ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
106 | //} |
||
107 | |||
108 | public void Push(ICollection<CommentUserInfo> comments) |
||
109 | d128ceb2 | humkyung | { |
110 | 873011c4 | humkyung | UndoDataGroup UndoData = new UndoDataGroup() |
111 | d128ceb2 | humkyung | { |
112 | IsUndo = false, |
||
113 | 873011c4 | humkyung | Event = EventType.Operation, |
114 | d128ceb2 | humkyung | EventTime = DateTime.Now, |
115 | 873011c4 | humkyung | MarkupDataColl = new List<Multi_UndoData>(), |
116 | d128ceb2 | humkyung | }; |
117 | |||
118 | foreach (var comment in comments) |
||
119 | { |
||
120 | 873011c4 | humkyung | Multi_UndoData multi_UndoData = new Multi_UndoData(); |
121 | multi_UndoData.Markup = comment; |
||
122 | multi_UndoData.Clone = comment.Clone(); |
||
123 | /* |
||
124 | multi_UndoData.PointSet = new List<Point>(); |
||
125 | ab7fe8c0 | humkyung | var p_set = new List<Point>(); |
126 | d128ceb2 | humkyung | |
127 | if (comment is TextControl) |
||
128 | { |
||
129 | 873011c4 | humkyung | multi_UndoData.PointSet.Add((comment as TextControl).StartPoint); |
130 | multi_UndoData.PointSet.Add((comment as TextControl).EndPoint); |
||
131 | d128ceb2 | humkyung | } |
132 | |||
133 | foreach (var point in (comment as IPath).PointSet) |
||
134 | { |
||
135 | 873011c4 | humkyung | multi_UndoData.PointSet.Add(point); |
136 | d128ceb2 | humkyung | } |
137 | |||
138 | e5bd2147 | swate0609 | |
139 | List<Point> points = new List<Point>(); |
||
140 | foreach(var point in (comment as IPath).PointSet) |
||
141 | { |
||
142 | points.Add(point); |
||
143 | } |
||
144 | 873011c4 | humkyung | multi_UndoData.PointSet = points; |
145 | fd452a01 | swate0609 | |
146 | d128ceb2 | humkyung | if (comment is ArrowTextControl) |
147 | { |
||
148 | 873011c4 | humkyung | //multi_UndoData.Angle = dAngle = (comment as ArrowTextControl).CommentAngle; |
149 | multi_UndoData.Angle = comment.CommentAngle; |
||
150 | d128ceb2 | humkyung | } |
151 | else |
||
152 | { |
||
153 | 873011c4 | humkyung | multi_UndoData.Angle = comment.CommentAngle; |
154 | d128ceb2 | humkyung | } |
155 | |||
156 | 873011c4 | humkyung | multi_UndoData.Markup = comment; |
157 | */ |
||
158 | UndoData.MarkupDataColl.Add(multi_UndoData); |
||
159 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
160 | 873011c4 | humkyung | MarkupParser.MarkupToString(multi_UndoData.Markup, App.ViewInfo.UserID), EventType.Operation, null, null); |
161 | d128ceb2 | humkyung | } |
162 | ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
||
163 | { |
||
164 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
165 | }); |
||
166 | |||
167 | e5bd2147 | swate0609 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
168 | d128ceb2 | humkyung | } |
169 | f816dd63 | humkyung | |
170 | /// <summary> |
||
171 | /// undo |
||
172 | /// </summary> |
||
173 | public void Execute() |
||
174 | { |
||
175 | AdornerFinal final; |
||
176 | SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
||
177 | |||
178 | 873011c4 | humkyung | UndoDataGroup undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList() |
179 | ab7fe8c0 | humkyung | .OrderByDescending(order => order.EventTime).FirstOrDefault(); |
180 | f816dd63 | humkyung | if (undo == null) return; |
181 | |||
182 | switch (undo.Event) |
||
183 | { |
||
184 | 873011c4 | humkyung | case (EventType.Create): |
185 | f816dd63 | humkyung | { |
186 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
187 | f816dd63 | humkyung | { |
188 | ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
||
189 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
190 | 873011c4 | humkyung | null, EventType.Delete, item.Markup.CommentID, null); |
191 | f816dd63 | humkyung | } |
192 | } |
||
193 | break; |
||
194 | 873011c4 | humkyung | case (EventType.Delete): |
195 | f816dd63 | humkyung | { |
196 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
197 | f816dd63 | humkyung | { |
198 | 8e6884a5 | taeseongkim | //var markupitem = MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID); |
199 | |||
200 | //if (markupitem != null) |
||
201 | //{ |
||
202 | // IKCOM.MarkupItemEx markup = new IKCOM.MarkupItemEx |
||
203 | // { |
||
204 | // Data = markupitem.ConvertData, |
||
205 | // Data_Type = markupitem.DATA_TYPE, |
||
206 | // ID = markupitem.CommentID, |
||
207 | // IsUpdate = false, |
||
208 | // MarkupInfoID = App.Custom_ViewInfoId, |
||
209 | // PageNumber = ViewerDataModel.Instance.PageNumber, |
||
210 | // //Symbol_ID = p.Symbol_ID, |
||
211 | // //Group_ID = p.Group_ID |
||
212 | // }; |
||
213 | |||
214 | // ViewerDataModel.Instance.MyMarkupList.Add(markup); |
||
215 | //} |
||
216 | |||
217 | //ViewerDataModel.Instance.MarkupControls.Add(item.Markup); |
||
218 | item.Markup.Load(); |
||
219 | |||
220 | f816dd63 | humkyung | ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup); |
221 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
222 | 873011c4 | humkyung | MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID), EventType.Create, null, null); |
223 | f816dd63 | humkyung | } |
224 | } |
||
225 | break; |
||
226 | 873011c4 | humkyung | case (EventType.Operation): |
227 | f816dd63 | humkyung | { |
228 | List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
||
229 | |||
230 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
231 | f816dd63 | humkyung | { |
232 | 86143026 | humkyung | ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup); |
233 | cbeff740 | swate0609 | |
234 | 86143026 | humkyung | var tmp = item.Markup.Clone(); |
235 | item.Markup.Copy(item.Clone); |
||
236 | item.Clone.Copy(tmp); |
||
237 | item.Markup.UpdateControl(); |
||
238 | f816dd63 | humkyung | |
239 | comment.Add(item.Markup); |
||
240 | } |
||
241 | final = new AdornerFinal(comment); |
||
242 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
||
243 | SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
||
244 | } |
||
245 | break; |
||
246 | 873011c4 | humkyung | /* |
247 | case (EventType.Select): |
||
248 | f816dd63 | humkyung | { |
249 | List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
||
250 | |||
251 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
252 | f816dd63 | humkyung | { |
253 | ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
||
254 | |||
255 | if ((item.Markup as IPath) != null) |
||
256 | { |
||
257 | (item.Markup as IPath).LineSize = item.LineSize; |
||
258 | } |
||
259 | if ((item.Markup as UIElement) != null) |
||
260 | { |
||
261 | (item.Markup as UIElement).Opacity = item.Opacity; |
||
262 | } |
||
263 | if ((item.Markup as IDashControl) != null) |
||
264 | { |
||
265 | (item.Markup as IDashControl).DashSize = item.DashSize; |
||
266 | } |
||
267 | if ((item.Markup as IShapeControl) != null) |
||
268 | { |
||
269 | (item.Markup as IShapeControl).Paint = item.paint; |
||
270 | } |
||
271 | |||
272 | comment.Add(item.Markup); |
||
273 | } |
||
274 | |||
275 | final = new AdornerFinal(comment); |
||
276 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
||
277 | } |
||
278 | break; |
||
279 | 873011c4 | humkyung | */ |
280 | f816dd63 | humkyung | } |
281 | ab7fe8c0 | humkyung | ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList() |
282 | .OrderByDescending(order => order.EventTime).ToList().ForEach(i => |
||
283 | f816dd63 | humkyung | { |
284 | i.IsUndo = true; |
||
285 | }); |
||
286 | } |
||
287 | d128ceb2 | humkyung | } |
288 | } |