Esempio n. 1
0
 protected override void Modified(UndoRedoProperty property, object oldValue)
 {
     owner.OnListChanged(
         new ListChangedEventArgs2(
             ListChangedType.ItemChanged,
             index,
             property,
             oldValue));
 }
Esempio n. 2
0
            public bool Run(UndoRedoManager undoRedoManager, ActionType type)
            {
                switch (operation)
                {
                case Operation.Insert:
                {
                    int count = owner.Count;
                    int index = this.index;

                    if (type != ActionType.Undo)
                    {
                        if ((index < 0) || (index > count))
                        {
                            return(false);
                        }

                        owner.List.Insert(index, item);

                        owner.OnListChanged(
                            new ListChangedEventArgs2(ListChangedType.ItemAdded, index));
                    }
                    else
                    {
                        if ((index < 0) || (index >= count))
                        {
                            return(false);
                        }

                        owner.List.RemoveAt(index);

                        owner.OnListChanged(
                            new ListChangedEventArgs2(
                                ListChangedType.ItemDeleted,
                                index,
                                item));
                    }

                    break;
                }

                case Operation.Remove:
                {
                    type = type != ActionType.Undo ? ActionType.Undo : ActionType.Do;

                    goto case Operation.Insert;
                }

                case Operation.Set:
                {
                    if ((index < 0) || (index >= owner.Count))
                    {
                        return(false);
                    }

                    T prevItem = owner.List[index];

                    if (EqualityComparer <T> .Default.Equals(prevItem, item))
                    {
                        return(false);
                    }

                    owner.List[index] = item;
                    item = prevItem;

                    owner.OnListChanged(
                        new ListChangedEventArgs2(ListChangedType.ItemChanged, index, item));

                    break;
                }
                }

                return(true);
            }