• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FastColoredTextBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FastColoredTextBox的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox类的具体用法?C# FastColoredTextBox怎么用?C# FastColoredTextBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FastColoredTextBox类属于命名空间,在下文中一共展示了FastColoredTextBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GetHtml

 public string GetHtml(FastColoredTextBox tb)
 {
     this.tb = tb;
     Range sel = new Range(tb);
     sel.SelectAll();
     return GetHtml(sel);
 }
开发者ID:Celtech,项目名称:BolDevStudio,代码行数:7,代码来源:ExportToHTML.cs


示例17: ApplyTheme

        public static void ApplyTheme(string source, SyntaxHighlighter highlighter, FastColoredTextBox tb)
        {
            source = Path.Combine(GlobalSettings.SettingsDir, source);
            using (var reader = XmlReader.Create(source))
            {
                while (reader.Read())
                    // Only detect start elements.
                    if (reader.IsStartElement())
                    {
                        // Get element name and switch on it.
                        switch (reader.Name)
                        {
                            case "Style":
                                // Search for the attribute name on this current node.
                                var name = reader["Name"];
                                var fontstyle = (FontStyle) Enum.Parse(typeof (FontStyle), reader["Font"]);
                                var color = reader["Color"];
                                InitStyle(name, fontstyle, GetColorFromHexVal(color), highlighter);
                                // if (reader.Read())
                                //     InitStyle(name, fontstyle, GetColorFromHexVal(color), highlighter);
                                break;

                            case "Key":
                                // Search for the attribute name on this current node.
                                InitKey(tb, reader["Name"], reader["Value"]);
                                // if (reader.Read())
                                //     KeyInit(tb, reader["Name"], reader["Value"]);
                                break;
                        }
                    }
            }
        }
开发者ID:samarjeet27,项目名称:ynoteclassic,代码行数:32,代码来源:YnoteThemeReader.cs


示例18: MoveWordRightToPatientDays

        public void MoveWordRightToPatientDays()
        {
            var tb = new FastColoredTextBox();
            //var range = new Range(tb, 0,0,0,0);
            string s = TabSizeCalculatorTests.CreateLongString();
            var words = s.Split('\t');
            tb.Text = s;
            Assert.AreEqual(new Place(0, 0), tb.Selection.Start);
            Assert.AreEqual(new Place(0, 0), tb.Selection.End);

            int wordIndex = 0;
            while (words[wordIndex] != "PatientDays")
            {
                tb.Selection.GoWordRight(false); // to the next end of the word
                wordIndex++;
            }
            // before "PatientDays"
            tb.Selection.GoWordRight(false);
            Assert.AreEqual(new Place(190, 0), tb.Selection.Start);
            Assert.AreEqual(new Place(190, 0), tb.Selection.End);

            string substring = s.Substring(0, 190);
            Assert.IsTrue(substring.EndsWith("PatientDays"));

            int width = TextSizeCalculator.TextWidth(s.Substring(0, 190), 4);
            Assert.AreEqual(211, width);
        }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:27,代码来源:MoveCaretTests.cs


示例19: StringTextSource

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


示例20: GetRange

 /// <summary>
 /// Get range of text
 /// </summary>
 /// <param name="textbox"></param>
 /// <param name="fromPos">Absolute start position</param>
 /// <param name="toPos">Absolute finish position</param>
 /// <returns>Range</returns>
 public static Range GetRange(FastColoredTextBox textbox, int fromPos, int toPos)
 {
     var sel = new Range(textbox);
     sel.Start = TextSourceUtil.PositionToPlace(textbox.lines, fromPos);
     sel.End = TextSourceUtil.PositionToPlace(textbox.lines, toPos);
     return sel;
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:14,代码来源:RangeUtil.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FastList类代码示例发布时间:2022-05-24
下一篇:
C# FastBitmap类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap