本文整理汇总了C#中FastColoredTextBox.ClearUndo方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.ClearUndo方法的具体用法?C# FastColoredTextBox.ClearUndo怎么用?C# FastColoredTextBox.ClearUndo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.ClearUndo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenFile
/// <summary>
/// Open text file
/// </summary>
public static void OpenFile(FastColoredTextBox textbox, string fileName, Encoding enc)
{
var ts = textbox.CreateTextSource();
try
{
textbox.InitTextSource(ts);
textbox.Text = File.ReadAllText(fileName, enc);
textbox.ClearUndo();
textbox.IsChanged = false;
textbox.OnVisibleRangeChanged();
}
catch
{
// failed, show an empty file
textbox.InitTextSource(textbox.CreateTextSource());
textbox.lines.InsertLine(0, textbox.TextSource.CreateLine());
textbox.IsChanged = false;
throw;
}
textbox.Selection.Start = Place.Empty;
textbox.DoSelectionVisible();
}
示例2: CreateTab
private void CreateTab(string fileName)
{
if (ScriptCommunityPack.keywordsInformation.Count == 0)
{
MessageBox.Show("primarily load keywords");
return;
}
try
{
FastColoredTextBox tb = new FastColoredTextBox();
tb.AutoScroll = true;
tb.BorderStyle = BorderStyle.None;
tb.Font = new Font("Consolas", 9.75f);
tb.BackgroundImage = Properties.Resources.bg1;
tb.ForeColor = Color.White;
tb.LineNumberColor = Color.White;
tb.IndentBackColor = Color.FromArgb(80, Color.Gray);
tb.ContextMenuStrip = cmMain;
tb.Dock = DockStyle.Fill;
tb.LeftPadding = 5;
tb.Language = Language.Scp;
tb.AddStyle(new MarkerStyle(new SolidBrush(Color.FromArgb(50, Color.Gray))));//same words style
if (fileName != null)
tb.OpenFile(fileName);
tb.Name = Path.GetFileName(fileName);
tb.ClearUndo();
tb.Tag = new PopupMenu();
tb.Focus();
tb.DelayedTextChangedInterval = 1;
tb.DelayedEventsInterval = 500;
tb.TextChangedDelayed += new EventHandler<TextChangedEventArgs>(tb_TextChangedDelayed);
tb.SelectionChangedDelayed += new EventHandler(tb_SelectionChangedDelayed);
tb.ToolTipNeeded += tb_ToolTipNeeded;
tb.KeyDown += new KeyEventHandler(tb_KeyDown);
tb.MouseMove += new MouseEventHandler(tb_MouseMove);
tb.ChangedLineColor = changedLineColor;
if (btHighlightCurrentLine.Checked)
tb.CurrentLineColor = currentLineColor;
tb.ShowFoldingLines = btShowFoldingLines.Checked;
tb.HighlightingRangeType = HighlightingRangeType.VisibleRange;
AutocompleteMenu popupMenu = new AutocompleteMenu(tb);
popupMenu.Items.ImageList = ilAutocomplete;
popupMenu.Opening += new EventHandler<CancelEventArgs>(popupMenu_Opening);
BuildAutocompleteMenu(popupMenu);
(tb.Tag as PopupMenu).popupMenu = popupMenu;
tb.ToolTip.OwnerDraw = true;
tb.ToolTip.Draw += ToolTip_Draw;
tb.ToolTip.Popup += ToolTip_Popup;
MSATabPage newPagem = new MSATabPage(tb, fileName != null ? Path.GetFileName(fileName) : "[new]");
newPagem.Tag = fileName;
newPagem.MSATabPageClosing += NewPagem_MSATabPageClosing;
msaTabControl1.MSATabPageClosed += msaTabControl1_MSATabPageClosed;
msaTabControl1.SelectedPageChanged += MsaTabControl1_SelectedPageChanged;
msaTabControl1.AddPage(newPagem);
documentMap1.BackgroundImage = tb.BackgroundImage;
documentMap1.Target = tb;
}
catch (Exception ex)
{
if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Retry)
CreateTab(fileName);
return;
}
msaTabControl1.SelectedPage.Tag = fileName;
}