markus / MarkupToPDF / Common / CommentUserInfo.cs @ d2114d3b
이력 | 보기 | 이력해설 | 다운로드 (5.77 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 |
} |
19 |
|
20 |
public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo |
21 |
{ |
22 |
public static readonly string[] delimiterChars = { "|DZ|" }; |
23 |
public static readonly string[] delimiterChars2 = { "|" }; |
24 |
public static readonly SolidColorBrush DefaultColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("")); |
25 |
|
26 |
public string Memo { get; set; } |
27 |
public string MarkupInfoID { get; set; } |
28 |
public bool IsMouseOver { get; set; } |
29 |
public bool IsNew { get; set; } |
30 |
public string CommentID { get; set; } |
31 |
public string SymbolID { get; set; } |
32 |
public long GroupID { get; set; } |
33 |
|
34 |
private SolidColorBrush _TempBorderBrush { get; set; } |
35 |
private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255)); |
36 |
|
37 |
public CommentUserInfo() |
38 |
{ |
39 |
this.BorderThickness = new System.Windows.Thickness(20.0); |
40 |
this.MouseEnter += CommentUserInfo_MouseEnter; |
41 |
this.MouseLeave += CommentUserInfo_MouseLeave; |
42 |
} |
43 |
|
44 |
protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters) |
45 |
{ |
46 |
var temp = base.HitTestCore(hitTestParameters); |
47 |
return temp; |
48 |
} |
49 |
|
50 |
private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) |
51 |
{ |
52 |
this.IsMouseOver = false; |
53 |
if (this.StrokeColor != null) |
54 |
{ |
55 |
this.StrokeColor = this._TempBorderBrush; |
56 |
this.UpdateLayout(); |
57 |
} |
58 |
} |
59 |
|
60 |
private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
61 |
{ |
62 |
this.IsMouseOver = true; |
63 |
if (this.StrokeColor != null) |
64 |
{ |
65 |
this._TempBorderBrush = this.StrokeColor; |
66 |
this.StrokeColor = this._HoverBorderBrush; |
67 |
this.UpdateLayout(); |
68 |
} |
69 |
} |
70 |
|
71 |
public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { } |
72 |
public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { } |
73 |
|
74 |
/// <summary> |
75 |
/// subclass has to override this property |
76 |
/// </summary> |
77 |
public virtual bool IsSelected { get; set; } |
78 |
|
79 |
/// <summary> |
80 |
/// subclass has to override this property |
81 |
/// </summary> |
82 |
public virtual ControlType ControlType { get; set; } |
83 |
|
84 |
public virtual SolidColorBrush StrokeColor { get; set; } |
85 |
|
86 |
/// <summary> |
87 |
/// translate commeny by given dx, dy |
88 |
/// </summary> |
89 |
/// <param name="dx"></param> |
90 |
/// <param name="dy"></param> |
91 |
public virtual void Move(double dx, double dy) { } |
92 |
|
93 |
/// <summary> |
94 |
/// |
95 |
/// </summary> |
96 |
public virtual void ApplyOverViewData() { } |
97 |
|
98 |
/// <summary> |
99 |
/// subclass has to override this method |
100 |
/// </summary> |
101 |
/// <returns>serialized string</returns> |
102 |
public virtual string Serialize() { return string.Empty; } |
103 |
|
104 |
/// <summary> |
105 |
/// return MARKUP_DATA |
106 |
/// </summary> |
107 |
/// <param name="sUserID"></param> |
108 |
/// <param name="iPageNo"></param> |
109 |
/// <returns></returns> |
110 |
public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID) |
111 |
{ |
112 |
var root = MarkupParser.MarkupToString(this, sUserID); |
113 |
return new MARKUP_DATA |
114 |
{ |
115 |
ID = this.CommentID, |
116 |
DATA = root.ConvertData, |
117 |
DATA_TYPE = root.DATA_TYPE, |
118 |
PAGENUMBER = iPageNo, |
119 |
MARKUPINFO_VERSION_ID = sMarkupVersionID, |
120 |
SYMBOL_ID = this.SymbolID, |
121 |
//GROUP_ID = this.GroupID |
122 |
}; |
123 |
} |
124 |
|
125 |
/// <summary> |
126 |
/// return item's area |
127 |
/// </summary> |
128 |
public virtual Rect ItemRect |
129 |
{ |
130 |
get; |
131 |
} |
132 |
|
133 |
/// <summary> |
134 |
/// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산 |
135 |
/// </summary> |
136 |
/// <param name="StartP">StartPoint</param> |
137 |
/// <param name="EndP">EndPoint</param> |
138 |
/// <returns>Return_EndPoint</returns> |
139 |
public Point GetSquareEndPoint(Point StartP, Point EndP) |
140 |
{ |
141 |
Point? res = null; |
142 |
|
143 |
double dx = EndP.X - StartP.X; |
144 |
double dy = EndP.Y - StartP.Y; |
145 |
double length; |
146 |
|
147 |
switch (this.ControlType) |
148 |
{ |
149 |
case ControlType.Triangle: |
150 |
{ |
151 |
//삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요 |
152 |
length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy)); |
153 |
res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length); |
154 |
} |
155 |
break; |
156 |
default: |
157 |
{ |
158 |
length = Math.Max(Math.Abs(dx), Math.Abs(dy)); |
159 |
res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length); |
160 |
} |
161 |
break; |
162 |
} |
163 |
|
164 |
return res.Value; |
165 |
} |
166 |
} |
167 |
} |