markus / KCOM / Events / UndoCommand.cs @ b79d6e7f
이력 | 보기 | 이력해설 | 다운로드 (11.3 KB)
1 |
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 |
using KCOM.Controls; |
18 |
using MarkupToPDF.Controls.Parsing; |
19 |
|
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 |
//public void Push(ICollection<CommentUserInfo> comments, double dAngle, double dBeforeAngle = 0.0, List<Point> lstBeforePointSet = null) |
51 |
//{ |
52 |
// UndoData UndoData = new UndoData() |
53 |
// { |
54 |
// IsUndo = false, |
55 |
// Event = EventType.Thumb, |
56 |
// EventTime = DateTime.Now, |
57 |
// MarkupDataColl = new List<Multi_UndoData>(), |
58 |
// }; |
59 |
|
60 |
// Multi_UndoData multi_UndoData = new Multi_UndoData(); |
61 |
|
62 |
// foreach (var comment in comments) |
63 |
// { |
64 |
// multi_UndoData.PointSet = new List<Point>(); |
65 |
// var p_set = new List<Point>(); |
66 |
|
67 |
// if (comment is TextControl) |
68 |
// { |
69 |
// multi_UndoData.PointSet.Add((comment as TextControl).StartPoint); |
70 |
// multi_UndoData.PointSet.Add((comment as TextControl).EndPoint); |
71 |
// } |
72 |
|
73 |
// foreach (var point in (comment as IPath).PointSet) |
74 |
// { |
75 |
// multi_UndoData.PointSet.Add(point); |
76 |
// } |
77 |
|
78 |
// if (lstBeforePointSet != null) |
79 |
// multi_UndoData.BeforePointSet = lstBeforePointSet; |
80 |
|
81 |
// if (comment is ArrowTextControl) |
82 |
// { |
83 |
// //multi_UndoData.Angle = dAngle = (comment as ArrowTextControl).CommentAngle; |
84 |
// multi_UndoData.Angle = dAngle; |
85 |
// multi_UndoData.BeforeAngle = dBeforeAngle; |
86 |
// } |
87 |
// else |
88 |
// { |
89 |
// multi_UndoData.Angle = dAngle; |
90 |
// multi_UndoData.BeforeAngle = dBeforeAngle; |
91 |
// } |
92 |
|
93 |
// multi_UndoData.Markup = comment; |
94 |
// UndoData.MarkupDataColl.Add(multi_UndoData); |
95 |
// ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
96 |
// MarkupParser.MarkupToString(multi_UndoData.Markup, App.ViewInfo.UserID), EventType.Thumb, null, null); |
97 |
|
98 |
// multi_UndoData = new Multi_UndoData(); |
99 |
// } |
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 |
{ |
110 |
UndoDataGroup UndoData = new UndoDataGroup() |
111 |
{ |
112 |
IsUndo = false, |
113 |
Event = EventType.Operation, |
114 |
EventTime = DateTime.Now, |
115 |
MarkupDataColl = new List<UndoData>(), |
116 |
}; |
117 |
|
118 |
foreach (var comment in comments) |
119 |
{ |
120 |
UndoData multi_UndoData = new UndoData(); |
121 |
multi_UndoData.Markup = comment; |
122 |
multi_UndoData.Clone = comment.Clone(); |
123 |
/* |
124 |
multi_UndoData.PointSet = new List<Point>(); |
125 |
var p_set = new List<Point>(); |
126 |
|
127 |
if (comment is TextControl) |
128 |
{ |
129 |
multi_UndoData.PointSet.Add((comment as TextControl).StartPoint); |
130 |
multi_UndoData.PointSet.Add((comment as TextControl).EndPoint); |
131 |
} |
132 |
|
133 |
foreach (var point in (comment as IPath).PointSet) |
134 |
{ |
135 |
multi_UndoData.PointSet.Add(point); |
136 |
} |
137 |
|
138 |
|
139 |
List<Point> points = new List<Point>(); |
140 |
foreach(var point in (comment as IPath).PointSet) |
141 |
{ |
142 |
points.Add(point); |
143 |
} |
144 |
multi_UndoData.PointSet = points; |
145 |
|
146 |
if (comment is ArrowTextControl) |
147 |
{ |
148 |
//multi_UndoData.Angle = dAngle = (comment as ArrowTextControl).CommentAngle; |
149 |
multi_UndoData.Angle = comment.CommentAngle; |
150 |
} |
151 |
else |
152 |
{ |
153 |
multi_UndoData.Angle = comment.CommentAngle; |
154 |
} |
155 |
|
156 |
multi_UndoData.Markup = comment; |
157 |
*/ |
158 |
UndoData.MarkupDataColl.Add(multi_UndoData); |
159 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
160 |
MarkupParser.MarkupToString(multi_UndoData.Markup, App.ViewInfo.UserID), EventType.Operation, null, null); |
161 |
} |
162 |
ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
163 |
{ |
164 |
ViewerDataModel.Instance.UndoDataList.Remove(i); |
165 |
}); |
166 |
|
167 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
168 |
} |
169 |
|
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 |
UndoDataGroup undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList() |
179 |
.OrderByDescending(order => order.EventTime).FirstOrDefault(); |
180 |
if (undo == null) return; |
181 |
|
182 |
switch (undo.Event) |
183 |
{ |
184 |
case (EventType.Create): |
185 |
{ |
186 |
foreach (var item in undo.MarkupDataColl) |
187 |
{ |
188 |
ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
189 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
190 |
null, EventType.Delete, item.Markup.CommentID, null); |
191 |
} |
192 |
} |
193 |
break; |
194 |
case (EventType.Delete): |
195 |
{ |
196 |
foreach (var item in undo.MarkupDataColl) |
197 |
{ |
198 |
//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 |
ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup); |
221 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
222 |
MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID), EventType.Create, null, null); |
223 |
} |
224 |
} |
225 |
break; |
226 |
case (EventType.Operation): |
227 |
{ |
228 |
List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
229 |
|
230 |
foreach (var item in undo.MarkupDataColl) |
231 |
{ |
232 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup); |
233 |
|
234 |
var tmp = item.Markup.Clone(); |
235 |
item.Markup.Copy(item.Clone); |
236 |
item.Clone.Copy(tmp); |
237 |
item.Markup.UpdateControl(); |
238 |
|
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 |
/* |
247 |
case (EventType.Select): |
248 |
{ |
249 |
List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
250 |
|
251 |
foreach (var item in undo.MarkupDataColl) |
252 |
{ |
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 |
*/ |
280 |
} |
281 |
ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList() |
282 |
.OrderByDescending(order => order.EventTime).ToList().ForEach(i => |
283 |
{ |
284 |
i.IsUndo = true; |
285 |
}); |
286 |
} |
287 |
} |
288 |
} |