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