コード例 #1
0
 /// <summary>
 /// Create an instance of the UndoRedoList.
 /// </summary>
 /// <param name="list">List to wrap.</param>
 /// <param name="undoRedoManager">Undo and redo manager.</param>
 public UndoRedoList(IList <T> list, UndoRedoManager undoRedoManager) :
     this(list, null, undoRedoManager)
 {
 }
コード例 #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);
            }
コード例 #3
0
ファイル: UndoRedoManager.cs プロジェクト: git-thinh/UndoRedo
 /// <summary>
 /// Create an instance of the undo and redo scope.
 /// </summary>
 /// <param name="undoRedoManager">Instance of the undo and redo manager.</param>
 /// <param name="name">Scope name.</param>
 public Scope(UndoRedoManager undoRedoManager, string name) :
     this(undoRedoManager, name, null)
 {
 }
コード例 #4
0
 /// <summary>
 /// Creates an instance of the UndoRedoTypeDescriptor.
 /// </summary>
 /// <param name="instance">Instance wrapped with UndoRedoTypeDescriptor.</param>
 /// <param name="undoRedoManager">Undo redo manager.</param>
 public UndoRedoTypeDescriptor(object instance, UndoRedoManager undoRedoManager) :
     this(instance, null, undoRedoManager)
 {
 }
コード例 #5
0
ファイル: UndoRedoManager.cs プロジェクト: git-thinh/UndoRedo
 public bool Run(UndoRedoManager undoRedoManager, ActionType type)
 {
     return(true);
 }