프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ fa48eb85

이력 | 보기 | 이력해설 | 다운로드 (7.48 KB)

1 cb33ad14 humkyung
using KCOMDataModel.DataModel;
2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Parsing;
4 036650a0 humkyung
using System;
5 787a4489 KangIngu
using System.Collections.Generic;
6
using System.Linq;
7
using System.Text;
8 91efe37a humkyung
using System.Windows;
9 a6272c57 humkyung
using System.Windows.Input;
10 787a4489 KangIngu
using System.Windows.Media;
11
12
namespace MarkupToPDF.Common
13
{
14 a6272c57 humkyung
    public interface ICommentUserInfo
15
    {
16
        void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed);
17 d2114d3b humkyung
        void OnMoveCtrlPoint(Point pt, double dx, double dy);
18 0d00f9c8 humkyung
        void OnTranslate(double dx, double dy);
19
        void UpdateControl();
20 a6272c57 humkyung
    }
21
22
    public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo
23 787a4489 KangIngu
    {
24 661b7416 humkyung
        public static readonly string[] delimiterChars = { "|DZ|" };
25
        public static readonly string[] delimiterChars2 = { "|" };
26
        public static readonly SolidColorBrush DefaultColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse(""));
27
28 787a4489 KangIngu
        public string Memo { get; set; }
29
        public string MarkupInfoID { get; set; }
30 05009a0e ljiyeon
        public bool IsMouseOver { get; set; }
31 787a4489 KangIngu
        public bool IsNew { get; set; }
32
        public string CommentID { get; set; }
33 c8e9b3e4 ljiyeon
        public string SymbolID { get; set; }
34 53880c83 ljiyeon
        public long GroupID { get; set; }
35 787a4489 KangIngu
36 4913851c humkyung
        private SolidColorBrush _TempBorderBrush { get; set; }
37
        private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255));
38 787a4489 KangIngu
39
        public CommentUserInfo()
40
        {
41
            this.BorderThickness = new System.Windows.Thickness(20.0);
42
            this.MouseEnter += CommentUserInfo_MouseEnter;
43
            this.MouseLeave += CommentUserInfo_MouseLeave;
44
        }
45
46
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
47
        {
48
            var temp = base.HitTestCore(hitTestParameters);
49
            return temp;
50
        }
51
52
        private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
53
        {
54 05009a0e ljiyeon
            this.IsMouseOver = false;
55 4913851c humkyung
            if (this.StrokeColor != null)
56
            {
57
                this.StrokeColor = this._TempBorderBrush;
58
                this.UpdateLayout();
59
            }
60 787a4489 KangIngu
        }
61
62
        private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
63
        {
64 05009a0e ljiyeon
            this.IsMouseOver = true;
65 4913851c humkyung
            if (this.StrokeColor != null)
66
            {
67
                this._TempBorderBrush = this.StrokeColor;
68
                this.StrokeColor = this._HoverBorderBrush;
69
                this.UpdateLayout();
70
            }
71 787a4489 KangIngu
        }
72 036650a0 humkyung
73 a6272c57 humkyung
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { }
74 d2114d3b humkyung
        public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { }
75 a6272c57 humkyung
76 036650a0 humkyung
        /// <summary>
77 0d00f9c8 humkyung
        /// translate control along given dx,dy
78
        /// </summary>
79
        /// <param name="dx"></param>
80
        /// <param name="dy"></param>
81
        public virtual void OnTranslate(double dx, double dy)
82
        {
83
            var path = (this as IPath);
84 fa48eb85 taeseongkim
            for (int i = 0; i < path.PointSet.Count; ++i)
85 0d00f9c8 humkyung
            {
86
                path.PointSet[i] = new Point(path.PointSet[i].X + dx, path.PointSet[i].Y + dy);
87
            }
88
            this.UpdateControl();
89
        }
90
91
        /// <summary>
92
        /// update control
93
        /// </summary>
94
        public virtual void UpdateControl() { }
95
96
        /// <summary>
97 036650a0 humkyung
        /// subclass has to override this property
98
        /// </summary>
99 91efe37a humkyung
        public virtual bool IsSelected { get; set; }
100 959b3ef2 humkyung
101
        /// <summary>
102
        /// subclass has to override this property
103
        /// </summary>
104
        public virtual ControlType ControlType { get; set; }
105 036650a0 humkyung
106 fa48eb85 taeseongkim
        private double _CommentAngle;
107
108 554aae3b humkyung
        /// <summary>
109 fa48eb85 taeseongkim
        /// 컨트롤의 ANGLE
110
        /// </summary>
111
        public virtual double CommentAngle
112
        {
113
            get { return _CommentAngle; }
114
            set
115
            {
116
                _CommentAngle = value;
117
                System.Diagnostics.Debug.WriteLine($"CommentInfo CommentAngle {value}");
118
            }
119
        }
120
121
        private double _PageAngle;
122
123
        /// <summary>
124
        /// 실제 저장된 Page의 ANGLE
125
        /// DB에 저장됨
126
        /// </summary>
127
        public virtual double PageAngle
128
        {
129
            get { return _PageAngle; }
130
            set
131
            {
132
                _PageAngle = value;
133
                System.Diagnostics.Debug.WriteLine($"CommentInfo PageAngle {value}");
134
            }
135
        }
136
137
        private double _VisualPageAngle;
138
139
        /// <summary>
140
        /// Display되는 Page의 ANGLE
141
        /// PageAngle에서 변형됨
142 554aae3b humkyung
        /// </summary>
143 fa48eb85 taeseongkim
        public virtual double VisualPageAngle
144
        {
145
            get { return _VisualPageAngle; }
146
            set
147
            {
148
                _VisualPageAngle = value;
149
                //System.Diagnostics.Debug.WriteLine($"CommentInfo VisualPageAngle {value}");
150
            }
151
        }
152 554aae3b humkyung
153 4913851c humkyung
        public virtual SolidColorBrush StrokeColor { get; set; }
154
155 036650a0 humkyung
        /// <summary>
156 f513c215 humkyung
        /// 
157
        /// </summary>
158
        public virtual void ApplyOverViewData() { }
159
160
        /// <summary>
161 036650a0 humkyung
        /// subclass has to override this method
162
        /// </summary>
163
        /// <returns>serialized string</returns>
164
        public virtual string Serialize() { return string.Empty; }
165 cb33ad14 humkyung
166
        /// <summary>
167
        /// return MARKUP_DATA
168
        /// </summary>
169
        /// <param name="sUserID"></param>
170
        /// <param name="iPageNo"></param>
171
        /// <returns></returns>
172
        public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID)
173
        {
174
            var root = MarkupParser.MarkupToString(this, sUserID);
175
            return new MARKUP_DATA
176
            {
177
                ID = this.CommentID,
178
                DATA = root.ConvertData,
179
                DATA_TYPE = root.DATA_TYPE,
180
                PAGENUMBER = iPageNo,
181
                MARKUPINFO_VERSION_ID = sMarkupVersionID,
182
                SYMBOL_ID = this.SymbolID,
183 c0977e97 djkim
                //GROUP_ID = this.GroupID
184 cb33ad14 humkyung
            };
185
        }
186 91efe37a humkyung
187
        /// <summary>
188
        /// return item's area
189
        /// </summary>
190
        public virtual Rect ItemRect
191
        {
192
            get;
193
        }
194 a6272c57 humkyung
195
        /// <summary>
196
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
197
        /// </summary>
198
        /// <param name="StartP">StartPoint</param>
199
        /// <param name="EndP">EndPoint</param>
200
        /// <returns>Return_EndPoint</returns>
201
        public Point GetSquareEndPoint(Point StartP, Point EndP)
202
        {
203
            Point? res = null;
204
205
            double dx = EndP.X - StartP.X;
206
            double dy = EndP.Y - StartP.Y;
207
            double length;
208
209
            switch (this.ControlType)
210
            {
211
                case ControlType.Triangle:
212
                    {
213
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
214
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
215
                        res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
216
                    }
217
                    break;
218
                default:
219
                    {
220
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
221
                        res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length);
222
                    }
223
                    break;
224
            }
225
226
            return res.Value;
227
        }
228 787a4489 KangIngu
    }
229
}
클립보드 이미지 추가 (최대 크기: 500 MB)