Ejemplo n.º 1
0
 protected override void Modified(UndoRedoProperty property, object oldValue)
 {
     owner.OnListChanged(
         new ListChangedEventArgs2(
             ListChangedType.ItemChanged,
             index,
             property,
             oldValue));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets property owner.
        /// </summary>
        /// <param name="pd">Property descriptor.</param>
        /// <returns>Property owner instance.</returns>
        public virtual object GetPropertyOwner(PropertyDescriptor pd)
        {
            UndoRedoProperty property = pd as UndoRedoProperty;

            if (property != null)
            {
                return(Instance);
            }

            return(null);
        }
Ejemplo n.º 3
0
        protected override void Modified(UndoRedoProperty property, object oldValue)
        {
            base.Modified(property, oldValue);

            EventHandler eventHandler = OnChanged;

            if (eventHandler != null)
            {
                eventHandler(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 4
0
        private static PropertyDescriptorCollection CreateProperties(
            PropertyDescriptorCollection collection)
        {
            int count = collection.Count;

            PropertyDescriptor[] items = new PropertyDescriptor[count];

            for (int i = 0; i < count; i++)
            {
                items[i] = new UndoRedoProperty(collection[i]);
            }

            return(new PropertyDescriptorCollection(items, true));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Tests if two instances are equal.
        /// </summary>
        /// <param name="obj">Instance to compare with.</param>
        /// <returns>true if instances are equal, and false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            UndoRedoProperty that = obj as UndoRedoProperty;

            if (that == null)
            {
                return(false);
            }

            return(parent.Equals(that.parent));
        }
Ejemplo n.º 6
0
            /// <summary>
            /// Creates an instance of the Action.
            /// </summary>
            /// <param name="owner">Owner type.</param>
            /// <param name="property">Property to change.</param>
            /// <param name="value">Value of the property.</param>
            public Action(
                UndoRedoWrapper owner,
                UndoRedoProperty property,
                object value)
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner");
                }

                if (property == null)
                {
                    throw new ArgumentNullException("property");
                }

                this.owner    = owner;
                this.property = property;
                this.value    = value;
            }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets or sets property of the instance.
        /// Action is recorded in undo and redo manager.
        /// </summary>
        /// <param name="property">Property to get or set.</param>
        /// <returns>Property value.</returns>
        public object this[PropertyDescriptor property]
        {
            get
            {
                if (property == null)
                {
                    throw new InvalidOperationException("property");
                }

                UndoRedoProperty undoRedoProperty = property as UndoRedoProperty;

                if (undoRedoProperty != null)
                {
                    return(undoRedoProperty.GetValue(this));
                }
                else
                {
                    return(property.GetValue(Instance));
                }
            }
            set
            {
                if (property == null)
                {
                    throw new InvalidOperationException("property");
                }

                UndoRedoProperty undoRedoProperty = property as UndoRedoProperty;

                if (undoRedoProperty != null)
                {
                    undoRedoProperty.SetValue(this, value);
                }
                else
                {
                    property.SetValue(Instance, value);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Occurs when propery has changed.
 /// </summary>
 /// <param name="property">Property that has changed.</param>
 /// <param name="oldValue">An old value of the property.</param>
 protected virtual void Modified(UndoRedoProperty property, object oldValue)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Create undo and redo property change action.
 /// </summary>
 /// <param name="property">Property to change.</param>
 /// <param name="value">Property value.</param>
 /// <returns>Instance of an action.</returns>
 public virtual IAction CreateAction(
     UndoRedoProperty property,
     object value)
 {
     return(new Action(this, property, value));
 }
Ejemplo n.º 10
0
 public MethodAction(UndoRedoWrapper owner, UndoRedoProperty property, object value)
 {
     this.owner    = owner;
     this.property = property;
     this.value    = value;
 }