markus / KCOM / Events / UndoCommand.cs @ f258d884
이력 | 보기 | 이력해설 | 다운로드 (7.67 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, 2024.04.26</date> |
49 |
/// <param name="comments"></param> |
50 |
public void Push(ICollection<CommentUserInfo> comments) |
51 |
{ |
52 |
UndoDataGroup UndoData = new UndoDataGroup() |
53 |
{ |
54 |
IsUndo = false, |
55 |
Event = EventType.Operation, |
56 |
EventTime = DateTime.Now, |
57 |
MarkupDataColl = new List<UndoData>(), |
58 |
}; |
59 |
|
60 |
foreach (var comment in comments) |
61 |
{ |
62 |
UndoData _UndoData = new UndoData(); |
63 |
_UndoData.Markup = comment; |
64 |
_UndoData.Clone = comment.Clone(); |
65 |
|
66 |
UndoData.MarkupDataColl.Add(_UndoData); |
67 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
68 |
MarkupParser.MarkupToString(_UndoData.Markup, App.ViewInfo.UserID), EventType.Operation, null, null); |
69 |
} |
70 |
ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
71 |
{ |
72 |
ViewerDataModel.Instance.UndoDataList.Remove(i); |
73 |
}); |
74 |
|
75 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
76 |
} |
77 |
|
78 |
/// <summary> |
79 |
/// undo 실행 |
80 |
/// </summary> |
81 |
public void Execute() |
82 |
{ |
83 |
AdornerFinal final; |
84 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
85 |
|
86 |
UndoDataGroup undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList() |
87 |
.OrderByDescending(order => order.EventTime).FirstOrDefault(); |
88 |
if (undo == null) return; |
89 |
|
90 |
switch (undo.Event) |
91 |
{ |
92 |
case (EventType.Create): |
93 |
{ |
94 |
foreach (var item in undo.MarkupDataColl) |
95 |
{ |
96 |
ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
97 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
98 |
null, EventType.Delete, item.Markup.CommentID, null); |
99 |
} |
100 |
} |
101 |
break; |
102 |
case (EventType.Delete): |
103 |
{ |
104 |
foreach (var item in undo.MarkupDataColl) |
105 |
{ |
106 |
//var markupitem = MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID); |
107 |
|
108 |
//if (markupitem != null) |
109 |
//{ |
110 |
// IKCOM.MarkupItemEx markup = new IKCOM.MarkupItemEx |
111 |
// { |
112 |
// Data = markupitem.ConvertData, |
113 |
// Data_Type = markupitem.DATA_TYPE, |
114 |
// ID = markupitem.CommentID, |
115 |
// IsUpdate = false, |
116 |
// MarkupInfoID = App.Custom_ViewInfoId, |
117 |
// PageNumber = ViewerDataModel.Instance.PageNumber, |
118 |
// //Symbol_ID = p.Symbol_ID, |
119 |
// //Group_ID = p.Group_ID |
120 |
// }; |
121 |
|
122 |
// ViewerDataModel.Instance.MyMarkupList.Add(markup); |
123 |
//} |
124 |
|
125 |
//ViewerDataModel.Instance.MarkupControls.Add(item.Markup); |
126 |
item.Markup.Load(); |
127 |
|
128 |
ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup); |
129 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
130 |
MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID), EventType.Create, null, null); |
131 |
} |
132 |
} |
133 |
break; |
134 |
case (EventType.Operation): |
135 |
{ |
136 |
List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
137 |
|
138 |
foreach (var item in undo.MarkupDataColl) |
139 |
{ |
140 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup); |
141 |
|
142 |
var tmp = item.Markup.Clone(); |
143 |
item.Markup.Copy(item.Clone); |
144 |
item.Clone.Copy(tmp); |
145 |
item.Markup.UpdateControl(); |
146 |
|
147 |
comment.Add(item.Markup); |
148 |
} |
149 |
final = new AdornerFinal(comment); |
150 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
151 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
152 |
} |
153 |
break; |
154 |
/* |
155 |
case (EventType.Select): |
156 |
{ |
157 |
List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
158 |
|
159 |
foreach (var item in undo.MarkupDataColl) |
160 |
{ |
161 |
ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
162 |
|
163 |
if ((item.Markup as IPath) != null) |
164 |
{ |
165 |
(item.Markup as IPath).LineSize = item.LineSize; |
166 |
} |
167 |
if ((item.Markup as UIElement) != null) |
168 |
{ |
169 |
(item.Markup as UIElement).Opacity = item.Opacity; |
170 |
} |
171 |
if ((item.Markup as IDashControl) != null) |
172 |
{ |
173 |
(item.Markup as IDashControl).DashSize = item.DashSize; |
174 |
} |
175 |
if ((item.Markup as IShapeControl) != null) |
176 |
{ |
177 |
(item.Markup as IShapeControl).Paint = item.paint; |
178 |
} |
179 |
|
180 |
comment.Add(item.Markup); |
181 |
} |
182 |
|
183 |
final = new AdornerFinal(comment); |
184 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
185 |
} |
186 |
break; |
187 |
*/ |
188 |
} |
189 |
ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList() |
190 |
.OrderByDescending(order => order.EventTime).ToList().ForEach(i => |
191 |
{ |
192 |
i.IsUndo = true; |
193 |
}); |
194 |
} |
195 |
} |
196 |
} |