/// <summary>
 /// Adds an action to an undo manager.
 /// </summary>
 /// <param name="undoManager">The undo manager supplier (normally the document).</param>
 /// <param name="undo">The undo-action to add.</param>
 public static void AddActionToUndoManager(XUndoManagerSupplier undoManager, XUndoAction undo)
 {
     AddActionToUndoManager(undoManager.getUndoManager(), undo);
 }
        /// <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>
        /// <returns><c>true</c> if the property could be changed successfully</returns>
        public static bool SetPropertyUndoable(Object obj, String propName, Object value, XUndoManagerSupplier doc)
        {
            if (obj is XControl)
            {
                obj = ((XControl)obj).getModel();
            }

            // We need the XPropertySet interface.
            XPropertySet objXPropertySet;
            if (obj is XPropertySet)
            {
                // If the right interface was passed in, just typecast it.
                objXPropertySet = (XPropertySet)obj;
            }
            else
            {
                // Get a different interface to the drawDoc.
                // The parameter passed in to us is the wrong interface to the object.
                objXPropertySet = obj as XPropertySet;
            }

            // Now just call our sibling using the correct interface.
            return SetPropertyUndoable(objXPropertySet, propName, value, doc);
        }
        /// <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>
        public 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;
        }
示例#4
0
        /// <summary>
        /// Sets a property and add the change in the uno manager.
        /// </summary>
        /// <param name="obj">The obj to change its property [XControl], [XPropertySet].</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>
        /// <returns><c>true</c> if the property could be changed successfully</returns>
        internal static bool SetPropertyUndoable(Object obj, String propName, Object value, XUndoManagerSupplier doc)
        {
            if (obj is XControl)
            {
                obj = ((XControl)obj).getModel();
            }

            // We need the XPropertySet interface.
            XPropertySet objXPropertySet;

            if (obj is XPropertySet)
            {
                // If the right interface was passed in, just typecast it.
                objXPropertySet = (XPropertySet)obj;
            }
            else
            {
                // Get a different interface to the drawDoc.
                // The parameter passed in to us is the wrong interface to the object.
                objXPropertySet = obj as XPropertySet;
            }

            // Now just call our sibling using the correct interface.
            return(SetPropertyUndoable(objXPropertySet, propName, value, doc));
        }
示例#5
0
        /// <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);
        }
示例#6
0
 /// <summary>
 /// Adds an action to an undo manager.
 /// </summary>
 /// <param name="undoManager">The undo manager supplier (normally the document).</param>
 /// <param name="undo">The undo-action to add.</param>
 public static void AddActionToUndoManager(XUndoManagerSupplier undoManager, XUndoAction undo)
 {
     AddActionToUndoManager(undoManager.getUndoManager(), undo);
 }