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