示例#1
0
        /// <summary>
        /// Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = ts.CurrentTB;

            prevText.Clear();

            ts.OnTextChanging(ref insertedText);

            tb.Selection.BeginUpdate();
            tb.BeginUpdate();
            for (int i = ranges.Count - 1; i >= 0; i--)
            {
                tb.Selection.Start = ranges[i].Start;
                tb.Selection.End   = ranges[i].End;
                prevText.Add(tb.Selection.Text);
                ClearSelected(ts);
                if (insertedText != "")
                {
                    InsertTextCommand.InsertText(insertedText, ts);
                }
            }
            if (ranges.Count > 0)
            {
                ts.OnTextChanged(ranges[0].Start.iLine, ranges[ranges.Count - 1].End.iLine);
            }
            tb.EndUpdate();
            tb.Selection.EndUpdate();
            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));

            lastSel = new RangeInfo(tb.Selection);
        }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tb">Underlaying textbox</param>
 /// <param name="ranges">List of ranges for replace</param>
 /// <param name="insertedText">Text for inserting</param>
 public RemoveLinesCommand(TextSource ts, List <int> iLines)
     : base(ts)
 {
     //sort iLines
     iLines.Sort();
     //
     this.iLines = iLines;
     lastSel     = sel = new RangeInfo(ts.CurrentTB.Selection);
 }
示例#3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ts">Underlaying textsource</param>
 /// <param name="ranges">List of ranges for replace</param>
 public ReplaceMultipleTextCommand(TextSource ts, List <ReplaceRange> ranges)
     : base(ts)
 {
     //sort ranges by place
     ranges.Sort((r1, r2) =>
     {
         if (r1.ReplacedRange.Start.iLine == r2.ReplacedRange.Start.iLine)
         {
             return(r1.ReplacedRange.Start.iChar.CompareTo(r2.ReplacedRange.Start.iChar));
         }
         return(r1.ReplacedRange.Start.iLine.CompareTo(r2.ReplacedRange.Start.iLine));
     });
     //
     this.ranges = ranges;
     lastSel     = sel = new RangeInfo(ts.CurrentTB.Selection);
 }
示例#4
0
        /// <summary>
        /// Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = ts.CurrentTB;

            string temp = null;

            ts.OnTextChanging(ref temp);
            if (temp == "")
            {
                throw new ArgumentOutOfRangeException();
            }

            deletedText = tb.Selection.Text;
            ClearSelected(ts);
            lastSel = new RangeInfo(tb.Selection);
            ts.OnTextChanged(lastSel.Start.iLine, lastSel.Start.iLine);
        }
示例#5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tb">Underlaying textbox</param>
 /// <param name="ranges">List of ranges for replace</param>
 /// <param name="insertedText">Text for inserting</param>
 public ReplaceTextCommand(TextSource ts, List <Range> ranges, string insertedText)
     : base(ts)
 {
     //sort ranges by place
     ranges.Sort((r1, r2) =>
     {
         if (r1.Start.iLine == r2.Start.iLine)
         {
             return(r1.Start.iChar.CompareTo(r2.Start.iChar));
         }
         return(r1.Start.iLine.CompareTo(r2.Start.iLine));
     });
     //
     this.ranges       = ranges;
     this.insertedText = insertedText;
     lastSel           = sel = new RangeInfo(ts.CurrentTB.Selection);
 }
示例#6
0
        /// <summary>
        /// Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = ts.CurrentTB;

            prevText.Clear();

            ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            for (int i = iLines.Count - 1; i >= 0; i--)
            {
                var iLine = iLines[i];

                prevText.Add(ts[iLine].Text);//backward
                ts.RemoveLine(iLine);
                //ts.OnTextChanged(ranges[i].Start.iLine, ranges[i].End.iLine);
            }
            tb.Selection.Start = new Place(0, 0);
            tb.Selection.EndUpdate();
            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));

            lastSel = new RangeInfo(tb.Selection);
        }
示例#7
0
 public override void Execute()
 {
     lastSel = new RangeInfo(ts.CurrentTB.Selection);
     OnTextChanged(false);
 }
示例#8
0
 public UndoableCommand(TextSource ts)
 {
     this.ts = ts;
     sel     = new RangeInfo(ts.CurrentTB.Selection);
 }
示例#9
0
 public override void Execute()
 {
     //remember selection
     lastSel = new RangeInfo(ts.CurrentTB.Selection);
 }