markus / MarkupToPDF / Common / CommentUserInfo.cs @ 52b1f175
이력 | 보기 | 이력해설 | 다운로드 (8.54 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 const int MaxZIndex = 99; |
30 |
|
31 |
public string Memo { get; set; } |
32 |
public string MarkupInfoID { get; set; } |
33 |
public bool IsMouseEnter { get; set; } |
34 |
public bool IsNew { get; set; } |
35 |
public string CommentID { get; set; } |
36 |
public string SymbolID { get; set; } |
37 |
public string GroupID { get; set; } |
38 |
|
39 |
[Description("ZIndex 값이 높을 수록 앞쪽으로 배치된다.")] |
40 |
public int ZIndex { get; set; } = 10; |
41 |
|
42 |
/// <summary> |
43 |
/// 리스트 인덱스 |
44 |
/// </summary> |
45 |
[Description("리스트 인덱스")] |
46 |
public int Index { get; set; } |
47 |
|
48 |
private SolidColorBrush _TempBorderBrush { get; set; } |
49 |
private SolidColorBrush _HoverBorderBrush { get; } = new SolidColorBrush(Color.FromRgb(255, 0, 255)); |
50 |
|
51 |
public CommentUserInfo() |
52 |
{ |
53 |
Load(); |
54 |
} |
55 |
|
56 |
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 |
public void Load() |
60 |
{ |
61 |
this.IsHitTestVisible = true; |
62 |
|
63 |
this.SetValue(Telerik.Windows.Controls.TabNavigationExtensions.IsTabStopProperty, false); |
64 |
this.BorderThickness = new System.Windows.Thickness(20.0); |
65 |
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 |
System.Diagnostics.Debug.WriteLine("Is Mouse Leave."); |
78 |
|
79 |
this.IsMouseEnter = false; |
80 |
if (this.StrokeColor != this._TempBorderBrush) |
81 |
{ |
82 |
this.StrokeColor = this._TempBorderBrush; |
83 |
this.UpdateLayout(); |
84 |
} |
85 |
} |
86 |
|
87 |
private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
88 |
{ |
89 |
this.IsMouseEnter = true; |
90 |
System.Diagnostics.Debug.WriteLine("Is Mouse Enter."); |
91 |
OnMouseHover(); |
92 |
} |
93 |
|
94 |
public void OnMouseHover() |
95 |
{ |
96 |
if (this.StrokeColor != this._HoverBorderBrush) |
97 |
{ |
98 |
this._TempBorderBrush = this.StrokeColor; |
99 |
this.StrokeColor = this._HoverBorderBrush; |
100 |
this.UpdateLayout(); |
101 |
} |
102 |
} |
103 |
|
104 |
public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked) { } |
105 |
public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) { } |
106 |
|
107 |
/// <summary> |
108 |
/// 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 |
for (int i = 0; i < path.PointSet.Count; ++i) |
116 |
{ |
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 |
/// subclass has to override this property |
129 |
/// </summary> |
130 |
public virtual bool IsSelected { get; set; } |
131 |
|
132 |
/// <summary> |
133 |
/// subclass has to override this property |
134 |
/// </summary> |
135 |
public virtual ControlType ControlType { get; set; } |
136 |
|
137 |
private double _CommentAngle; |
138 |
|
139 |
/// <summary> |
140 |
/// 컨트롤의 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 |
/// </summary> |
174 |
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 |
|
184 |
public virtual SolidColorBrush StrokeColor { get; set; } |
185 |
|
186 |
/// <summary> |
187 |
/// |
188 |
/// </summary> |
189 |
public virtual void ApplyOverViewData() { } |
190 |
|
191 |
/// <summary> |
192 |
/// subclass has to override this method |
193 |
/// </summary> |
194 |
/// <returns>serialized string</returns> |
195 |
public virtual string Serialize() { return string.Empty; } |
196 |
|
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 |
//GROUP_ID = this.GroupID |
215 |
}; |
216 |
} |
217 |
|
218 |
/// <summary> |
219 |
/// return item's area |
220 |
/// </summary> |
221 |
public virtual Rect ItemRect |
222 |
{ |
223 |
get; |
224 |
} |
225 |
|
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 |
} |
260 |
} |