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