本文整理汇总了C#中FastColoredTextBox.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.Invalidate方法的具体用法?C# FastColoredTextBox.Invalidate怎么用?C# FastColoredTextBox.Invalidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.Invalidate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HighlightBrackets1
private static void HighlightBrackets1(FastColoredTextBox textbox, char LeftBracket, char RightBracket, ref Range leftBracketPosition, ref Range rightBracketPosition)
{
if (!textbox.Selection.IsEmpty)
return;
if (textbox.LinesCount == 0)
return;
//
Range oldLeftBracketPosition = leftBracketPosition;
Range oldRightBracketPosition = rightBracketPosition;
Range range = textbox.Selection.Clone(); //need clone because we will move caret
int counter = 0;
int maxIterations = FastColoredTextBox.MAX_BRACKET_SEARCH_ITERATIONS;
while (range.GoLeftThroughFolded()) //move caret left
{
if (range.CharAfterStart == LeftBracket) counter++;
if (range.CharAfterStart == RightBracket) counter--;
if (counter == 1)
{
//highlighting
range.End = new Place(range.Start.iChar + 1, range.Start.iLine);
leftBracketPosition = range;
break;
}
//
maxIterations--;
if (maxIterations <= 0) break;
}
//
range = textbox.Selection.Clone(); //need clone because we will move caret
counter = 0;
maxIterations = FastColoredTextBox.MAX_BRACKET_SEARCH_ITERATIONS;
do
{
if (range.CharAfterStart == LeftBracket) counter++;
if (range.CharAfterStart == RightBracket) counter--;
if (counter == -1)
{
//highlighting
range.End = new Place(range.Start.iChar + 1, range.Start.iLine);
rightBracketPosition = range;
break;
}
//
maxIterations--;
if (maxIterations <= 0) break;
} while (range.GoRightThroughFolded()); //move caret right
if (oldLeftBracketPosition != leftBracketPosition ||
oldRightBracketPosition != rightBracketPosition)
{
textbox.Invalidate();
}
}
示例2: CloseBindingFile
/// <summary>
/// Close file binding mode
/// </summary>
public static void CloseBindingFile(FastColoredTextBox textbox)
{
if (textbox.lines is FileTextSource)
{
var fts = textbox.lines as FileTextSource;
fts.CloseFile();
// show an empty file
textbox.InitTextSource(textbox.CreateTextSource());
textbox.lines.InsertLine(0, textbox.TextSource.CreateLine());
textbox.IsChanged = false;
textbox.Invalidate();
}
}
示例3: GifImageStyle
public GifImageStyle(FastColoredTextBox parent)
: base(null, null, FontStyle.Regular)
{
ImagesByText = new Dictionary<string, Image>();
this.parent = parent;
//create timer
timer = new System.Windows.Forms.Timer();
timer.Interval = 100;
timer.Tick += (EventHandler)delegate
{
ImageAnimator.UpdateFrames();
parent.Invalidate();
};
timer.Start();
}
示例4: OpenBindingFile
/// <summary>
/// Open file binding mode
/// </summary>
/// <param name="textbox"></param>
/// <param name="fileName"></param>
/// <param name="enc"></param>
public static void OpenBindingFile(FastColoredTextBox textbox, string fileName, Encoding enc)
{
var fts = new FileTextSource(textbox);
try
{
textbox.InitTextSource(fts);
fts.OpenFile(fileName, enc);
textbox.IsChanged = false;
textbox.OnVisibleRangeChanged();
}
catch
{
// failed, show an empty file
fts.CloseFile();
textbox.InitTextSource(textbox.CreateTextSource());
textbox.lines.InsertLine(0, textbox.TextSource.CreateLine());
textbox.IsChanged = false;
throw;
}
textbox.Invalidate();
}
示例5: GoRightBracket
void GoRightBracket(FastColoredTextBox tb, char leftBracket, char rightBracket)
{
var range = tb.Selection.Clone();//need clone because we will move caret
int counter = 0;
int maxIterations = maxBracketSearchIterations;
do
{
if (range.CharAfterStart == leftBracket) counter++;
if (range.CharAfterStart == rightBracket) counter--;
if (counter == -1)
{
//found
tb.Selection.Start = range.Start;
tb.Selection.GoRightThroughFolded();
tb.DoSelectionVisible();
break;
}
//
maxIterations--;
if (maxIterations <= 0) break;
} while (range.GoRightThroughFolded());//move caret right
tb.Invalidate();
}
示例6: PaintTextBox
void PaintTextBox( FastColoredTextBox target, List<Token> changes )
{
XManager<Token> XMT = new XManager<Token>( changes );
while ( !XMT.Eof ) {
try {
if ( XMT.X.Type == TokenType.Keyword ) {
target.VisibleRange.getRange( XMT.X.LineNum - 1, XMT.X.Pos - 1, 0, XMT.X.Length ).SetStyle( keywordStyle, false );
} else if ( XMT.X.Type == TokenType.Comment ) {
if ( XMT.X.Value.Contains( "\n" ) ) {
target.VisibleRange.getRange( XMT.X.LineNum - 1, XMT.X.Pos - 1,
XMT.X.Value.Split( '\n' ).GetLength( 0 ) - 1,
XMT.X.Length - XMT.X.Value.LastIndexOf( "\n" ) - 1 ).SetStyle( commentStyle, false );
target[ target.VisibleRange.Start.iLine + XMT.X.LineNum - 1 ].FoldingStartMarker = "/**/";
target[ target.VisibleRange.Start.iLine + XMT.X.LineNum - 2 + XMT.X.Value.Split( '\n' ).GetLength( 0 ) ].FoldingEndMarker = "/**/";
} else
target.VisibleRange.getRange( XMT.X.LineNum - 1, XMT.X.Pos - 1, 0, XMT.X.Length ).SetStyle( commentStyle, false );
} else if ( XMT.X.Type == TokenType.String || XMT.X.Type == TokenType.Integer ) {
target.VisibleRange.getRange( XMT.X.LineNum - 1, XMT.X.Pos - 1, 0, XMT.X.Length ).SetStyle( valueStyle, false );
} else if ( XMT.X.Type == TokenType.Symbol ) {
switch ( XMT.X.Value ) {
case "{":
target[ XMT.X.LineNum - 1 ].FoldingStartMarker = "{}";
break;
case "}":
target[ XMT.X.LineNum - 1 ].FoldingEndMarker = "{}";
break;
}
}
//else if ( Objects.IndexOf( XMT.X.Value ) != -1 )
// target.VisibleRange.getRange( XMT.X.LineNum - 1, XMT.X.Pos - 1, 0, XMT.X.Length ).SetStyle( objectStyle );
} catch {
//MessageBox.Show( "Caught Error: " + XMT[ XMT.Indexed ] );
}
XMT++;
}
target.Invalidate( );
}
示例7: GoLeftBracket
private void GoLeftBracket(FastColoredTextBox tb, char leftBracket, char rightBracket)
{
var range = tb.Selection.Clone(); //need to clone because we will move caret
var counter = 0;
var maxIterations = MaxBracketSearchIterations;
while (range.GoLeftThroughFolded()) //move caret left
{
if (range.CharAfterStart == leftBracket) counter++;
if (range.CharAfterStart == rightBracket) counter--;
if (counter == 1)
{
//found
tb.Selection.Start = range.Start;
tb.DoSelectionVisible();
break;
}
//
maxIterations--;
if (maxIterations <= 0) break;
}
tb.Invalidate();
}
示例8: DrawRecordingHint
internal static void DrawRecordingHint(Graphics graphics, FastColoredTextBox textbox)
{
const int w = 75;
const int h = 13;
var rect = new Rectangle(textbox.ClientRectangle.Right - w, textbox.ClientRectangle.Bottom - h, w, h);
var iconRect = new Rectangle(-h / 2 + 3, -h / 2 + 3, h - 7, h - 7);
var state = graphics.Save();
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TranslateTransform(rect.Left + h / 2, rect.Top + h / 2);
var ts = new TimeSpan(DateTime.Now.Ticks);
graphics.RotateTransform(180 * (DateTime.Now.Millisecond / 1000f));
using (var pen = new Pen(Color.Red, 2))
{
graphics.DrawArc(pen, iconRect, 0, 90);
graphics.DrawArc(pen, iconRect, 180, 90);
}
graphics.DrawEllipse(Pens.Red, iconRect);
graphics.Restore(state);
using (var font = new Font(FontFamily.GenericSansSerif, 8f))
graphics.DrawString("Recording...", font, Brushes.Red, new PointF(rect.Left + h, rect.Top));
System.Threading.Timer tm = null;
tm = new System.Threading.Timer(
(o) =>
{
textbox.Invalidate(rect);
tm.Dispose();
}, null, 200, System.Threading.Timeout.Infinite);
}