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