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