markus / MarkupToPDF / Common / CommentUserInfo.cs @ 81173d69
이력 | 보기 | 이력해설 | 다운로드 (6.38 KB)
1 | cb33ad14 | humkyung | using KCOMDataModel.DataModel; |
---|---|---|---|
2 | using MarkupToPDF.Controls.Common; |
||
3 | using MarkupToPDF.Controls.Parsing; |
||
4 | 036650a0 | humkyung | using System; |
5 | 787a4489 | KangIngu | using System.Collections.Generic; |
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | 91efe37a | humkyung | using System.Windows; |
9 | a6272c57 | humkyung | using System.Windows.Input; |
10 | 787a4489 | KangIngu | using System.Windows.Media; |
11 | |||
12 | namespace MarkupToPDF.Common |
||
13 | { |
||
14 | a6272c57 | humkyung | public interface ICommentUserInfo |
15 | { |
||
16 | void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed); |
||
17 | d2114d3b | humkyung | void OnMoveCtrlPoint(Point pt, double dx, double dy); |
18 | 0d00f9c8 | humkyung | void OnTranslate(double dx, double dy); |
19 | void UpdateControl(); |
||
20 | a6272c57 | humkyung | } |
21 | |||
22 | public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo |
||
23 | 787a4489 | KangIngu | { |
24 | 661b7416 | humkyung | 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 | 787a4489 | KangIngu | public string Memo { get; set; } |
29 | public string MarkupInfoID { get; set; } |
||
30 | 05009a0e | ljiyeon | public bool IsMouseOver { get; set; } |
31 | 787a4489 | KangIngu | public bool IsNew { get; set; } |
32 | public string CommentID { get; set; } |
||
33 | c8e9b3e4 | ljiyeon | public string SymbolID { get; set; } |
34 | 53880c83 | ljiyeon | public long GroupID { get; set; } |
35 | 787a4489 | KangIngu | |
36 | 4913851c | humkyung | private SolidColorBrush _TempBorderBrush { get; set; } |
37 | private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255)); |
||
38 | 787a4489 | KangIngu | |
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 | 05009a0e | ljiyeon | this.IsMouseOver = false; |
55 | 4913851c | humkyung | if (this.StrokeColor != null) |
56 | { |
||
57 | this.StrokeColor = this._TempBorderBrush; |
||
58 | this.UpdateLayout(); |
||
59 | } |
||
60 | 787a4489 | KangIngu | } |
61 | |||
62 | private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
||
63 | { |
||
64 | 05009a0e | ljiyeon | this.IsMouseOver = true; |
65 | 4913851c | humkyung | if (this.StrokeColor != null) |
66 | { |
||
67 | this._TempBorderBrush = this.StrokeColor; |
||
68 | this.StrokeColor = this._HoverBorderBrush; |
||
69 | this.UpdateLayout(); |
||
70 | } |
||
71 | 787a4489 | KangIngu | } |
72 | 036650a0 | humkyung | |
73 | a6272c57 | humkyung | public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { } |
74 | d2114d3b | humkyung | public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { } |
75 | a6272c57 | humkyung | |
76 | 036650a0 | humkyung | /// <summary> |
77 | 0d00f9c8 | humkyung | /// 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 | 8771edc4 | humkyung | for(int i=0; i < path.PointSet.Count;++i) |
85 | 0d00f9c8 | humkyung | { |
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 | 036650a0 | humkyung | /// subclass has to override this property |
98 | /// </summary> |
||
99 | 91efe37a | humkyung | public virtual bool IsSelected { get; set; } |
100 | 959b3ef2 | humkyung | |
101 | /// <summary> |
||
102 | /// subclass has to override this property |
||
103 | /// </summary> |
||
104 | public virtual ControlType ControlType { get; set; } |
||
105 | 036650a0 | humkyung | |
106 | 554aae3b | humkyung | /// <summary> |
107 | /// subclass has to override this property |
||
108 | /// </summary> |
||
109 | public virtual double Angle { get; set; } |
||
110 | |||
111 | 4913851c | humkyung | public virtual SolidColorBrush StrokeColor { get; set; } |
112 | |||
113 | 036650a0 | humkyung | /// <summary> |
114 | f513c215 | humkyung | /// |
115 | /// </summary> |
||
116 | public virtual void ApplyOverViewData() { } |
||
117 | |||
118 | /// <summary> |
||
119 | 036650a0 | humkyung | /// subclass has to override this method |
120 | /// </summary> |
||
121 | /// <returns>serialized string</returns> |
||
122 | public virtual string Serialize() { return string.Empty; } |
||
123 | cb33ad14 | humkyung | |
124 | /// <summary> |
||
125 | /// return MARKUP_DATA |
||
126 | /// </summary> |
||
127 | /// <param name="sUserID"></param> |
||
128 | /// <param name="iPageNo"></param> |
||
129 | /// <returns></returns> |
||
130 | public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID) |
||
131 | { |
||
132 | var root = MarkupParser.MarkupToString(this, sUserID); |
||
133 | return new MARKUP_DATA |
||
134 | { |
||
135 | ID = this.CommentID, |
||
136 | DATA = root.ConvertData, |
||
137 | DATA_TYPE = root.DATA_TYPE, |
||
138 | PAGENUMBER = iPageNo, |
||
139 | MARKUPINFO_VERSION_ID = sMarkupVersionID, |
||
140 | SYMBOL_ID = this.SymbolID, |
||
141 | c0977e97 | djkim | //GROUP_ID = this.GroupID |
142 | cb33ad14 | humkyung | }; |
143 | } |
||
144 | 91efe37a | humkyung | |
145 | /// <summary> |
||
146 | /// return item's area |
||
147 | /// </summary> |
||
148 | public virtual Rect ItemRect |
||
149 | { |
||
150 | get; |
||
151 | } |
||
152 | a6272c57 | humkyung | |
153 | /// <summary> |
||
154 | /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산 |
||
155 | /// </summary> |
||
156 | /// <param name="StartP">StartPoint</param> |
||
157 | /// <param name="EndP">EndPoint</param> |
||
158 | /// <returns>Return_EndPoint</returns> |
||
159 | public Point GetSquareEndPoint(Point StartP, Point EndP) |
||
160 | { |
||
161 | Point? res = null; |
||
162 | |||
163 | double dx = EndP.X - StartP.X; |
||
164 | double dy = EndP.Y - StartP.Y; |
||
165 | double length; |
||
166 | |||
167 | switch (this.ControlType) |
||
168 | { |
||
169 | case ControlType.Triangle: |
||
170 | { |
||
171 | //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요 |
||
172 | length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy)); |
||
173 | res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length); |
||
174 | } |
||
175 | break; |
||
176 | default: |
||
177 | { |
||
178 | length = Math.Max(Math.Abs(dx), Math.Abs(dy)); |
||
179 | res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length); |
||
180 | } |
||
181 | break; |
||
182 | } |
||
183 | |||
184 | return res.Value; |
||
185 | } |
||
186 | 787a4489 | KangIngu | } |
187 | } |