markus / MarkupToPDF / Common / CommentUserInfo.cs @ ef7ba61f
이력 | 보기 | 이력해설 | 다운로드 (8.42 KB)
1 |
using KCOMDataModel.DataModel; |
---|---|
2 |
using MarkupToPDF.Controls.Common; |
3 |
using MarkupToPDF.Controls.Parsing; |
4 |
using System; |
5 |
using System.Collections.Generic; |
6 |
using System.ComponentModel; |
7 |
using System.Linq; |
8 |
using System.Text; |
9 |
using System.Windows; |
10 |
using System.Windows.Input; |
11 |
using System.Windows.Media; |
12 |
|
13 |
namespace MarkupToPDF.Common |
14 |
{ |
15 |
public interface ICommentUserInfo |
16 |
{ |
17 |
void OnCreatingMouseMove(Point pt, bool bAxisLocked); |
18 |
void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false); |
19 |
void OnTranslate(double dx, double dy); |
20 |
void UpdateControl(); |
21 |
} |
22 |
|
23 |
public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo |
24 |
{ |
25 |
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 |
public string Memo { get; set; } |
30 |
public string MarkupInfoID { get; set; } |
31 |
public bool IsMouseEnter { get; set; } |
32 |
public bool IsNew { get; set; } |
33 |
public string CommentID { get; set; } |
34 |
public string SymbolID { get; set; } |
35 |
public long GroupID { get; set; } |
36 |
|
37 |
[Description("ZIndex 값이 높을 수록 앞쪽으로 배치된다.")] |
38 |
public int ZIndex { get; set; } = 10; |
39 |
|
40 |
[Description("리스트 인덱스")] |
41 |
public int Index { get; set; } |
42 |
|
43 |
private SolidColorBrush _TempBorderBrush { get; set; } |
44 |
private SolidColorBrush _HoverBorderBrush { get; } = new SolidColorBrush(Color.FromRgb(255, 0, 255)); |
45 |
|
46 |
public CommentUserInfo() |
47 |
{ |
48 |
Load(); |
49 |
} |
50 |
|
51 |
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 |
public void Load() |
55 |
{ |
56 |
this.IsHitTestVisible = true; |
57 |
|
58 |
this.SetValue(Telerik.Windows.Controls.TabNavigationExtensions.IsTabStopProperty, false); |
59 |
this.BorderThickness = new System.Windows.Thickness(20.0); |
60 |
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 |
System.Diagnostics.Debug.WriteLine("Is Mouse Leave."); |
73 |
|
74 |
this.IsMouseEnter = false; |
75 |
if (this.StrokeColor != this._TempBorderBrush) |
76 |
{ |
77 |
this.StrokeColor = this._TempBorderBrush; |
78 |
this.UpdateLayout(); |
79 |
} |
80 |
} |
81 |
|
82 |
private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
83 |
{ |
84 |
this.IsMouseEnter = true; |
85 |
System.Diagnostics.Debug.WriteLine("Is Mouse Enter."); |
86 |
OnMouseHover(); |
87 |
} |
88 |
|
89 |
public void OnMouseHover() |
90 |
{ |
91 |
if (this.StrokeColor != this._HoverBorderBrush) |
92 |
{ |
93 |
this._TempBorderBrush = this.StrokeColor; |
94 |
this.StrokeColor = this._HoverBorderBrush; |
95 |
this.UpdateLayout(); |
96 |
} |
97 |
} |
98 |
|
99 |
public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked) { } |
100 |
public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) { } |
101 |
|
102 |
/// <summary> |
103 |
/// 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 |
for (int i = 0; i < path.PointSet.Count; ++i) |
111 |
{ |
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 |
/// subclass has to override this property |
124 |
/// </summary> |
125 |
public virtual bool IsSelected { get; set; } |
126 |
|
127 |
/// <summary> |
128 |
/// subclass has to override this property |
129 |
/// </summary> |
130 |
public virtual ControlType ControlType { get; set; } |
131 |
|
132 |
private double _CommentAngle; |
133 |
|
134 |
/// <summary> |
135 |
/// 컨트롤의 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 |
/// </summary> |
169 |
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 |
|
179 |
public virtual SolidColorBrush StrokeColor { get; set; } |
180 |
|
181 |
/// <summary> |
182 |
/// |
183 |
/// </summary> |
184 |
public virtual void ApplyOverViewData() { } |
185 |
|
186 |
/// <summary> |
187 |
/// subclass has to override this method |
188 |
/// </summary> |
189 |
/// <returns>serialized string</returns> |
190 |
public virtual string Serialize() { return string.Empty; } |
191 |
|
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 |
//GROUP_ID = this.GroupID |
210 |
}; |
211 |
} |
212 |
|
213 |
/// <summary> |
214 |
/// return item's area |
215 |
/// </summary> |
216 |
public virtual Rect ItemRect |
217 |
{ |
218 |
get; |
219 |
} |
220 |
|
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 |
} |
255 |
} |