コード例 #1
0
        /// <summary>
        /// Delete the content between a markup range from the document.
        /// </summary>
        /// <param name="selection"></param>
        private void DeleteContent(MarkupRange selection)
        {
            //there is nothing being deleted, so just return
            //Note: this avoids overhead associated with needlessly notifying that the content changed
            if (selection.Start.IsEqualTo(selection.End))
            {
                return;
            }

            IUndoUnit undo = CreateUndoUnit();
            using (undo)
            {
                try
                {
                    selection.RemoveContent();
                }
                catch (Exception e)
                {
                    Trace.Fail("error while deleting selection: " + e.Message, e.StackTrace);
                    throw e;
                }

                undo.Commit();
            }
        }