프로젝트

일반

사용자정보

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

markus / KCOM / Events / RedoCommand.cs @ 0d00f9c8

이력 | 보기 | 이력해설 | 다운로드 (7.09 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

    
19
namespace KCOM.Events
20
{
21
    public class RedoCommand
22
    {
23
        private static readonly RedoCommand _instance = new RedoCommand();
24

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

    
31
        private RedoCommand()
32
        {
33
        }
34

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

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

    
52
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
53
            switch (redo.Event)
54
            {
55
                case (Event_Type.Create):
56
                    {
57
                        foreach (var item in redo.Markup_List)
58
                        {
59
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
60
                        }
61
                    }
62
                    break;
63
                case (Event_Type.Delete):
64
                    {
65
                        foreach (var item in redo.Markup_List)
66
                        {
67
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
68
                        }
69
                    }
70
                    break;
71
                case (Event_Type.Thumb):
72
                    {
73
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
74

    
75
                        foreach (var item in redo.Markup_List)
76
                        {
77
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
78

    
79
                            if ((item.Markup as IViewBox) != null)
80
                            {
81
                                (item.Markup as IViewBox).Angle = item.Angle;
82
                            }
83
                            if ((item.Markup as TextControl) != null)
84
                            {
85
                                (item.Markup as TextControl).Angle = item.Angle;
86

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

    
106
                        foreach (var item in redo.Markup_List)
107
                        {
108
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
109

    
110
                            if ((item.Markup as IPath) != null)
111
                            {
112
                                (item.Markup as IPath).LineSize = item.LineSize;
113
                            }
114
                            if ((item.Markup as UIElement) != null)
115
                            {
116
                                (item.Markup as UIElement).Opacity = item.Opacity;
117
                            }
118
                            if ((item.Markup as IDashControl) != null)
119
                            {
120
                                (item.Markup as IDashControl).DashSize = item.DashSize;
121
                            }
122
                            if ((item.Markup as IShapeControl) != null)
123
                            {
124
                                (item.Markup as IShapeControl).Paint = item.paint;
125
                            }
126

    
127
                            comment.Add(item.Markup);
128
                        }
129
                        final = new AdornerFinal(comment);
130
                        Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
131
                    }
132
                    break;
133
                case (Event_Type.Option):
134
                    {
135
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
136

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

    
168
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
169
            {
170
                i.IsUndo = false;
171
            });
172
        }
173
    }
174
}
클립보드 이미지 추가 (최대 크기: 500 MB)