internal static CreatePropertiesDialog CreateDialog(InsertionContext context) { ITextEditor textEditor = context.TextArea.GetService(typeof(ITextEditor)) as ITextEditor; if (textEditor == null) return null; using (textEditor.Document.OpenUndoGroup()) { IEditorUIService uiService = textEditor.GetService(typeof(IEditorUIService)) as IEditorUIService; if (uiService == null) return null; ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition); anchor.MovementType = AnchorMovementType.BeforeInsertion; CreatePropertiesDialog dialog = new CreatePropertiesDialog(context, textEditor, anchor); dialog.Element = uiService.CreateInlineUIElement(anchor, dialog); // Add creation of this inline dialog as undoable operation TextDocument document = textEditor.Document as TextDocument; if (document != null) { document.UndoStack.Push(dialog.UndoableCreationOperation); } return dialog; } }
internal static CreatePropertiesDialog CreateDialog(InsertionContext context) { ITextEditor textEditor = context.TextArea.GetService(typeof(ITextEditor)) as ITextEditor; if (textEditor == null) { return(null); } using (textEditor.Document.OpenUndoGroup()) { IEditorUIService uiService = textEditor.GetService(typeof(IEditorUIService)) as IEditorUIService; if (uiService == null) { return(null); } ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition); anchor.MovementType = AnchorMovementType.BeforeInsertion; CreatePropertiesDialog dialog = new CreatePropertiesDialog(context, textEditor, anchor); dialog.Element = uiService.CreateInlineUIElement(anchor, dialog); // Add creation of this inline dialog as undoable operation TextDocument document = textEditor.Document as TextDocument; if (document != null) { document.UndoStack.Push(dialog.UndoableCreationOperation); } return(dialog); } }