Execute() public method

Execute operation
public Execute ( ) : void
return void
コード例 #1
0
        private void ExecuteInsertTextCommand(ref int iChar, string text)
        {
            var lines = text.Split('\n');
            var iLine = 0;

            foreach (var r in range.GetSubRanges(true))
            {
                var line        = ts.CurrentTB[r.Start.iLine];
                var lineIsEmpty = r.End < r.Start && line.StartSpacesCount == line.Count;
                if (!lineIsEmpty)
                {
                    var insertedText = lines[iLine % lines.Length];
                    if (r.End < r.Start && insertedText != "")
                    {
                        //add forwarding spaces
                        insertedText = new string( ' ', r.Start.iChar - r.End.iChar ) + insertedText;
                        r.Start      = r.End;
                    }
                    ts.CurrentTB.Selection = r;
                    var c = new InsertTextCommand(ts, insertedText);
                    c.Execute();
                    if (ts.CurrentTB.Selection.End.iChar > iChar)
                    {
                        iChar = ts.CurrentTB.Selection.End.iChar;
                    }
                    commandsByRanges.Add(c);
                }
                iLine++;
            }
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: WendyH/HMSEditor
 private void ExecuteInsertTextCommand(ref int iChar, string text)
 {
     var lines = text.Split('\n');
     var iLine = 0;
     foreach (var r in range.GetSubRanges(true))
     {
         var line = ts.CurrentTB[r.Start.iLine];
         var lineIsEmpty = r.End < r.Start && line.StartSpacesCount == line.Count;
         if (!lineIsEmpty)
         {
             var insertedText = lines[iLine%lines.Length];
             if (r.End < r.Start && insertedText!="")
             {
                 //add forwarding spaces
                 insertedText = new string(' ', r.Start.iChar - r.End.iChar) + insertedText;
                 r.Start = r.End;
             }
             ts.CurrentTB.Selection = r;
             var c = new InsertTextCommand(ts, insertedText);
             c.Execute();
             if (ts.CurrentTB.Selection.End.iChar > iChar)
                 iChar = ts.CurrentTB.Selection.End.iChar;
             commandsByRanges.Add(c);
         }
         iLine++;
     }
 }