markus / MarkupToPDF / Common / CommentUserInfo.cs @ d2114d3b
이력 | 보기 | 이력해설 | 다운로드 (5.77 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 | a6272c57 | humkyung | } |
19 | |||
20 | public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo |
||
21 | 787a4489 | KangIngu | { |
22 | 661b7416 | humkyung | 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 | 787a4489 | KangIngu | public string Memo { get; set; } |
27 | public string MarkupInfoID { get; set; } |
||
28 | 05009a0e | ljiyeon | public bool IsMouseOver { get; set; } |
29 | 787a4489 | KangIngu | public bool IsNew { get; set; } |
30 | public string CommentID { get; set; } |
||
31 | c8e9b3e4 | ljiyeon | public string SymbolID { get; set; } |
32 | 53880c83 | ljiyeon | public long GroupID { get; set; } |
33 | 787a4489 | KangIngu | |
34 | 4913851c | humkyung | private SolidColorBrush _TempBorderBrush { get; set; } |
35 | private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255)); |
||
36 | 787a4489 | KangIngu | |
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 | 05009a0e | ljiyeon | this.IsMouseOver = false; |
53 | 4913851c | humkyung | if (this.StrokeColor != null) |
54 | { |
||
55 | this.StrokeColor = this._TempBorderBrush; |
||
56 | this.UpdateLayout(); |
||
57 | } |
||
58 | 787a4489 | KangIngu | } |
59 | |||
60 | private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
||
61 | { |
||
62 | 05009a0e | ljiyeon | this.IsMouseOver = true; |
63 | 4913851c | humkyung | if (this.StrokeColor != null) |
64 | { |
||
65 | this._TempBorderBrush = this.StrokeColor; |
||
66 | this.StrokeColor = this._HoverBorderBrush; |
||
67 | this.UpdateLayout(); |
||
68 | } |
||
69 | 787a4489 | KangIngu | } |
70 | 036650a0 | humkyung | |
71 | a6272c57 | humkyung | public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { } |
72 | d2114d3b | humkyung | public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { } |
73 | a6272c57 | humkyung | |
74 | 036650a0 | humkyung | /// <summary> |
75 | /// subclass has to override this property |
||
76 | /// </summary> |
||
77 | 91efe37a | humkyung | public virtual bool IsSelected { get; set; } |
78 | 959b3ef2 | humkyung | |
79 | /// <summary> |
||
80 | /// subclass has to override this property |
||
81 | /// </summary> |
||
82 | public virtual ControlType ControlType { get; set; } |
||
83 | 036650a0 | humkyung | |
84 | 4913851c | humkyung | public virtual SolidColorBrush StrokeColor { get; set; } |
85 | |||
86 | 036650a0 | humkyung | /// <summary> |
87 | e6a9ddaf | humkyung | /// 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 | f513c215 | humkyung | /// |
95 | /// </summary> |
||
96 | public virtual void ApplyOverViewData() { } |
||
97 | |||
98 | /// <summary> |
||
99 | 036650a0 | humkyung | /// subclass has to override this method |
100 | /// </summary> |
||
101 | /// <returns>serialized string</returns> |
||
102 | public virtual string Serialize() { return string.Empty; } |
||
103 | cb33ad14 | humkyung | |
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 | c0977e97 | djkim | //GROUP_ID = this.GroupID |
122 | cb33ad14 | humkyung | }; |
123 | } |
||
124 | 91efe37a | humkyung | |
125 | /// <summary> |
||
126 | /// return item's area |
||
127 | /// </summary> |
||
128 | public virtual Rect ItemRect |
||
129 | { |
||
130 | get; |
||
131 | } |
||
132 | a6272c57 | humkyung | |
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 | 787a4489 | KangIngu | } |
167 | } |