public ITextSnapshotLine GetLineToSwap(IWpfTextView view, SelectionHelper selectionHelper) { var startPosition = selectionHelper.GetLineStartPoint(); var startLineNumber = view.TextSnapshot.GetLineNumberFromPosition(startPosition.Position); return view.TextSnapshot.GetLineFromLineNumber(startLineNumber - 1); }
public ITextSnapshotLine GetLineToSwap(IWpfTextView view, SelectionHelper selectionHelper) { var endPosition = selectionHelper.GetLineEndPoint(); var endLineNumber = view.TextSnapshot.GetLineNumberFromPosition(endPosition.Position); return view.TextSnapshot.GetLineFromLineNumber(endLineNumber + 1); }
public void MoveLine(IWpfTextView view) { try { var selectionHelper = new SelectionHelper(view); selectionHelper.TakeSelectionSnapshot(); var lineToSwap = this.lineMover.GetLineToSwap(view, selectionHelper); var insertPosition = this.lineMover.GetInsertPosition(selectionHelper); var offSet = this.lineMover.PerformMove(view, lineToSwap, insertPosition); selectionHelper.ApplySelection(offSet); view.Caret.EnsureVisible(); } catch { // Not critical. Swallow the exception. } }
public SnapshotPoint GetInsertPosition(SelectionHelper selectionHelper) { return selectionHelper.GetLineEndIncludingLineBreak(); }
public SnapshotPoint GetInsertPosition(SelectionHelper selectionHelper) { return selectionHelper.GetLineStartPoint(); }