/// <summary> /// Sets a property and add the change in the uno manager. /// </summary> /// <param name="obj">The obj.</param> /// <param name="propName">Name of the property.</param> /// <param name="value">The value of the property.</param> /// <param name="doc">The undo manager.</param> internal static bool SetPropertyUndoable(XPropertySet obj, String propName, Object value, XUndoManagerSupplier doc) { bool success = false; XUndoManager undoManager = null; if (doc != null) { undoManager = ((XUndoManagerSupplier)doc).getUndoManager() as XUndoManager; if (undoManager != null) { var is_lock = undoManager.isLocked(); undoManager.enterUndoContext("Change Property : " + propName); } } var oldVal = GetProperty(obj, propName); success = SetProperty(obj, propName, value); if (doc != null) { if (undoManager != null) { undoManager.addUndoAction(new ParameterUndo("Change a Prop", obj, propName, oldVal, value)); undoManager.leaveUndoContext(); } } return(success); }
/// <summary> /// Adds an action to an undo manager. /// </summary> /// <param name="undoManager">The undo manager.</param> /// <param name="undo">The undo-action to add.</param> public static void AddActionToUndoManager(XUndoManager undoManager, XUndoAction undo) { if (undoManager != null && undo != null) { undoManager.enterUndoContext(undo.Title); undoManager.addUndoAction(undo); undoManager.leaveUndoContext(); } }