public virtual void ComponentChanged(ComponentChangedEventArgs e) { if (_closed) { return; } // A component starts getting removed. // ComponentRemoving -> remove component -> ComponentRemoved // The problem is that someone can subscribe to the Removed event after us (the UndoEngine) - e.g // ParentControlDesigner will explicitly request (by setting it to null between Removing and Removed // the serialization of the Parent property of the removed child. // In the case where someone subscribes after and performs changes to the component, we might get // ComponentChanged events after we've already created the addremove action, but the componentchangeaction // will be incomplete standing before the addremove one. // ComponentChangeAction changeAction = null; for (int i = 0; i < _actions.Count; i++) { changeAction = _actions[i] as ComponentChangeAction; if (changeAction != null && !changeAction.IsComplete && changeAction.Component == e.Component && changeAction.Member.Equals(e.Member)) { changeAction.SetModifiedState(_engine, (IComponent)e.Component, e.Member); break; } } }
public virtual void ComponentChanging (ComponentChangingEventArgs e) { if (_closed) return; // Console.WriteLine ("New Action: ComponentChangeAction (" + ((IComponent)e.Component).Site.Name + ")"); ComponentChangeAction action = new ComponentChangeAction (); action.SetOriginalState (_engine, (IComponent) e.Component, e.Member); _actions.Add (action); }