markus / KCOM / Events / UndoCommand.cs @ 90d1dee0
이력 | 보기 | 이력해설 | 다운로드 (7.67 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 | f258d884 | humkyung | /// <date>2019.06.14, 2024.04.26</date> |
49 | d128ceb2 | humkyung | /// <param name="comments"></param> |
50 | e5bd2147 | swate0609 | public void Push(ICollection<CommentUserInfo> comments) |
51 | d128ceb2 | humkyung | { |
52 | 873011c4 | humkyung | UndoDataGroup UndoData = new UndoDataGroup() |
53 | d128ceb2 | humkyung | { |
54 | IsUndo = false, |
||
55 | 873011c4 | humkyung | Event = EventType.Operation, |
56 | d128ceb2 | humkyung | EventTime = DateTime.Now, |
57 | b79d6e7f | humkyung | MarkupDataColl = new List<UndoData>(), |
58 | d128ceb2 | humkyung | }; |
59 | |||
60 | foreach (var comment in comments) |
||
61 | { |
||
62 | f258d884 | humkyung | UndoData _UndoData = new UndoData(); |
63 | _UndoData.Markup = comment; |
||
64 | _UndoData.Clone = comment.Clone(); |
||
65 | d128ceb2 | humkyung | |
66 | f258d884 | humkyung | UndoData.MarkupDataColl.Add(_UndoData); |
67 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
68 | f258d884 | humkyung | MarkupParser.MarkupToString(_UndoData.Markup, App.ViewInfo.UserID), EventType.Operation, null, null); |
69 | d128ceb2 | humkyung | } |
70 | ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
||
71 | { |
||
72 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
73 | }); |
||
74 | |||
75 | e5bd2147 | swate0609 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
76 | d128ceb2 | humkyung | } |
77 | f816dd63 | humkyung | |
78 | /// <summary> |
||
79 | f258d884 | humkyung | /// undo 실행 |
80 | f816dd63 | humkyung | /// </summary> |
81 | public void Execute() |
||
82 | { |
||
83 | AdornerFinal final; |
||
84 | SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
||
85 | |||
86 | 873011c4 | humkyung | UndoDataGroup undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList() |
87 | ab7fe8c0 | humkyung | .OrderByDescending(order => order.EventTime).FirstOrDefault(); |
88 | f816dd63 | humkyung | if (undo == null) return; |
89 | |||
90 | switch (undo.Event) |
||
91 | { |
||
92 | 873011c4 | humkyung | case (EventType.Create): |
93 | f816dd63 | humkyung | { |
94 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
95 | f816dd63 | humkyung | { |
96 | ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
||
97 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
98 | 873011c4 | humkyung | null, EventType.Delete, item.Markup.CommentID, null); |
99 | f816dd63 | humkyung | } |
100 | } |
||
101 | break; |
||
102 | 873011c4 | humkyung | case (EventType.Delete): |
103 | f816dd63 | humkyung | { |
104 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
105 | f816dd63 | humkyung | { |
106 | 8e6884a5 | taeseongkim | //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 | f816dd63 | humkyung | ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup); |
129 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
130 | 873011c4 | humkyung | MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID), EventType.Create, null, null); |
131 | f816dd63 | humkyung | } |
132 | } |
||
133 | break; |
||
134 | 873011c4 | humkyung | case (EventType.Operation): |
135 | f816dd63 | humkyung | { |
136 | List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
||
137 | |||
138 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
139 | f816dd63 | humkyung | { |
140 | 86143026 | humkyung | ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup); |
141 | cbeff740 | swate0609 | |
142 | 86143026 | humkyung | var tmp = item.Markup.Clone(); |
143 | item.Markup.Copy(item.Clone); |
||
144 | item.Clone.Copy(tmp); |
||
145 | item.Markup.UpdateControl(); |
||
146 | f816dd63 | humkyung | |
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 | 873011c4 | humkyung | /* |
155 | case (EventType.Select): |
||
156 | f816dd63 | humkyung | { |
157 | List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
||
158 | |||
159 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
160 | f816dd63 | humkyung | { |
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 | 873011c4 | humkyung | */ |
188 | f816dd63 | humkyung | } |
189 | ab7fe8c0 | humkyung | ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList() |
190 | .OrderByDescending(order => order.EventTime).ToList().ForEach(i => |
||
191 | f816dd63 | humkyung | { |
192 | i.IsUndo = true; |
||
193 | }); |
||
194 | } |
||
195 | d128ceb2 | humkyung | } |
196 | } |