프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ 9f55b953

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