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