markus / KCOM / Events / UndoCommand.cs @ 490208bd
이력 | 보기 | 이력해설 | 다운로드 (5.84 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 | 34ac8db7 | humkyung | public void Push(EventType _EventType, ICollection<CommentUserInfo> comments) |
51 | d128ceb2 | humkyung | { |
52 | 02a9f323 | humkyung | UndoDataGroup UndoDataGrp = new UndoDataGroup() |
53 | d128ceb2 | humkyung | { |
54 | IsUndo = false, |
||
55 | 02a9f323 | humkyung | Event = _EventType |
56 | d128ceb2 | humkyung | }; |
57 | |||
58 | foreach (var comment in comments) |
||
59 | { |
||
60 | 19d602e0 | humkyung | UndoData _UndoData = new UndoData(comment); |
61 | f258d884 | humkyung | _UndoData.Clone = comment.Clone(); |
62 | 02a9f323 | humkyung | UndoDataGrp.MarkupDataColl.Add(_UndoData); |
63 | 34ac8db7 | humkyung | |
64 | if (_EventType == EventType.Delete) |
||
65 | { |
||
66 | ViewerDataModel.Instance.MarkupControls_USER.Remove(comment); |
||
67 | ViewerDataModel.Instance.MarkupControls.Remove(comment); |
||
68 | |||
69 | var Item_ = ViewerDataModel.Instance.MyMarkupList.Find(d => d.ID == comment.CommentID); |
||
70 | ViewerDataModel.Instance.MyMarkupList.Remove(Item_); |
||
71 | |||
72 | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
||
73 | null, EventType.Delete, MarkupParser.MarkupToString(_UndoData.Markup, App.ViewInfo.UserID).CommentID, null); |
||
74 | } |
||
75 | else |
||
76 | { |
||
77 | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
||
78 | MarkupParser.MarkupToString(_UndoData.Markup, App.ViewInfo.UserID), EventType.Operation, null, null); |
||
79 | } |
||
80 | d128ceb2 | humkyung | } |
81 | 34ac8db7 | humkyung | |
82 | ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo).ToList().ForEach(i => |
||
83 | d128ceb2 | humkyung | { |
84 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
85 | }); |
||
86 | 02a9f323 | humkyung | ViewerDataModel.Instance.UndoDataList.Add(UndoDataGrp); |
87 | d128ceb2 | humkyung | } |
88 | f816dd63 | humkyung | |
89 | /// <summary> |
||
90 | f258d884 | humkyung | /// undo 실행 |
91 | f816dd63 | humkyung | /// </summary> |
92 | public void Execute() |
||
93 | { |
||
94 | AdornerFinal final; |
||
95 | SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
||
96 | |||
97 | 34ac8db7 | humkyung | UndoDataGroup undo = ViewerDataModel.Instance.UndoDataList.Where(data => !data.IsUndo).ToList() |
98 | ab7fe8c0 | humkyung | .OrderByDescending(order => order.EventTime).FirstOrDefault(); |
99 | f816dd63 | humkyung | if (undo == null) return; |
100 | |||
101 | switch (undo.Event) |
||
102 | { |
||
103 | 873011c4 | humkyung | case (EventType.Create): |
104 | f816dd63 | humkyung | { |
105 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
106 | f816dd63 | humkyung | { |
107 | ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup)); |
||
108 | 34ac8db7 | humkyung | |
109 | 39f0624f | ljiyeon | ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
110 | 873011c4 | humkyung | null, EventType.Delete, item.Markup.CommentID, null); |
111 | f816dd63 | humkyung | } |
112 | } |
||
113 | break; |
||
114 | 873011c4 | humkyung | case (EventType.Delete): |
115 | f816dd63 | humkyung | { |
116 | 85132173 | humkyung | List<CommentUserInfo> comments = new List<CommentUserInfo>(); |
117 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
118 | f816dd63 | humkyung | { |
119 | 8e6884a5 | taeseongkim | item.Markup.Load(); |
120 | 34ac8db7 | humkyung | item.Markup.UpdateControl(); |
121 | 85132173 | humkyung | comments.Add(item.Markup); |
122 | f816dd63 | humkyung | } |
123 | 34ac8db7 | humkyung | |
124 | 85132173 | humkyung | var adorner = new AdornerFinal(comments); |
125 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(adorner); |
||
126 | ///SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
||
127 | f816dd63 | humkyung | } |
128 | break; |
||
129 | 873011c4 | humkyung | case (EventType.Operation): |
130 | f816dd63 | humkyung | { |
131 | List<CommentUserInfo> comment = new List<CommentUserInfo>(); |
||
132 | |||
133 | 873011c4 | humkyung | foreach (var item in undo.MarkupDataColl) |
134 | f816dd63 | humkyung | { |
135 | 86143026 | humkyung | ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup); |
136 | cbeff740 | swate0609 | |
137 | 86143026 | humkyung | var tmp = item.Markup.Clone(); |
138 | item.Markup.Copy(item.Clone); |
||
139 | item.Clone.Copy(tmp); |
||
140 | item.Markup.UpdateControl(); |
||
141 | f816dd63 | humkyung | |
142 | comment.Add(item.Markup); |
||
143 | } |
||
144 | 85132173 | humkyung | var adoner = new AdornerFinal(comment); |
145 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(adoner); |
||
146 | 34ac8db7 | humkyung | ///SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
147 | f816dd63 | humkyung | } |
148 | break; |
||
149 | } |
||
150 | 34ac8db7 | humkyung | |
151 | ab7fe8c0 | humkyung | ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList() |
152 | .OrderByDescending(order => order.EventTime).ToList().ForEach(i => |
||
153 | f816dd63 | humkyung | { |
154 | i.IsUndo = true; |
||
155 | }); |
||
156 | } |
||
157 | d128ceb2 | humkyung | } |
158 | } |