protected RmlElementEditor(Element element, ElementStrategy elementStrategy) : base("Medical.GUI.Editor.RmlWysiwyg.RmlElementEditor.layout") { this.element = element; this.elementStrategy = elementStrategy; this.Hiding += RmlElementEditor_Hiding; tabs = (TabControl)widget.findWidget("Tabs"); Button up = (Button)widget.findWidget("Up"); up.MouseButtonClick += new MyGUIEvent(up_MouseButtonClick); Button down = (Button)widget.findWidget("Down"); down.MouseButtonClick += new MyGUIEvent(down_MouseButtonClick); Button delete = (Button)widget.findWidget("Delete"); delete.MouseButtonClick += new MyGUIEvent(delete_MouseButtonClick); Button close = (Button)widget.findWidget("Close"); close.MouseButtonClick += close_MouseButtonClick; hasChanges = false; SmoothShow = false; KeepOpen = true; }
public ElementStrategy this[Element element] { get { ElementStrategy ret = defaultStrategy; if (element != null) { String tagName = element.TagName; ElementStrategy strat; if (strategies.TryGetValue(tagName, out strat)) { ret = strat; } else if (defaultElementStrategyManager.strategies.TryGetValue(tagName, out strat)) { ret = strat; } } return(ret); } }
void rmlImage_MouseButtonReleased(Widget source, EventArgs e) { MouseEventArgs me = (MouseEventArgs)e; if (me.Button == Engine.Platform.MouseButtonCode.MB_BUTTON0) { Element element = draggingElementManager.DragElement; //This will be the clicked element, or null if the element was moved ElementStrategy elementStrategy = elementStrategyManager[element]; IntVector2 mousePosition = me.Position; draggingElementManager.dragEnded(mousePosition); if (!allowEdit) { //Break if they cannot edit return; } Element altElement = rocketWidget.Context.FindElementAtPoint(localCoord(mousePosition), element); if (altElement != null) //Another element was found see if we can use it { ElementStrategy altStrategy = elementStrategyManager[altElement]; if (altStrategy != elementStrategyManager.DefaultStrategy) { element = altElement; elementStrategy = altStrategy; } } if (element != null) { showRmlElementEditor(element, elementStrategy); } else { cancelAndHideEditor(); selectedElementManager.clearSelectedAndHighlightedElement(); } } }
public void addCustomStrategy(ElementStrategy strategy) { customStrategies.AddLast(strategy); }
public void remove(ElementStrategy strategy) { strategies.Remove(strategy.TagName); }
public void add(ElementStrategy strategy) { strategies.Add(strategy.TagName, strategy); }
/// <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); }
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(); } }