/// <summary>Save the current selection</summary> public RangeI SaveTextSelection() { var selection = RangeI.FromStartLength(SelectionStart, SelectionLength); //System.Diagnostics.Trace.WriteLine("Selection Saved: [{0},{1}]\n\t{2}" // .Fmt(selection.Value.Begi, selection.Value.Sizei, // string.Join("\n\t", new System.Diagnostics.StackTrace().GetFrames().Take(5).Select(x => x.GetMethod())))); return(selection); }
/// <summary>Returns a disposable object that preserves the current selection</summary> public static Scope <RangeI> SelectionScope(this TextBox edit) { return(Scope.Create( () => RangeI.FromStartLength(edit.SelectionStart, edit.SelectionLength), rn => edit.Select(rn.Begi, rn.Sizei))); }