public override void Undo(UndoEngine engine) { // Console.WriteLine ("ComponentRenameAction.Undo (" + _currentName + "): " + _oldName); IDesignerHost host = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; IComponent component = host.Container.Components[_currentName]; component.Site.Name = _oldName; string tmp = _currentName; _currentName = _oldName; _oldName = tmp; }
public void SetModifiedState(UndoEngine engine, IComponent component, MemberDescriptor member) { // Console.WriteLine ("ComponentChangeAction.SetModifiedState (" + (_componentName != null ? (_componentName + ".") : "") + // member.Name + "): " + // (((PropertyDescriptor)member).GetValue (component) == null ? "null" : // ((PropertyDescriptor)member).GetValue (component).ToString ())); ComponentSerializationService serializationService = engine.GetRequiredService( typeof(ComponentSerializationService)) as ComponentSerializationService; _afterChange = serializationService.CreateStore(); serializationService.SerializeMemberAbsolute(_afterChange, component, member); _afterChange.Close(); }
public UndoUnit(UndoEngine engine, string name) { if (engine == null) { throw new ArgumentNullException("engine"); } if (name == null) { throw new ArgumentNullException("name"); } _engine = engine; _name = name; _actions = new List <Action> (); }
public ComponentAddRemoveAction(UndoEngine engine, IComponent component, bool added) { if (component == null) { throw new ArgumentNullException("component"); } // Console.WriteLine ((added ? "Component*Add*RemoveAction" : "ComponentAdd*Remove*Action") + // " (" + component.Site.Name + ")"); ComponentSerializationService serializationService = engine.GetRequiredService( typeof(ComponentSerializationService)) as ComponentSerializationService; _serializedComponent = serializationService.CreateStore(); serializationService.Serialize(_serializedComponent, component); _serializedComponent.Close(); _added = added; _componentName = component.Site.Name; }
// Reminder: _component might no longer be a valid instance // so one should request a new one. // public override void Undo(UndoEngine engine) { if (_beforeChange == null) { // Console.WriteLine ("ComponentChangeAction.Undo: ERROR: UndoUnit is not complete."); return; } // Console.WriteLine ("ComponentChangeAction.Undo (" + _componentName + "." + _member.Name + ")"); IDesignerHost host = (IDesignerHost)engine.GetRequiredService(typeof(IDesignerHost)); _component = host.Container.Components[_componentName]; ComponentSerializationService serializationService = engine.GetRequiredService( typeof(ComponentSerializationService)) as ComponentSerializationService; serializationService.DeserializeTo(_beforeChange, host.Container); SerializationStore tmp = _beforeChange; _beforeChange = _afterChange; _afterChange = tmp; }
public override void Undo(UndoEngine engine) { IDesignerHost host = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; if (_added) { // Console.WriteLine ("Component*Add*RemoveAction.Undo (" + _componentName + ")"); IComponent component = host.Container.Components[_componentName]; if (component != null) // the component might have been destroyed already { host.DestroyComponent(component); } _added = false; } else { // Console.WriteLine ("ComponentAdd*Remove*Action.Undo (" + _componentName + ")"); ComponentSerializationService serializationService = engine.GetRequiredService( typeof(ComponentSerializationService)) as ComponentSerializationService; serializationService.DeserializeTo(_serializedComponent, host.Container); _added = true; } }
public virtual void Undo(UndoEngine engine) { }
protected override void DiscardUndoUnit(UndoEngine.UndoUnit unit) { base.DiscardUndoUnit (unit); if (_undoUnits.Count > 0 && Object.ReferenceEquals (unit, _undoUnits.Peek ())) _undoUnits.Pop (); }
protected override void AddUndoUnit(UndoEngine.UndoUnit unit) { _undoUnits.Push (unit); _redoUnits.Clear (); }