Exemplo n.º 1
0
        /// <inheritdoc />
        public override void Do(DocumentEditorContext context)
        {
            var caret = (TextCaret)_handle.GetCaret(context);

            var block = caret.Block;

            var destinationDescriptor = GetDestinationDescriptor();

            // optimization; if it's already the correct block type, we just have to change it in-place
            if (block.DescriptorHandle == destinationDescriptor)
            {
                MakeChangesTo((TBlock)block);
            }
            else
            {
                var newBlock = (TBlock)destinationDescriptor.CreateInstance();
                MakeChangesTo(newBlock);

                Replace(context, block, newBlock);
            }
        }
 /// <summary>
 ///  Moves to he cursor to point to the location given by <paramref name="handle"/>.
 /// </summary>
 public static void MoveTo(this DocumentSelection cursor, DocumentCursorHandle handle, DocumentEditorContext context)
 => cursor.Replace(handle.GetCaret(context));