프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Events / RedoCommand.cs @ ab7fe8c0

이력 | 보기 | 이력해설 | 다운로드 (7.58 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 RedoCommand
23
    {
24
        private static readonly RedoCommand _instance = new RedoCommand();
25

    
26
        // Explicit static constructor to tell C# compiler
27
        // not to mark type as beforefieldinit
28
        static RedoCommand()
29
        {
30
        }
31

    
32
        private RedoCommand()
33
        {
34
        }
35

    
36
        public static RedoCommand Instance
37
        {
38
            get
39
            {
40
                return _instance;
41
            }
42
        }
43

    
44
        /// <summary>
45
        /// redo
46
        /// </summary>
47
        public void Execute()
48
        {
49
            AdornerFinal final;
50
            Undo_data redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo).ToList()
51
                .OrderBy(order => order.EventTime).FirstOrDefault();
52
            if (redo == null) return;
53

    
54
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
55
            switch (redo.Event)
56
            {
57
                case (Event_Type.Create):
58
                    {
59
                        foreach (var item in redo.Markup_List)
60
                        {
61
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
62
                            ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
63
                            MarkupParser.MarkupToString(item.Markup, App.ViewInfo.UserID), Event_Type.Create, null, null);
64
                        }
65
                    }
66
                    break;
67
                case (Event_Type.Delete):
68
                    {
69
                        foreach (var item in redo.Markup_List)
70
                        {
71
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
72
                            ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
73
                            null, Event_Type.Delete, item.Markup.CommentID, null);
74
                        }
75
                    }
76
                    break;
77
                case (Event_Type.Thumb):
78
                    {
79
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
80

    
81
                        foreach (var item in redo.Markup_List)
82
                        {
83
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
84

    
85
                            if ((item.Markup as IViewBox) != null)
86
                            {
87
                                (item.Markup as IViewBox).CommentAngle = item.Angle;
88
                            }
89
                            if ((item.Markup as TextControl) != null)
90
                            {
91
                                (item.Markup as TextControl).CommentAngle = item.Angle;
92

    
93
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
94
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
95
                            }
96
                            else
97
                            {
98
                                (item.Markup as IPath).PointSet = item.PointSet;
99
                                (item.Markup as CommentUserInfo).UpdateControl();
100
                            }
101
                            comment.Add(item.Markup);
102
                        }
103
                        final = new AdornerFinal(comment);
104
                        Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
105
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
106
                    }
107
                    break;
108
                case (Event_Type.Select):
109
                    {
110
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
111

    
112
                        foreach (var item in redo.Markup_List)
113
                        {
114
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
115

    
116
                            if ((item.Markup as IPath) != null)
117
                            {
118
                                (item.Markup as IPath).LineSize = item.LineSize;
119
                            }
120
                            if ((item.Markup as UIElement) != null)
121
                            {
122
                                (item.Markup as UIElement).Opacity = item.Opacity;
123
                            }
124
                            if ((item.Markup as IDashControl) != null)
125
                            {
126
                                (item.Markup as IDashControl).DashSize = item.DashSize;
127
                            }
128
                            if ((item.Markup as IShapeControl) != null)
129
                            {
130
                                (item.Markup as IShapeControl).Paint = item.paint;
131
                            }
132

    
133
                            comment.Add(item.Markup);
134
                        }
135
                        final = new AdornerFinal(comment);
136
                        Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
137
                    }
138
                    break;
139
                case (Event_Type.Option):
140
                    {
141
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
142

    
143
                        foreach (var item in redo.Markup_List)
144
                        {
145
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
146
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
147
                            {
148
                                (item.Markup as IPath).LineSize = redo.LineSize;
149
                            }
150
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
151
                            {
152
                                (item.Markup as UIElement).Opacity = redo.Opacity;
153
                            }
154
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
155
                            {
156
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
157
                            }
158
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
159
                            {
160
                                (item.Markup as LineControl).Interval = redo.Interval;
161
                            }
162
                            else if (item.Markup as IShapeControl != null)
163
                            {
164
                                (item.Markup as IShapeControl).Paint = redo.paint;
165
                            }
166
                            comment.Add(item.Markup);
167
                        }
168
                        final = new AdornerFinal(comment);
169
                        Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
170
                    }
171
                    break;
172
            }
173

    
174
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList()
175
                .OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
176
            {
177
                i.IsUndo = false;
178
            });
179
        }
180
    }
181
}
클립보드 이미지 추가 (최대 크기: 500 MB)