本文整理汇总了C#中Range.GetFragment方法的典型用法代码示例。如果您正苦于以下问题:C# Range.GetFragment方法的具体用法?C# Range.GetFragment怎么用?C# Range.GetFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.GetFragment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnToolTip
//函数悬停提示
protected override void OnToolTip()
{
if (ToolTip == null)
return;
if (ToolTipNeeded == null)
return;
//get place under mouse
Place place = PointToPlace(lastMouseCoord);
//check distance
Point p = PlaceToPoint(place);
if (Math.Abs(p.X - lastMouseCoord.X) > CharWidth*2 ||
Math.Abs(p.Y - lastMouseCoord.Y) > CharHeight*2)
return;
//get word under mouse
var r = new Range(this, place, place);
string hoveredWord = r.GetFragment("[a-zA-Z0-9_]").Text;
//event handler
var ea = new ToolTipNeededEventArgs(place, hoveredWord);
ToolTipNeeded(this, ea);
if (ea.ToolTipText != null)
{
//show tooltip
ToolTip.ToolTipTitle = ea.ToolTipTitle;
ToolTip.ToolTipIcon = ea.ToolTipIcon;
//ToolTip.SetToolTip(this, ea.ToolTipText);
ToolTip.Show(ea.ToolTipText, this, new Point(lastMouseCoord.X, lastMouseCoord.Y + CharHeight));
}
}
示例2: fastColoredTextBox_Code_ToolTipNeeded
private void fastColoredTextBox_Code_ToolTipNeeded(object aSender, ToolTipNeededEventArgs aEventArgs)
{
var lRange = new Range(aSender as FastColoredTextBox, aEventArgs.Place, aEventArgs.Place);
try
{
int lHandle = mBrowser.getItemHandleByName(lRange.GetFragment("[^\n ']").Text);
if (lHandle != -1)
{
aEventArgs.ToolTipText = mBrowser.getItemToolTipByHandle(lHandle);
}
}
catch { }
}
示例3: DoHighlighting
protected virtual void DoHighlighting()
{
if (parser == null)
return;
//parse text
ParseTree tree;
try
{
tree = parser.Parse(Text);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message); //oops...
return;
}
//highlight errors
if (tree.Status == ParseTreeStatus.Error)
{
ClearStyle(GetStyleIndexMask(new[] {WavyStyle}));
foreach (var msg in tree.ParserMessages)
{
var loc = msg.Location;
var place = new Place(loc.Column, loc.Line);
var r = new Range(this, place, place);
var f = r.GetFragment(@"[\S]");
f.SetStyle(WavyStyle);
}
return;
}
//highlight syntax
ClearStyle(StyleIndex.All);
foreach (var t in tree.Tokens)
{
var arg = new StyleNeededEventArgs(t);
OnStyleNeeded(arg);
if (arg.Cancel)
continue;
if (arg.Style != null)
{
GetTokenRange(t).SetStyle(arg.Style);
continue;
}
switch (t.Terminal.GetType().Name)
{
case "KeyTerm":
if ((t.Terminal.Flags & TermFlags.IsKeyword) != 0) //keywords are highlighted only
GetTokenRange(t).SetStyle(SyntaxHighlighter.KeywordStyle);
break;
case "NumberLiteral":
GetTokenRange(t).SetStyle(SyntaxHighlighter.NumberStyle);
break;
case "StringLiteral":
GetTokenRange(t).SetStyle(SyntaxHighlighter.StringStyle);
break;
case "CommentTerminal":
GetTokenRange(t).SetStyle(SyntaxHighlighter.CommentStyle);
break;
}
}
}
示例4: tb_MouseMove
private void tb_MouseMove(object sender, MouseEventArgs e)
{
var tb = sender as FastColoredTextBox;
var place = tb.PointToPlace(e.Location);
var r = new Range(tb, place, place);
string text = r.GetFragment("[\\(\\)a-zA-Z_0-9]").Text;
int result = 0;
if (text.Length > 0 && !int.TryParse(text, out result) && !(text[0] == '(') && !(text[text.Length - 1] == ')'))
{
List<Style> stls = tb.GetStylesOfChar(place);
int x = stls.FindIndex(p => p == tb.SyntaxHighlighter.styScpComments);
if (x > 0)
return;
toolStripStatusLabel1.Text = text;
}
else
{
toolStripStatusLabel1.Text = "";
}
}
示例5: CurrentWord
private string CurrentWord()
{
Range r = new Range(Editor, Editor.Selection.Start, Editor.Selection.Start);
r = r.GetFragment(@"[\w]");
if (Editor.SyntaxHighlighter.IsCommentOrString(r)) return "";
return r.Text;
}