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