public override void BeforeUndo(UndoEngine engine)
 {
     if (!this._savedAfterState)
     {
         this._savedAfterState = true;
         this.SaveAfterState(engine);
     }
 }
 public ChangeUndoEvent(UndoEngine engine, System.ComponentModel.Design.ComponentChangingEventArgs e, bool serializeBeforeState)
 {
     this._componentName = engine.GetName(e.Component, true);
     this._openComponent = e.Component;
     this._member        = e.Member;
     if (serializeBeforeState)
     {
         this._before = this.Serialize(engine, this._openComponent, this._member);
     }
 }
Example #3
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;
				}
Example #4
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> ();
			}
 public AddRemoveUndoEvent(UndoEngine engine, IComponent component, bool add)
 {
     this._componentName = component.Site.Name;
     this._nextUndoAdds  = !add;
     this._openComponent = component;
     using (this._serializedData = engine._serializationService.CreateStore())
     {
         engine._serializationService.Serialize(this._serializedData, component);
     }
     this._committed = add;
 }
Example #6
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 ();
				}
                public override void Undo(UndoEngine engine)
                {
                    IComponent component = engine._host.Container.Components[this._after];

                    if (component != null)
                    {
                        engine.ComponentChangeService.OnComponentChanging(component, null);
                        component.Site.Name = this._before;
                        string str = this._after;
                        this._after  = this._before;
                        this._before = str;
                    }
                }
                private SerializationStore Serialize(UndoEngine engine, object component, MemberDescriptor member)
                {
                    SerializationStore store;

                    using (store = engine._serializationService.CreateStore())
                    {
                        if ((member != null) && !member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))
                        {
                            engine._serializationService.SerializeMemberAbsolute(store, component, member);
                            return(store);
                        }
                        engine._serializationService.SerializeAbsolute(store, component);
                    }
                    return(store);
                }
                public override void Undo(UndoEngine engine)
                {
                    if (this._before != null)
                    {
                        IDesignerHost service = engine.GetService(typeof(IDesignerHost)) as IDesignerHost;
                        if (service != null)
                        {
                            engine._serializationService.DeserializeTo(this._before, service.Container);
                        }
                    }
                    SerializationStore store = this._after;

                    this._after  = this._before;
                    this._before = store;
                }
Example #10
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;
				}
Example #11
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;
					}
				}
Example #12
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;
				}
 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;
 }
                private void SaveAfterState(UndoEngine engine)
                {
                    object            component = null;
                    IReferenceService service   = engine.GetService(typeof(IReferenceService)) as IReferenceService;

                    if (service != null)
                    {
                        component = service.GetReference(this._componentName);
                    }
                    else
                    {
                        IDesignerHost host = engine.GetService(typeof(IDesignerHost)) as IDesignerHost;
                        if (host != null)
                        {
                            component = host.Container.Components[this._componentName];
                        }
                    }
                    if (component != null)
                    {
                        this._after = this.Serialize(engine, component, this._member);
                    }
                }
 public abstract void Undo(UndoEngine engine);
 public virtual void BeforeUndo(UndoEngine engine)
 {
 }
Example #17
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;
					}
				}
 public override void Undo(UndoEngine engine)
 {
     if (this._before != null)
     {
         IDesignerHost service = engine.GetService(typeof(IDesignerHost)) as IDesignerHost;
         if (service != null)
         {
             engine._serializationService.DeserializeTo(this._before, service.Container);
         }
     }
     SerializationStore store = this._after;
     this._after = this._before;
     this._before = store;
 }
Example #19
0
		protected virtual void DiscardUndoUnit (UndoEngine.UndoUnit unit)
		{
			// Console.WriteLine ("DiscardUndoUnit: " + unit.Name);
		}
Example #20
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;
				}
 protected override void AddUndoUnit(UndoEngine.UndoUnit unit)
 {
     undoStack.Push(unit);
 }
 internal void Commit(UndoEngine engine)
 {
     if (!this.Committed)
     {
         this._committed = true;
     }
 }
 public void Commit(UndoEngine engine)
 {
     if (!this.Committed)
     {
         this._openComponent = null;
     }
 }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     this.host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (((ToolStripKeyboardHandlingService) this.GetService(typeof(ToolStripKeyboardHandlingService))) == null)
     {
         ToolStripKeyboardHandlingService service = new ToolStripKeyboardHandlingService(component.Site);
     }
     if (((ISupportInSituService) this.GetService(typeof(ISupportInSituService))) == null)
     {
         ISupportInSituService service2 = new ToolStripInSituService(base.Component.Site);
     }
     this.dropDown = (ToolStripDropDown) base.Component;
     this.dropDown.Visible = false;
     this.AutoClose = this.dropDown.AutoClose;
     this.AllowDrop = this.dropDown.AllowDrop;
     this.selSvc = (ISelectionService) this.GetService(typeof(ISelectionService));
     if (this.selSvc != null)
     {
         if ((this.host != null) && !this.host.Loading)
         {
             this.selSvc.SetSelectedComponents(new IComponent[] { this.host.RootComponent }, SelectionTypes.Replace);
         }
         this.selSvc.SelectionChanging += new EventHandler(this.OnSelectionChanging);
         this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.designMenu = new MenuStrip();
     this.designMenu.Visible = false;
     this.designMenu.AutoSize = false;
     this.designMenu.Dock = DockStyle.Top;
     Control rootComponent = this.host.RootComponent as Control;
     if (rootComponent != null)
     {
         this.menuItem = new ToolStripMenuItem();
         this.menuItem.BackColor = SystemColors.Window;
         this.menuItem.Name = base.Component.Site.Name;
         this.menuItem.Text = (this.dropDown != null) ? this.dropDown.GetType().Name : this.menuItem.Name;
         this.designMenu.Items.Add(this.menuItem);
         rootComponent.Controls.Add(this.designMenu);
         this.designMenu.SendToBack();
         this.nestedContainer = this.GetService(typeof(INestedContainer)) as INestedContainer;
         if (this.nestedContainer != null)
         {
             this.nestedContainer.Add(this.menuItem, "ContextMenuStrip");
         }
     }
     new EditorServiceContext(this, TypeDescriptor.GetProperties(base.Component)["Items"], System.Design.SR.GetString("ToolStripItemCollectionEditorVerb"));
     if (this.undoEngine == null)
     {
         this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine;
         if (this.undoEngine != null)
         {
             this.undoEngine.Undone += new EventHandler(this.OnUndone);
         }
     }
 }
 public override void BeforeUndo(UndoEngine engine)
 {
     if (!this._savedAfterState)
     {
         this._savedAfterState = true;
         this.SaveAfterState(engine);
     }
 }
 public ChangeUndoEvent(UndoEngine engine, System.ComponentModel.Design.ComponentChangingEventArgs e, bool serializeBeforeState)
 {
     this._componentName = engine.GetName(e.Component, true);
     this._openComponent = e.Component;
     this._member = e.Member;
     if (serializeBeforeState)
     {
         this._before = this.Serialize(engine, this._openComponent, this._member);
     }
 }
 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 override void Undo(UndoEngine engine)
 {
     IComponent component = engine._host.Container.Components[this._after];
     if (component != null)
     {
         engine.ComponentChangeService.OnComponentChanging(component, null);
         component.Site.Name = this._before;
         string str = this._after;
         this._after = this._before;
         this._before = str;
     }
 }
 private void OnDesignerActivate(object source, EventArgs evevent)
 {
     if (this.undoEngine == null)
     {
         this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine;
         if (this.undoEngine != null)
         {
             this.undoEngine.Undoing += new EventHandler(this.OnUndoing);
             this.undoEngine.Undone += new EventHandler(this.OnUndone);
         }
     }
 }
 private void SaveAfterState(UndoEngine engine)
 {
     object component = null;
     IReferenceService service = engine.GetService(typeof(IReferenceService)) as IReferenceService;
     if (service != null)
     {
         component = service.GetReference(this._componentName);
     }
     else
     {
         IDesignerHost host = engine.GetService(typeof(IDesignerHost)) as IDesignerHost;
         if (host != null)
         {
             component = host.Container.Components[this._componentName];
         }
     }
     if (component != null)
     {
         this._after = this.Serialize(engine, component, this._member);
     }
 }
 public AddRemoveUndoEvent(UndoEngine engine, IComponent component, bool add)
 {
     this._componentName = component.Site.Name;
     this._nextUndoAdds = !add;
     this._openComponent = component;
     using (this._serializedData = engine._serializationService.CreateStore())
     {
         engine._serializationService.Serialize(this._serializedData, component);
     }
     this._committed = add;
 }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     base.AutoResizeHandles = true;
     this.host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (this.host != null)
     {
         this.componentChangeSvc = (IComponentChangeService) this.host.GetService(typeof(IComponentChangeService));
     }
     if (this.undoEngine == null)
     {
         this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine;
         if (this.undoEngine != null)
         {
             this.undoEngine.Undoing += new EventHandler(this.OnUndoing);
             this.undoEngine.Undone += new EventHandler(this.OnUndone);
         }
     }
     this.editManager = new ToolStripEditorManager(component);
     if (this.Control.IsHandleCreated)
     {
         this.InitializeNewItemDropDown();
     }
     else
     {
         this.Control.HandleCreated += new EventHandler(this.Control_HandleCreated);
     }
     if (this.componentChangeSvc != null)
     {
         this.componentChangeSvc.ComponentRemoved += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved);
         this.componentChangeSvc.ComponentRemoving += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving);
         this.componentChangeSvc.ComponentAdded += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded);
         this.componentChangeSvc.ComponentAdding += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding);
         this.componentChangeSvc.ComponentChanged += new ComponentChangedEventHandler(this.ComponentChangeSvc_ComponentChanged);
     }
     this.toolStripAdornerWindowService = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService));
     this.SelectionService.SelectionChanging += new EventHandler(this.selSvc_SelectionChanging);
     this.SelectionService.SelectionChanged += new EventHandler(this.selSvc_SelectionChanged);
     this.ToolStrip.Resize += new EventHandler(this.ToolStrip_Resize);
     this.ToolStrip.DockChanged += new EventHandler(this.ToolStrip_Resize);
     this.ToolStrip.LayoutCompleted += new EventHandler(this.ToolStrip_LayoutCompleted);
     this.ToolStrip.OverflowButton.DropDown.TopLevel = false;
     if (this.CanAddItems)
     {
         new EditorServiceContext(this, TypeDescriptor.GetProperties(base.Component)["Items"], System.Design.SR.GetString("ToolStripItemCollectionEditorVerb"));
         this.keyboardHandlingService = (ToolStripKeyboardHandlingService) this.GetService(typeof(ToolStripKeyboardHandlingService));
         if (this.keyboardHandlingService == null)
         {
             this.keyboardHandlingService = new ToolStripKeyboardHandlingService(base.Component.Site);
         }
         if (((ISupportInSituService) this.GetService(typeof(ISupportInSituService))) == null)
         {
             ISupportInSituService service = new ToolStripInSituService(base.Component.Site);
         }
     }
     this.toolStripSelected = true;
     if (this.keyboardHandlingService != null)
     {
         this.KeyboardHandlingService.SelectedDesignerControl = null;
     }
 }
Example #33
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;
				}
Example #34
0
 public virtual void Undo(UndoEngine engine)
 {
 }
        /// <summary>
        /// ���� UndoEngine.UndoUnit��
        /// </summary>
        /// <param name="unit"></param>
        protected override void DiscardUndoUnit(UndoEngine.UndoUnit unit)
        {
            //undoUnitList.Remove(unit);
            base.DiscardUndoUnit(unit);

            if (cassPropertyGrid != null)
            {
                cassPropertyGrid.Refresh();
            }
            //this.Enabled = false;
        }
Example #36
0
		protected abstract void AddUndoUnit (UndoEngine.UndoUnit unit);
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     base.Visible = true;
     this.DoubleClickEnabled = this.MenuItem.DoubleClickEnabled;
     this.selSvc = (ISelectionService) this.GetService(typeof(ISelectionService));
     if (this.selSvc != null)
     {
         this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.toolStripAdornerWindowService = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService));
     this.designerHost = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     this.MenuItem.DoubleClickEnabled = true;
     IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentRemoved += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved);
         service.ComponentRemoving += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving);
         service.ComponentAdding += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding);
         service.ComponentAdded += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded);
     }
     if (this.undoEngine == null)
     {
         this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine;
         if (this.undoEngine != null)
         {
             this.undoEngine.Undoing += new EventHandler(this.OnUndoing);
             this.undoEngine.Undone += new EventHandler(this.OnUndone);
         }
     }
 }
Example #38
0
				public virtual void Undo (UndoEngine engine)
				{
				}
 public virtual void BeforeUndo(UndoEngine engine)
 {
 }
Example #40
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;
				}
 public abstract void Undo(UndoEngine engine);
Example #42
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 ();
				}
 private SerializationStore Serialize(UndoEngine engine, object component, MemberDescriptor member)
 {
     SerializationStore store;
     using (store = engine._serializationService.CreateStore())
     {
         if ((member != null) && !member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))
         {
             engine._serializationService.SerializeMemberAbsolute(store, component, member);
             return store;
         }
         engine._serializationService.SerializeAbsolute(store, component);
     }
     return store;
 }
Example #44
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> ();
			}
        /// <summary>
        /// �� UndoEngine.UndoUnit ��ӵ�������ջ�С�
        /// </summary>
        /// <param name="unit"></param>
        protected override void AddUndoUnit(UndoEngine.UndoUnit unit)
        {
            tempUnList.Add(unit);

            if (editToolStripMenuItem.DropDownItems.Count > 0)
            {
                editToolStripMenuItem.DropDownItems[undoIndex].Enabled = true;
            }

            if (cassPropertyGrid != null)
            {
                cassPropertyGrid.Refresh();
            }
            //this.Enabled = false;
        }