本文整理汇总了C#中FastColoredTextBox类的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox类的具体用法?C# FastColoredTextBox怎么用?C# FastColoredTextBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FastColoredTextBox类属于命名空间,在下文中一共展示了FastColoredTextBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GotoNextBookmark
/// <summary>
/// Scrolls to nearest bookmark or to first bookmark
/// </summary>
/// <param name="textbox"></param>
/// <param name="iLine">Current bookmark line index</param>
public static bool GotoNextBookmark(FastColoredTextBox textbox, int iLine)
{
Bookmark nearestBookmark = null;
int minNextLineIndex = int.MaxValue;
Bookmark minBookmark = null;
int minLineIndex = int.MaxValue;
foreach (Bookmark bookmark in textbox.Bookmarks)
{
if (bookmark.LineIndex < minLineIndex)
{
minLineIndex = bookmark.LineIndex;
minBookmark = bookmark;
}
if (bookmark.LineIndex > iLine && bookmark.LineIndex < minNextLineIndex)
{
minNextLineIndex = bookmark.LineIndex;
nearestBookmark = bookmark;
}
}
if (nearestBookmark != null)
{
nearestBookmark.DoVisible();
return true;
}
else if (minBookmark != null)
{
minBookmark.DoVisible();
return true;
}
return false;
}
示例2: Copy
/// <summary>
/// Copy selected text into Clipboard
/// </summary>
public static void Copy(FastColoredTextBox textbox)
{
if (textbox.Selection.IsEmpty)
{
textbox.Selection.Expand();
}
if (!textbox.Selection.IsEmpty)
{
var exp = new ExportToHTML();
exp.UseBr = false;
exp.UseNbsp = false;
exp.UseStyleTag = true;
string html = "<pre>" + exp.GetHtml(textbox.Selection.Clone()) + "</pre>";
var data = new DataObject();
data.SetData(DataFormats.UnicodeText, true, textbox.Selection.Text);
data.SetData(DataFormats.Html, PrepareHtmlForClipboard(html));
data.SetData(DataFormats.Rtf, new ExportToRTF().GetRtf(textbox.Selection.Clone()));
//
var thread = new Thread(() => SetClipboard(data));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
}
示例3: Create
public Control Create()
{
txt = new FastColoredTextBox();
txt.ReadOnly = false;
//txt.MouseWheel += MouseWheel;
txt.KeyDown += KeyDown;
//txt.KeyPress += KeyPress;
//txt.TextChanged += TextChanged;
txt.SelectionChanged += SelectionChanged;
//txt.Language = Language.CSharp;
//txt.Language = Language.SQL;
txt.Language = Language.Custom;
txt.DescriptionFile = "isql_syntax_desc.xml";
txt.Font = new Font("Courier New", 10);
txt.WordWrap = true;
txt.WordWrapMode = WordWrapMode.CharWrapControlWidth;
txt.ShowLineNumbers = false;
txt.AutoIndentNeeded += (object sender, AutoIndentEventArgs e) => { e.Shift = 0; e.AbsoluteIndentation = 0; e.ShiftNextLines = 0; }; // Disable auto-indentation
//txt.Text = "> ";
ClearAction = ActionManager.CreateAction("Clear console", this, "Clear");
PrintCommandAction = ActionManager.CreateAction("Print command to console", this, "PrintCommand");
ActionManager.Do(ClearAction);
return txt;
}
示例4: MoveSelectedLinesUp
/// <summary>
/// Moves selected lines up
/// </summary>
public static void MoveSelectedLinesUp(FastColoredTextBox textbox)
{
Range prevSelection = textbox.Selection.Clone();
textbox.Selection.Expand();
if (!textbox.Selection.ReadOnly)
{
int iLine = textbox.Selection.Start.iLine;
if (iLine == 0)
{
textbox.Selection = prevSelection;
return;
}
string text = textbox.SelectedText;
var temp = new List<int>();
for (int i = textbox.Selection.Start.iLine; i <= textbox.Selection.End.iLine; i++)
{
temp.Add(i);
}
textbox.RemoveLines(temp);
textbox.Selection.Start = new Place(0, iLine - 1);
textbox.SelectedText = text + "\n";
textbox.Selection.Start = new Place(prevSelection.Start.iChar, prevSelection.Start.iLine - 1);
textbox.Selection.End = new Place(prevSelection.End.iChar, prevSelection.End.iLine - 1);
}
else
{
textbox.Selection = prevSelection;
}
}
示例5: MoveSelectedLinesDown
/// <summary>
/// Moves selected lines down
/// </summary>
public static void MoveSelectedLinesDown(FastColoredTextBox textbox)
{
Range prevSelection = textbox.Selection.Clone();
textbox.Selection.Expand();
if (!textbox.Selection.ReadOnly)
{
int iLine = textbox.Selection.Start.iLine;
if (textbox.Selection.End.iLine >= textbox.LinesCount - 1)
{
textbox.Selection = prevSelection;
return;
}
string text = textbox.SelectedText;
var temp = new List<int>();
for (int i = textbox.Selection.Start.iLine; i <= textbox.Selection.End.iLine; i++)
{
temp.Add(i);
}
textbox.RemoveLines(temp);
textbox.Selection.Start = new Place(textbox.GetLineLength(iLine), iLine);
textbox.SelectedText = "\n" + text;
textbox.Selection.Start = new Place(prevSelection.Start.iChar, prevSelection.Start.iLine + 1);
textbox.Selection.End = new Place(prevSelection.End.iChar, prevSelection.End.iLine + 1);
}
else
{
textbox.Selection = prevSelection;
}
}
示例6: GetRtf
public string GetRtf(FastColoredTextBox tb)
{
_tb = tb;
var sel = new Range(tb);
sel.SelectAll();
return GetRtf(sel);
}
示例7: MgfService
public MgfService(FastColoredTextBox tb)
{
this.tb = tb;
tb.AddStyle(preprocStyle);
tb.AddStyle(commentStyle);
tb.AddStyle(operatorStyle);
tb.AddStyle(linkStyle);
tb.AddStyle(linkTlpdStyle);
tb.AddStyle(wavyError);
tb.AddStyle(wavyUndefined);
tb.AddStyle(wavyRedefined);
tb.AddStyle(entityStyle);
tb.AddStyle(seriesStyle);
//tb.AddStyle(terranStyle);
//tb.AddStyle(zergStyle);
//tb.AddStyle(protossStyle);
//tb.AddStyle(randomStyle);
tb.AddStyle(playerStyle);
tb.AddStyle(mapStyle);
tb.AddStyle(winnerStyle);
tb.AddStyle(loserStyle);
tb.AddStyle(rangeStyle);
}
示例8: Cut
/// <summary>
/// Cut selected text into Clipboard
/// </summary>
public static void Cut(FastColoredTextBox textbox)
{
if (!textbox.Selection.IsEmpty)
{
EditorCommands.Copy(textbox);
textbox.ClearSelected();
}
else
if (textbox.LinesCount == 1)
{
textbox.Selection.SelectAll();
EditorCommands.Copy(textbox);
textbox.ClearSelected();
}
else
{
EditorCommands.Copy(textbox);
//remove current line
if (textbox.Selection.Start.iLine >= 0 && textbox.Selection.Start.iLine < textbox.LinesCount)
{
int iLine = textbox.Selection.Start.iLine;
textbox.RemoveLines(new List<int> { iLine });
textbox.Selection.Start = new Place(0, Math.Max(0, Math.Min(iLine, textbox.LinesCount - 1)));
}
}
}
示例9: AutocompleteListView
internal AutocompleteListView(FastColoredTextBox tb)
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
base.Font = new Font(FontFamily.GenericSansSerif, 9);
visibleItems = new List<AutocompleteItem>();
itemHeight = Font.Height + 2;
VerticalScroll.SmallChange = itemHeight;
BackColor = Color.White;
MaximumSize = new Size(Size.Width, 180);
toolTip.ShowAlways = false;
AppearInterval = 500;
timer.Tick += new EventHandler(timer_Tick);
this.tb = tb;
tb.KeyDown += new KeyEventHandler(tb_KeyDown);
tb.SelectionChanged += new EventHandler(tb_SelectionChanged);
tb.KeyPressed += new KeyPressEventHandler(tb_KeyPressed);
Form form = tb.FindForm();
if (form != null)
{
form.LocationChanged += (o, e) => Menu.Close();
form.ResizeBegin += (o, e) => Menu.Close();
form.FormClosing += (o, e) => Menu.Close();
form.LostFocus += (o, e) => Menu.Close();
}
tb.LostFocus += (o, e) =>
{
if (!Menu.Focused) Menu.Close();
};
tb.Scroll += (o, e) => Menu.Close();
}
示例10: Sandbox
public Sandbox()
{
InitializeComponent();
fctb = new FastColoredTextBox() { Parent = this, Dock = DockStyle.Fill };
fctb.TextChangedDelayed += new EventHandler<TextChangedEventArgs>(fctb_TextChangedDelayed);
fctb.Text = @"<?xml version=""1.0"" encoding=""ISO-8859-1""?>
<!-- Edited by XMLSpy® -->
<CATALOG>
<PLANT>
<COMMON>Bloodroot</COMMON><AVAILABILITY>
031599
</AVAILABILITY>
</PLANT>
<PLANT><PRICE value=""11.34""></PRICE>
<COMMON Name=""Bloodroot"" /><BLABLA/>
<BOTANICAL Title=""Sanguinaria canadensis""
Name="""" /><ZONE>4</ZONE>
<LIGHT>Mostly Shady</LIGHT> <PRICE Value=""$2.44""/>
<AVAILABILITY No=""3454"">
031599
</AVAILABILITY>
</PLANT>
</CATALOG>
";
}
示例11: StringTextSource
public StringTextSource(FastColoredTextBox tb)
: base(tb)
{
timer.Interval = 10000;
timer.Tick += new EventHandler(timer_Tick);
timer.Enabled = true;
}
示例12: GotoPrevBookmark
/// <summary>
/// Scrolls to nearest previous bookmark or to last bookmark
/// </summary>
/// <param name="textbox"></param>
/// <param name="iLine">Current bookmark line index</param>
public static bool GotoPrevBookmark(FastColoredTextBox textbox, int iLine)
{
Bookmark nearestBookmark = null;
int maxPrevLineIndex = -1;
Bookmark maxBookmark = null;
int maxLineIndex = -1;
foreach (Bookmark bookmark in textbox.Bookmarks)
{
if (bookmark.LineIndex > maxLineIndex)
{
maxLineIndex = bookmark.LineIndex;
maxBookmark = bookmark;
}
if (bookmark.LineIndex < iLine && bookmark.LineIndex > maxPrevLineIndex)
{
maxPrevLineIndex = bookmark.LineIndex;
nearestBookmark = bookmark;
}
}
if (nearestBookmark != null)
{
nearestBookmark.DoVisible();
return true;
}
else if (maxBookmark != null)
{
maxBookmark.DoVisible();
return true;
}
return false;
}
示例13: InsertChar
internal static void InsertChar(char c, ref char deletedChar, FastColoredTextBox tb)
{
switch (c)
{
case '\n':
if (tb.LinesCount == 0)
InsertLine(tb);
InsertLine(tb);
break;
case '\r': break;
case '\b'://backspace
if (tb.Selection.Start.iChar == 0 && tb.Selection.Start.iLine == 0)
return;
if (tb.Selection.Start.iChar == 0)
{
if (tb[tb.Selection.Start.iLine - 1].VisibleState != VisibleState.Visible)
tb.ExpandBlock(tb.Selection.Start.iLine - 1);
deletedChar = '\n';
MergeLines(tb.Selection.Start.iLine - 1, tb);
}
else
{
deletedChar = tb[tb.Selection.Start.iLine][tb.Selection.Start.iChar - 1].c;
tb[tb.Selection.Start.iLine].RemoveAt(tb.Selection.Start.iChar - 1);
tb.Selection.Start = new Place(tb.Selection.Start.iChar - 1, tb.Selection.Start.iLine);
}
break;
default:
tb[tb.Selection.Start.iLine].Insert(tb.Selection.Start.iChar, new Char(c));
tb.Selection.Start = new Place(tb.Selection.Start.iChar + 1, tb.Selection.Start.iLine);
break;
}
}
示例14: Bookmark
public Bookmark(FastColoredTextBox tb, string name, int lineIndex)
{
this.TB = tb;
this.Name = name;
this.LineIndex = lineIndex;
Color = tb.BookmarkColor;
}
示例15: SelectText
public static void SelectText(string target, FastColoredTextBox editor)
{
int index = Match(editor.Text, [email protected]"(?<=\n)\({target}\)").Index; //finding the goto destination
Range range = editor.GetRange(index + target.Length + 2, index + target.Length + 2);
editor.Selection = new Range(editor, range.Start.iLine);
editor.DoCaretVisible();
}