本文整理汇总了C#中FastColoredTextBox.AddHint方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.AddHint方法的具体用法?C# FastColoredTextBox.AddHint怎么用?C# FastColoredTextBox.AddHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.AddHint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetJavaCodeError
/// <summary>
/// Set Error marker on code for Java. returns True on success False otherwise.
/// </summary>
public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false)
{
try
{
//split data in parts separated by ':'
string data = message.Text;
string[] part = data.Split(new char[] { ':' });
//usually row and col is on first two parts
int row = int.Parse(part[0]) - 1; // <-- throws exception on failure
//check if rest of the data is not empty
string rest = string.Join(" ", part, 1, part.Length - 1);
if (rest.Trim().Length == 0) return false;
//get line by row number
string line = code.Lines[row].TrimEnd();
//get last of the message
Place stop = new Place(line.Length, row);
//we need to move start point where first non-space character found
int col = 0; while (col < line.Length && line[col] == ' ') ++col;
Place start = new Place(col, row);
//get range from start to stop
Range range = code.GetRange(start, stop);
//show zigzag lines under the errors
range.SetStyle(HighlightSyntax.LineErrorStyle);
//focus current and exit
if (focus)
{
code.ExpandBlock(row);
code.Selection = range;
code.DoRangeVisible(range, true);
}
// add hints
if (Properties.Settings.Default.EditorShowHints)
{
Hint hdat = code.AddHint(range, data, focus, true, true);
hdat.Tag = message;
hdat.BorderColor = Color.LightBlue;
hdat.BackColor = Color.AliceBlue;
hdat.BackColor2 = Color.PowderBlue;
}
return true;
}
catch { return false; }
}
示例2: SetCPPCodeError
/// <summary>
/// Set Error marker on code for C/C++. returns True on success False otherwise.
/// </summary>
public static bool SetCPPCodeError(FastColoredTextBox code, Range message, bool focus = false)
{
try
{
//split data in parts separated by ':'
string data = message.Text;
string[] part = data.Split(new char[] { ':' });
//usually row and col is on first two parts
int row, col;
row = int.Parse(part[0]) - 1; // <-- throws exception on failure
col = int.Parse(part[1]) - 1; // <-- throws exception on failure
//get the type of message : there can be one and only one of these types
bool error = Regex.IsMatch(data, " error:.*"); //check for error data type
bool warn = Regex.IsMatch(data, " warning:.*"); //check for warning data type
bool note = Regex.IsMatch(data, " note:.*"); //check for note data type
if (!(error || warn || note)) return false; //for c++ do not proceed if not valid type
//get line by row number
string line = code.Lines[row];
//get start the message
Place start = new Place(col, row);
//we need to cover the next word after start
while (col < line.Length && char.IsLetterOrDigit(line[col])) ++col;
//if no word of number is selected select all non-space chars instead
if (start.iChar == col) { while (col < line.Length && ' ' != line[col]) ++col; }
//now we found our stop position
Place stop = new Place(col, row);
//get range from start to stop
Range range = code.GetRange(start, stop);
//show zigzag lines under the errors
if (error) range.SetStyle(HighlightSyntax.LineErrorStyle);
else if (warn) range.SetStyle(HighlightSyntax.LineWarningStyle);
else if (note) range.SetStyle(HighlightSyntax.LineNoteStyle);
//focus current and exit
if (focus && error)
{
code.ExpandBlock(row);
code.Selection = range;
code.DoRangeVisible(range, true);
}
// add hints
if (Properties.Settings.Default.EditorShowHints && error)
{
Hint hdat = code.AddHint(range, data, focus, true, true);
hdat.Tag = message;
hdat.BackColor = Color.AliceBlue;
hdat.BackColor2 = Color.LightSkyBlue;
}
return true;
}
catch { return false; }
}