Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Util\TipPainterTools.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
168
|
Highlight:
Uncovered Code
Covered Code
| L | V | Source |
|---|---|---|
1 |
// <file> |
|
2 |
// <copyright see="prj:///doc/copyright.txt"/> |
|
3 |
// <license see="prj:///doc/license.txt"/> |
|
4 |
// <owner name="none" email=""/> |
|
5 |
// <version>$Revision: 915 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
using System.Drawing; |
|
10 |
using System.Windows.Forms; |
|
11 |
||
12 |
namespace ICSharpCode.TextEditor.Util |
|
13 |
{ |
|
14 |
class TipPainterTools |
|
15 |
{ |
|
16 |
const int SpacerSize = 4; |
|
17 |
||
18 |
private TipPainterTools() |
|
19 |
{ |
|
20 |
||
21 |
} |
|
22 |
public static Size GetDrawingSizeHelpTipFromCombinedDescription(Control control, |
|
23 |
Graphics graphics, |
|
24 |
Font font, |
|
25 |
string countMessage, |
|
26 |
string description) |
|
27 |
{ |
|
28 |
string basicDescription = null; |
|
29 |
string documentation = null; |
|
30 |
||
31 |
if (IsVisibleText(description)) { |
|
32 |
string[] splitDescription = description.Split(new char[] { '\n' }, 2); |
|
33 |
||
34 |
if (splitDescription.Length > 0) { |
|
35 |
basicDescription = splitDescription[0]; |
|
36 |
||
37 |
if (splitDescription.Length > 1) { |
|
38 |
documentation = splitDescription[1].Trim(); |
|
39 |
} |
|
40 |
} |
|
41 |
} |
|
42 |
||
43 |
return GetDrawingSizeDrawHelpTip(control, graphics, font, countMessage, basicDescription, documentation); |
|
44 |
} |
|
45 |
||
46 |
public static Size DrawHelpTipFromCombinedDescription(Control control, |
|
47 |
Graphics graphics, |
|
48 |
Font font, |
|
49 |
string countMessage, |
|
50 |
string description) |
|
51 |
{ |
|
52 |
string basicDescription = null; |
|
53 |
string documentation = null; |
|
54 |
||
55 |
if (IsVisibleText(description)) { |
|
56 |
string[] splitDescription = description.Split |
|
57 |
(new char[] { '\n' }, 2); |
|
58 |
||
59 |
if (splitDescription.Length > 0) { |
|
60 |
basicDescription = splitDescription[0]; |
|
61 |
||
62 |
if (splitDescription.Length > 1) { |
|
63 |
documentation = splitDescription[1].Trim(); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
||
68 |
return DrawHelpTip(control, graphics, font, countMessage, |
|
69 |
basicDescription, documentation); |
|
70 |
} |
|
71 |
||
72 |
// btw. I know it's ugly. |
|
73 |
public static Rectangle DrawingRectangle1; |
|
74 |
public static Rectangle DrawingRectangle2; |
|
75 |
||
76 |
public static Size GetDrawingSizeDrawHelpTip(Control control, |
|
77 |
Graphics graphics, Font font, |
|
78 |
string countMessage, |
|
79 |
string basicDescription, |
|
80 |
string documentation) |
|
81 |
{ |
|
82 |
if (IsVisibleText(countMessage) || |
|
83 |
IsVisibleText(basicDescription) || |
|
84 |
IsVisibleText(documentation)) { |
|
85 |
// Create all the TipSection objects. |
|
86 |
CountTipText countMessageTip = new CountTipText(graphics, font, countMessage); |
|
87 |
||
88 |
TipSpacer countSpacer = new TipSpacer(graphics, new SizeF(IsVisibleText(countMessage) ? 4 : 0, 0)); |
|
89 |
||
90 |
TipText descriptionTip = new TipText(graphics, font, basicDescription); |
|
91 |
||
92 |
TipSpacer docSpacer = new TipSpacer(graphics, new SizeF(0, IsVisibleText(documentation) ? 4 : 0)); |
|
93 |
||
94 |
TipText docTip = new TipText(graphics, font, documentation); |
|
95 |
||
96 |
// Now put them together. |
|
97 |
TipSplitter descSplitter = new TipSplitter(graphics, false, |
|
98 |
descriptionTip, |
|
99 |
docSpacer |
|
100 |
); |
|
101 |
||
102 |
TipSplitter mainSplitter = new TipSplitter(graphics, true, |
|
103 |
countMessageTip, |
|
104 |
countSpacer, |
|
105 |
descSplitter); |
|
106 |
||
107 |
TipSplitter mainSplitter2 = new TipSplitter(graphics, false, |
|
108 |
mainSplitter, |
|
109 |
docTip); |
|
110 |
||
111 |
// Show it. |
|
112 |
Size size = TipPainter.GetTipSize(control, graphics, mainSplitter2); |
|
113 |
DrawingRectangle1 = countMessageTip.DrawingRectangle1; |
|
114 |
DrawingRectangle2 = countMessageTip.DrawingRectangle2; |
|
115 |
return size; |
|
116 |
} |
|
117 |
return Size.Empty; |
|
118 |
} |
|
119 |
public static Size DrawHelpTip(Control control, |
|
120 |
Graphics graphics, Font font, |
|
121 |
string countMessage, |
|
122 |
string basicDescription, |
|
123 |
string documentation) |
|
124 |
{ |
|
125 |
if (IsVisibleText(countMessage) || |
|
126 |
IsVisibleText(basicDescription) || |
|
127 |
IsVisibleText(documentation)) { |
|
128 |
// Create all the TipSection objects. |
|
129 |
CountTipText countMessageTip = new CountTipText(graphics, font, countMessage); |
|
130 |
||
131 |
TipSpacer countSpacer = new TipSpacer(graphics, new SizeF(IsVisibleText(countMessage) ? 4 : 0, 0)); |
|
132 |
||
133 |
TipText descriptionTip = new TipText(graphics, font, basicDescription); |
|
134 |
||
135 |
TipSpacer docSpacer = new TipSpacer(graphics, new SizeF(0, IsVisibleText(documentation) ? 4 : 0)); |
|
136 |
||
137 |
TipText docTip = new TipText(graphics, font, documentation); |
|
138 |
||
139 |
// Now put them together. |
|
140 |
TipSplitter descSplitter = new TipSplitter(graphics, false, |
|
141 |
descriptionTip, |
|
142 |
docSpacer |
|
143 |
); |
|
144 |
||
145 |
TipSplitter mainSplitter = new TipSplitter(graphics, true, |
|
146 |
countMessageTip, |
|
147 |
countSpacer, |
|
148 |
descSplitter); |
|
149 |
||
150 |
TipSplitter mainSplitter2 = new TipSplitter(graphics, false, |
|
151 |
mainSplitter, |
|
152 |
docTip); |
|
153 |
||
154 |
// Show it. |
|
155 |
Size size = TipPainter.DrawTip(control, graphics, mainSplitter2); |
|
156 |
DrawingRectangle1 = countMessageTip.DrawingRectangle1; |
|
157 |
DrawingRectangle2 = countMessageTip.DrawingRectangle2; |
|
158 |
return size; |
|
159 |
} |
|
160 |
return Size.Empty; |
|
161 |
} |
|
162 |
||
163 |
static bool IsVisibleText(string text) |
|
164 |
{ |
|
165 |
return text != null && text.Length > 0; |
|
166 |
} |
|
167 |
} |
|
168 |
} |