Introduction
I like the snippet manager written by Tim Sneath, but when I use it and have a lot of code snippets, I only can see the title of my snippet and cannot remember, what is its content. So I added the functionality of a tooltip which provides me the contents. The tooltip is limited to 24 lines.
Using the Code
I only added a simple method to SnippetUI.cs, which receives a control and a message text as arguments and attaches a tooltip to the control.
private void CreateToolTipForControl(Control ctl, String msg)
{
String[] lines = msg.Split(new char[] {'\u000D'});
StringBuilder sb = new StringBuilder();
int lineCount = lines.Length;
if (lineCount > 24)
{
lineCount = 24;
}
for (int i = 0; i < lineCount; i++)
{
char tab = '\u0009';
char lf = '\u000A';
String line = lines[i].Replace(tab.ToString(), " ");
line = line.Replace(lf.ToString(), "");
sb.Append(line + "\n");
}
if (lines.Length > lineCount)
{
sb.Append("...");
}
toolTip1.SetToolTip(ctl, sb.ToString());
}
This method is called everytime the toolwindow
synchronizes its contents.
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.