public virtual void attachToParent(RmlElementEditor parentEditor, Widget parent) { this.parentEditor = parentEditor; widget.Visible = false; IntCoord clientCoord = parent.ClientCoord; widget.setSize(clientCoord.width, clientCoord.height); widget.Align = Align.Stretch; widget.attachToWidget(parent); widget.Visible = true; }
/// <summary> /// Open a text editor that disposes when it is closed. /// </summary> /// <returns></returns> public static RmlElementEditor openEditor(Element element, int left, int top, ElementStrategy elementStrategy) { RmlElementEditor editor = new RmlElementEditor(element, elementStrategy); editor.show(left, top); editor.Hidden += (source, e) => { ((RmlElementEditor)source).Dispose(); }; return(editor); }
public virtual bool delete(Element element, RmlElementEditor editor, RmlWysiwygComponent component) { return(false); }
public virtual bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations) { additionalUndoOperations = null; return(false); }
private void showRmlElementEditor(Element element, ElementStrategy strategy) { if (currentEditor == null || selectedElementManager.SelectedElement != element) { cancelAndHideEditor(); RmlElementEditor editor = strategy.openEditor(element, uiCallback, 0, 0); if (editor == null) { //The editor was null, which means editing is not supported so just clear the selection. selectedElementManager.clearSelectedAndHighlightedElement(); return; //Return here to prevent more execution } editor.UndoRml = UnformattedRml; //Everything is good so setup. editor.Hiding += (src, arg) => { if (!disposed) { if (editor.deleteIfNeeded(this)) { rmlModified(); updateUndoStatus(editor.UndoRml, true); editor.UndoRml = UnformattedRml; } selectedElementManager.AllowShowResizeHandles = false; } }; editor.Hidden += (src, arg) => { if (currentEditor == editor) { currentEditor = null; } }; editor.ChangesMade += (applyElement) => { TwoWayCommand additionalUndoOperations; if (!disposed && editor.applyChanges(this, out additionalUndoOperations)) { rocketWidget.Context.GetDocument(0).MakeDirtyForScaleChange(); rmlModified(); updateUndoStatus(editor.UndoRml, true, additionalUndoOperations); editor.UndoRml = UnformattedRml; } }; editor.MoveElementUp += upElement => { Element previousSibling = upElement.PreviousSibling; if (previousSibling != null) { Element parent = upElement.ParentNode; if (parent != null) { upElement.addReference(); parent.RemoveChild(upElement); parent.InsertBefore(upElement, previousSibling); upElement.removeReference(); rmlModified(); updateUndoStatus(editor.UndoRml); editor.UndoRml = UnformattedRml; } } }; editor.MoveElementDown += downElement => { Element parent = downElement.ParentNode; if (parent != null) { Element nextSibling = downElement.NextSibling; if (nextSibling != null) { downElement.addReference(); parent.RemoveChild(downElement); nextSibling = nextSibling.NextSibling; if (nextSibling != null) { parent.InsertBefore(downElement, nextSibling); } else { parent.AppendChild(downElement); } downElement.removeReference(); rmlModified(); updateUndoStatus(editor.UndoRml); editor.UndoRml = UnformattedRml; } } }; editor.DeleteElement += deleteElement => { Element parent = deleteElement.ParentNode; if (parent != null) { Element nextSelectionElement = deleteElement.NextSibling; if (nextSelectionElement == null) { nextSelectionElement = deleteElement.PreviousSibling; } parent.RemoveChild(deleteElement); rmlModified(false); updateUndoStatus(editor.UndoRml); editor.UndoRml = UnformattedRml; if (nextSelectionElement != null) { showRmlElementEditor(nextSelectionElement, elementStrategyManager[nextSelectionElement]); } else { selectedElementManager.clearSelectedAndHighlightedElement(); } } }; currentEditor = editor; selectedElementManager.SelectedElement = element; selectedElementManager.setHighlightElement(element, strategy.HighlightProvider); selectedElementManager.ElementStrategy = strategy; selectedElementManager.AllowShowResizeHandles = true; updateEditorPosition(); } }