当前位置: 首页>>代码示例>>C#>>正文


C# FastColoredTextBox类代码示例

本文整理汇总了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;
        }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:39,代码来源:BookmarkCommands.cs

示例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();
            }
        }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:28,代码来源:EditorCommands.cs

示例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;
        }
开发者ID:RcSepp,项目名称:global_view,代码行数:28,代码来源:ScriptingConsole.cs

示例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;
     }
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:32,代码来源:MoveCommands.cs

示例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;
     }
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:32,代码来源:MoveCommands.cs

示例6: GetRtf

 public string GetRtf(FastColoredTextBox tb)
 {
     _tb = tb;
     var sel = new Range(tb);
     sel.SelectAll();
     return GetRtf(sel);
 }
开发者ID:workwhileweb,项目名称:FastColoredTextBox,代码行数:7,代码来源:ExportToRTF.cs

示例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);
    }
开发者ID:xpaperclip,项目名称:tlpdtools,代码行数:27,代码来源:MgfService.cs

示例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)));
             }
         }
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:29,代码来源:EditorCommands.cs

示例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();
        }
开发者ID:zp-j,项目名称:CompileSpeaker,代码行数:34,代码来源:AutocompleteMenu.cs

示例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>
";
        }
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:26,代码来源:Sandbox.cs

示例11: StringTextSource

 public StringTextSource(FastColoredTextBox tb)
     : base(tb)
 {
     timer.Interval = 10000;
     timer.Tick += new EventHandler(timer_Tick);
     timer.Enabled = true;
 }
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:7,代码来源:CustomTextSourceSample.cs

示例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;
        }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:39,代码来源:BookmarkCommands.cs

示例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;
     }
 }
开发者ID:runt18,项目名称:open-webkit-sharp,代码行数:33,代码来源:Commands.cs

示例14: Bookmark

 public Bookmark(FastColoredTextBox tb, string name, int lineIndex)
 {
     this.TB = tb;
     this.Name = name;
     this.LineIndex = lineIndex;
     Color = tb.BookmarkColor;
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:7,代码来源:Bookmark.cs

示例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();
 }
开发者ID:q55x8x,项目名称:Peronality-Creator,代码行数:7,代码来源:FastColoredEditorUtils.cs


注:本文中的FastColoredTextBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。