예제 #1
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();
                }
예제 #2
0
        ICollection IDesignerSerializationService.Deserialize(object serializationData)
        {
            if (serializationData == null)
            {
                throw new ArgumentNullException("serializationData");
            }

            ComponentSerializationService service = LoaderHost.GetService(typeof(ComponentSerializationService)) as ComponentSerializationService;
            SerializationStore            store   = serializationData as SerializationStore;

            if (service != null && serializationData != null)
            {
                return(service.Deserialize(store, this.LoaderHost.Container));
            }
            return(new object[0]);
        }
예제 #3
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;
                }
예제 #4
0
        object IDesignerSerializationService.Serialize(ICollection objects)
        {
            if (objects == null)
            {
                throw new ArgumentNullException("objects");
            }

            ComponentSerializationService service = LoaderHost.GetService(typeof(ComponentSerializationService)) as ComponentSerializationService;

            if (service != null)
            {
                SerializationStore store = service.CreateStore();
                foreach (object o in objects)
                {
                    service.Serialize(store, o);
                }
                store.Close();
                return(store);
            }
            return(null);
        }
예제 #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;
                    }
                }