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