프로젝트

일반

사용자정보

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

markus / KCOM / Events / UndoCommand.cs @ d128ceb2

이력 | 보기 | 이력해설 | 다운로드 (2.86 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
18
namespace KCOM.Events
19
{
20
    public class UndoCommand
21
    {
22
        private static readonly UndoCommand _instance = new UndoCommand();
23
24
        // Explicit static constructor to tell C# compiler
25
        // not to mark type as beforefieldinit
26
        static UndoCommand()
27
        {
28
        }
29
30
        private UndoCommand()
31
        {
32
        }
33
34
        public static UndoCommand Instance
35
        {
36
            get
37
            {
38
                return _instance;
39
            }
40
        }
41
42
        /// <summary>
43
        /// push undo data
44
        /// </summary>
45
        /// <author>humkyung</author>
46
        /// <date>2019.06.14</date>
47
        /// <param name="comments"></param>
48
        public void Execute(ICollection<CommentUserInfo> comments, double dAngle)
49
        {
50
            List<Point> p_set = new List<Point>();
51
52
            Undo_data UndoData = new Undo_data()
53
            {
54
                IsUndo = false,
55
                Event = Event_Type.Thumb,
56
                EventTime = DateTime.Now,
57
                Markup_List = new List<Multi_Undo_data>(),
58
            };
59
60
            Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
61
62
            foreach (var comment in comments)
63
            {
64
                multi_Undo_Data.PointSet = new List<Point>();
65
                p_set = new List<Point>();
66
67
                if (comment is TextControl)
68
                {
69
                    multi_Undo_Data.PointSet.Add((comment as TextControl).StartPoint);
70
                    multi_Undo_Data.PointSet.Add((comment as TextControl).EndPoint);
71
                }
72
73
                foreach (var point in (comment as IPath).PointSet)
74
                {
75
                    multi_Undo_Data.PointSet.Add(point);
76
                }
77
78
                if (comment is ArrowTextControl)
79
                {
80
                    multi_Undo_Data.Angle = dAngle = (comment as ArrowTextControl).Angle;
81
                }
82
                else
83
                {
84
                    multi_Undo_Data.Angle = dAngle;
85
                }
86
87
                multi_Undo_Data.Markup = comment;
88
                UndoData.Markup_List.Add(multi_Undo_Data);
89
                multi_Undo_Data = new Multi_Undo_data();
90
            }
91
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
92
            {
93
                ViewerDataModel.Instance.UndoDataList.Remove(i);
94
            });
95
96
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
97
        }
98
    }
99
}
클립보드 이미지 추가 (최대 크기: 500 MB)