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; } }
// 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) { // 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 override void Undo(UndoEngine engine) { if (this._nextUndoAdds) { IDesignerHost requiredService = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; if (requiredService != null) { engine._serializationService.DeserializeTo(this._serializedData, requiredService.Container); } } else { IDesignerHost host2 = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; IComponent component = host2.Container.Components[this._componentName]; if (component != null) { host2.DestroyComponent(component); } } this._nextUndoAdds = !this._nextUndoAdds; }
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 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; }