コード例 #1
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;
                }
コード例 #2
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;
                    }
                }