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


C# FastColoredTextBox.ClearSelected方法代码示例

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


在下文中一共展示了FastColoredTextBox.ClearSelected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: DropFromTheInside

        private static void DropFromTheInside(FastColoredTextBox textbox, Place place, string text)
        {
            Range insertRange = new Range(textbox, place, place);

            // Determine, if the dragged string should be copied or moved
            bool copyMode =
                (textbox.draggedRange == null) ||       // drag from outside
                (textbox.draggedRange.ReadOnly) ||      // dragged range is read only
                ((Control.ModifierKeys & Keys.Control) != Keys.None);

            if (!textbox.draggedRange.Contains(place))
            {
                textbox.BeginAutoUndo();
                textbox.Selection.BeginUpdate();

                //remember dragged selection for undo/redo
                textbox.Selection = textbox.draggedRange;
                textbox.lines.Manager.ExecuteCommand(new SelectCommand(textbox.lines));
                //

                if (textbox.draggedRange.ColumnSelectionMode)
                {
                    // dropping a block selection, add a few new lines
                    textbox.draggedRange.Normalize();
                    var endLine = place.iLine + textbox.draggedRange.End.iLine - textbox.draggedRange.Start.iLine;
                    var end = new Place(place.iChar,endLine );
                    insertRange = new Range(textbox, place, end) { ColumnSelectionMode = true };
                    for (int i = textbox.LinesCount; i <= insertRange.End.iLine; i++)
                    {
                        textbox.Selection.GoLast(false);
                        textbox.InsertChar('\n');
                    }
                }

                if (!insertRange.ReadOnly)
                {
                    if (place < textbox.draggedRange.Start)
                    {
                        // Target place is before the dragged range,
                        // first delete dragged range if not in copy mode
                        if (copyMode == false)
                        {
                            textbox.Selection = textbox.draggedRange;
                            textbox.ClearSelected(); // clear original selectin
                        }

                        // Insert text
                        textbox.Selection = insertRange;
                        textbox.Selection.ColumnSelectionMode = insertRange.ColumnSelectionMode;
                        textbox.InsertText(text);
                    }
                    else
                    {
                        // Target place is after the dragged range, first insert the text
                        // Insert text
                        textbox.Selection = insertRange;
                        textbox.Selection.ColumnSelectionMode = insertRange.ColumnSelectionMode;
                        textbox.InsertText(text);

                        // Delete dragged range if not in copy mode
                        if (copyMode == false)
                        {
                            textbox.Selection = textbox.draggedRange;
                            textbox.ClearSelected();
                        }
                    }
                }

                // Selection start and end position
                Place startPosition = place;
                Place endPosition = textbox.Selection.Start;

                // Correct selection
                Range dR = (textbox.draggedRange.End > textbox.draggedRange.Start)  // dragged selection
                    ? RangeUtil.GetRange(textbox, textbox.draggedRange.Start, textbox.draggedRange.End)
                    : RangeUtil.GetRange(textbox, textbox.draggedRange.End, textbox.draggedRange.Start);
                Place tP = place; // targetPlace
                int tS_S_Line;  // targetSelection.Start.iLine
                int tS_S_Char;  // targetSelection.Start.iChar
                int tS_E_Line;  // targetSelection.End.iLine
                int tS_E_Char;  // targetSelection.End.iChar
                if ((place > textbox.draggedRange.Start) && (copyMode == false))
                {
                    if (textbox.draggedRange.ColumnSelectionMode == false)
                    {
                        // Normal selection mode:

                        // Determine character/column position of target selection
                        if (dR.Start.iLine != dR.End.iLine) // If more then one line was selected/dragged ...
                        {
                            tS_S_Char = (dR.End.iLine != tP.iLine)
                                ? tP.iChar
                                : dR.Start.iChar + (tP.iChar - dR.End.iChar);
                            tS_E_Char = dR.End.iChar;
                        }
                        else // only one line was selected/dragged
                        {
                            if (dR.End.iLine == tP.iLine)
                            {
                                tS_S_Char = tP.iChar - dR.Text.Length;
//.........这里部分代码省略.........
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:101,代码来源:DoDragDropHelper.cs

示例3: Split

 private void Split(int iLine, FastColoredTextBox tb, string s)
 {
     string[] sep = s.Split(':');
     tb.Selection.Start = new Place(0, iLine);
     tb.Selection.Expand();
     string seperator;
     if (sep.Length == 3 && sep[1] == string.Empty)
         seperator = ":";
     else
         seperator = sep[1];
     var lines = tb.SelectedText.Split(seperator.ToCharArray());
     tb.ClearSelected();
     foreach (string line in lines)
     {
         tb.InsertText(line+"\n");
     }
     tb.ClearCurrentLine();
 }
开发者ID:samarjeet27,项目名称:ynoteclassic,代码行数:18,代码来源:MainForm.cs


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