private void AcceptChanges() { // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } // cascade the call to all child objects foreach (C child in this) { child.AcceptChanges(); // if item is below its point of addition, lower point of addition if (child.EditLevelAdded > _editLevel) { child.EditLevelAdded = _editLevel; } } // cascade the call to all deleted child objects for (int index = DeletedList.Count - 1; index >= 0; index--) { C child = DeletedList[index]; child.AcceptChanges(); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { DeletedList.RemoveAt(index); } } }
private void UndoChanges() { C child; // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; child.UndoChanges(); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { bool oldAllowRemove = this.AllowRemove; try { this.AllowRemove = true; RemoveAt(index); } finally { this.AllowRemove = oldAllowRemove; } } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } }
private void UndoChanges() { if (!this.IsDirty) { return; } C child; // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; if (!child.IsDirty && !child.IsNew) { continue; } child.UndoChanges(); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { RemoveAt(index); } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } }
private void AcceptChanges(int parentEditLevel) { if (this.EditLevel - 1 != parentEditLevel) { throw new UndoException(string.Format(Resources.EditLevelMismatchException, "AcceptChanges"), this.GetType().Name, _parent != null ? _parent.GetType().Name : null, this.EditLevel, parentEditLevel + 1); } // we are coming up one edit level _editLevel -= 1; // cascade the call to all child objects foreach (C child in this) { child.AcceptChanges(_editLevel, false); // if item is below its point of addition, lower point of addition if (child.EditLevelAdded > _editLevel) { child.EditLevelAdded = _editLevel; } } // cascade the call to all deleted child objects for (int index = DeletedList.Count - 1; index >= 0; index--) { C child = DeletedList[index]; child.AcceptChanges(_editLevel, false); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { DeletedList.RemoveAt(index); } } if (_editLevel < 0) { _editLevel = 0; } }
private void UndoChanges(int parentEditLevel) { C child; if (this.EditLevel - 1 != parentEditLevel) { throw new UndoException(string.Format(Resources.EditLevelMismatchException, "UndoChanges"), this.GetType().Name, _parent != null ? _parent.GetType().Name : null, this.EditLevel, parentEditLevel + 1); } // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } bool oldRLCE = this.RaiseListChangedEvents; this.RaiseListChangedEvents = false; try { // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; //ACE: Important, make sure to remove the item prior to // it going through undo, otherwise, it will // incur a more expensive RemoveByReference operation //DeferredLoadIndexIfNotLoaded(); //_indexSet.RemoveItem(child); child.UndoChanges(_editLevel, false); //ACE: Now that we have undone the changes, we can add the item // back in the index. //_indexSet.InsertItem(child); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { bool oldAllowRemove = this.AllowRemove; try { this.AllowRemove = true; _completelyRemoveChild = true; //RemoveIndexItem(child); RemoveAt(index); } finally { _completelyRemoveChild = false; this.AllowRemove = oldAllowRemove; } } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(_editLevel, false); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } } finally { this.RaiseListChangedEvents = oldRLCE; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } }
private void UndoChanges(int parentEditLevel) { C child; if (this.EditLevel - 1 != parentEditLevel) { throw new Core.UndoException(string.Format(Resources.EditLevelMismatchException, "UndoChanges")); } // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } bool oldRLCE = this.RaiseListChangedEvents; this.RaiseListChangedEvents = false; try { // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; child.UndoChanges(_editLevel, false); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { bool oldAllowRemove = this.AllowRemove; try { this.AllowRemove = true; _completelyRemoveChild = true; RemoveAt(index); } finally { _completelyRemoveChild = false; this.AllowRemove = oldAllowRemove; } } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(_editLevel, false); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } } finally { this.RaiseListChangedEvents = oldRLCE; OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); } }