markus / MarkupToPDF / Common / CommentUserInfo.cs @ 0d00f9c8
이력 | 보기 | 이력해설 | 다운로드 (6.24 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 |
public virtual SolidColorBrush StrokeColor { get; set; } |
107 |
|
108 |
/// <summary> |
109 |
/// |
110 |
/// </summary> |
111 |
public virtual void ApplyOverViewData() { } |
112 |
|
113 |
/// <summary> |
114 |
/// subclass has to override this method |
115 |
/// </summary> |
116 |
/// <returns>serialized string</returns> |
117 |
public virtual string Serialize() { return string.Empty; } |
118 |
|
119 |
/// <summary> |
120 |
/// return MARKUP_DATA |
121 |
/// </summary> |
122 |
/// <param name="sUserID"></param> |
123 |
/// <param name="iPageNo"></param> |
124 |
/// <returns></returns> |
125 |
public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID) |
126 |
{ |
127 |
var root = MarkupParser.MarkupToString(this, sUserID); |
128 |
return new MARKUP_DATA |
129 |
{ |
130 |
ID = this.CommentID, |
131 |
DATA = root.ConvertData, |
132 |
DATA_TYPE = root.DATA_TYPE, |
133 |
PAGENUMBER = iPageNo, |
134 |
MARKUPINFO_VERSION_ID = sMarkupVersionID, |
135 |
SYMBOL_ID = this.SymbolID, |
136 |
//GROUP_ID = this.GroupID |
137 |
}; |
138 |
} |
139 |
|
140 |
/// <summary> |
141 |
/// return item's area |
142 |
/// </summary> |
143 |
public virtual Rect ItemRect |
144 |
{ |
145 |
get; |
146 |
} |
147 |
|
148 |
/// <summary> |
149 |
/// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산 |
150 |
/// </summary> |
151 |
/// <param name="StartP">StartPoint</param> |
152 |
/// <param name="EndP">EndPoint</param> |
153 |
/// <returns>Return_EndPoint</returns> |
154 |
public Point GetSquareEndPoint(Point StartP, Point EndP) |
155 |
{ |
156 |
Point? res = null; |
157 |
|
158 |
double dx = EndP.X - StartP.X; |
159 |
double dy = EndP.Y - StartP.Y; |
160 |
double length; |
161 |
|
162 |
switch (this.ControlType) |
163 |
{ |
164 |
case ControlType.Triangle: |
165 |
{ |
166 |
//삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요 |
167 |
length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy)); |
168 |
res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length); |
169 |
} |
170 |
break; |
171 |
default: |
172 |
{ |
173 |
length = Math.Max(Math.Abs(dx), Math.Abs(dy)); |
174 |
res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length); |
175 |
} |
176 |
break; |
177 |
} |
178 |
|
179 |
return res.Value; |
180 |
} |
181 |
} |
182 |
} |