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