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