示例#1
0
                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;
                }
示例#2
0
                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();
                }
示例#3
0
            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> ();
            }
示例#4
0
                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;
                }
示例#5
0
                // 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;
                }
示例#6
0
                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;
                    }
                }
示例#7
0
 public virtual void Undo(UndoEngine engine)
 {
 }
示例#8
0
 protected override void DiscardUndoUnit(UndoEngine.UndoUnit unit)
 {
     base.DiscardUndoUnit (unit);
     if (_undoUnits.Count > 0 && Object.ReferenceEquals (unit, _undoUnits.Peek ()))
         _undoUnits.Pop ();
 }
示例#9
0
 protected override void AddUndoUnit(UndoEngine.UndoUnit unit)
 {
     _undoUnits.Push (unit);
     _redoUnits.Clear ();
 }