Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@782 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 74 additions and 694 deletions
@ -1,66 +0,0 @@ |
|||||||
//// <file>
|
|
||||||
//// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
//// <license see="prj:///doc/license.txt"/>
|
|
||||||
//// <owner name="Mike Krger" email="mike@icsharpcode.net"/>
|
|
||||||
//// <version value="$version"/>
|
|
||||||
//// </file>
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using System.IO;
|
|
||||||
//using System.Collections;
|
|
||||||
//using System.Drawing;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
//using System.Reflection;
|
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Printing;
|
|
||||||
//using System.ComponentModel;
|
|
||||||
//using System.ComponentModel.Design;
|
|
||||||
//using System.Xml;
|
|
||||||
//using System.ComponentModel.Design.Serialization;
|
|
||||||
//using ICSharpCode.SharpDevelop.Project;
|
|
||||||
//using ICSharpCode.SharpDevelop.Internal.Undo;
|
|
||||||
//using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.Core;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.FormDesigner.Services;
|
|
||||||
//using ICSharpCode.TextEditor;
|
|
||||||
//
|
|
||||||
//using System.CodeDom;
|
|
||||||
//using System.CodeDom.Compiler;
|
|
||||||
//
|
|
||||||
//using Microsoft.CSharp;
|
|
||||||
//using Microsoft.VisualBasic;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.ErrorDialogs;
|
|
||||||
//using ICSharpCode.FormDesigner.Gui;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
|
||||||
//
|
|
||||||
//namespace ICSharpCode.FormDesigner {
|
|
||||||
//
|
|
||||||
// public class ComponentAddedUndoAction : ICSharpCode.SharpDevelop.Internal.Undo.IUndoableOperation
|
|
||||||
// {
|
|
||||||
// IDesignerHost host;
|
|
||||||
//
|
|
||||||
// Type componentType;
|
|
||||||
// string componentName;
|
|
||||||
//
|
|
||||||
// public ComponentAddedUndoAction(IDesignerHost host, ComponentEventArgs cea)
|
|
||||||
// {
|
|
||||||
// this.host = host;
|
|
||||||
// componentName = cea.Component.Site.Name;
|
|
||||||
// componentType = cea.Component.GetType();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Undo()
|
|
||||||
// {
|
|
||||||
// host.DestroyComponent(host.Container.Components[componentName]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Redo()
|
|
||||||
// {
|
|
||||||
// host.CreateComponent(componentType, componentName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,190 +0,0 @@ |
|||||||
//// <file>
|
|
||||||
//// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
//// <license see="prj:///doc/license.txt"/>
|
|
||||||
//// <owner name="Mike Krger" email="mike@icsharpcode.net"/>
|
|
||||||
//// <version value="$version"/>
|
|
||||||
//// </file>
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using System.IO;
|
|
||||||
//using System.Collections;
|
|
||||||
//using System.Drawing;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
//using System.Reflection;
|
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Printing;
|
|
||||||
//using System.ComponentModel;
|
|
||||||
//using System.ComponentModel.Design;
|
|
||||||
//using System.Xml;
|
|
||||||
//using System.ComponentModel.Design.Serialization;
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui;
|
|
||||||
//using ICSharpCode.SharpDevelop.Project;
|
|
||||||
//using ICSharpCode.SharpDevelop.Internal.Undo;
|
|
||||||
//using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.Core;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.FormDesigner.Services;
|
|
||||||
//using ICSharpCode.TextEditor;
|
|
||||||
//
|
|
||||||
//using System.CodeDom;
|
|
||||||
//using System.CodeDom.Compiler;
|
|
||||||
//
|
|
||||||
//using Microsoft.CSharp;
|
|
||||||
//using Microsoft.VisualBasic;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.ErrorDialogs;
|
|
||||||
//using ICSharpCode.FormDesigner.Gui;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
|
||||||
//
|
|
||||||
//namespace ICSharpCode.FormDesigner {
|
|
||||||
//
|
|
||||||
// public class ComponentChangedUndoAction : ICSharpCode.SharpDevelop.Internal.Undo.IUndoableOperation
|
|
||||||
// {
|
|
||||||
// IDesignerHost host;
|
|
||||||
//
|
|
||||||
// string componentName;
|
|
||||||
// MemberDescriptor member;
|
|
||||||
// bool isCollection;
|
|
||||||
// bool isComponentCollection;
|
|
||||||
// object oldValue = null;
|
|
||||||
// object newValue = null;
|
|
||||||
//
|
|
||||||
// public ComponentChangedUndoAction(IDesignerHost host, ComponentChangedEventArgs ea)
|
|
||||||
// {
|
|
||||||
// this.host = host;
|
|
||||||
// IComponent component = ea.Component as IComponent;
|
|
||||||
// if (component == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.member = ea.Member;
|
|
||||||
// this.componentName = component.Site.Name;
|
|
||||||
//
|
|
||||||
// isCollection = ea.NewValue is IList;
|
|
||||||
//
|
|
||||||
// if (isCollection) {
|
|
||||||
// IList oldCol = (IList)ea.OldValue;
|
|
||||||
// IList newCol = (IList)ea.NewValue;
|
|
||||||
// object[] newArray = new object[newCol.Count];
|
|
||||||
// isComponentCollection = false;
|
|
||||||
// if (newCol.Count > 0) {
|
|
||||||
// isComponentCollection = newCol[0] is IComponent;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (oldCol != null) {
|
|
||||||
// object[] oldArray = new object[oldCol.Count];
|
|
||||||
// if (isComponentCollection) {
|
|
||||||
// int idx = 0;
|
|
||||||
// foreach (IComponent cmp in oldCol) {
|
|
||||||
// oldArray[idx++] = cmp.Site.Name;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// oldCol.CopyTo(oldArray, 0);
|
|
||||||
// }
|
|
||||||
// this.oldValue = oldArray;
|
|
||||||
// }
|
|
||||||
// if (isComponentCollection) {
|
|
||||||
// int idx = 0;
|
|
||||||
// foreach (IComponent cmp in newCol) {
|
|
||||||
// newArray[idx++] = cmp.Site.Name;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// newCol.CopyTo(newArray, 0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.newValue = newArray;
|
|
||||||
// } else {
|
|
||||||
// this.oldValue = ea.OldValue;
|
|
||||||
// this.newValue = ea.NewValue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Undo()
|
|
||||||
// {
|
|
||||||
// ComponentChangeService componentChangeService = (ComponentChangeService)host.GetService(typeof(System.ComponentModel.Design.IComponentChangeService));
|
|
||||||
//
|
|
||||||
// IComponent component = host.Container.Components[componentName];
|
|
||||||
// componentChangeService.OnComponentChanging(component, member);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Type t = component.GetType();
|
|
||||||
//
|
|
||||||
// PropertyInfo pInfo = t.Get(member.Name);
|
|
||||||
// if (isCollection) {
|
|
||||||
// IList coll = (IList)pInfo.GetValue(component, null);
|
|
||||||
//
|
|
||||||
// if (isComponentCollection) {
|
|
||||||
// int idx = 0;
|
|
||||||
// foreach (string name in (object[])oldValue) {
|
|
||||||
// try {
|
|
||||||
// if (coll is Menu.MenuItemCollection) {
|
|
||||||
// ((Menu.MenuItemCollection)coll).Add(idx++, (MenuItem)host.Container.Components[name]);
|
|
||||||
// } else {
|
|
||||||
// coll.Add(host.Container.Components[name]);
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
//
|
|
||||||
// MessageService.ShowError(e, "Can't add " + name + " to collection.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// foreach (object o in (object[])oldValue) {
|
|
||||||
// coll.Add(o);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// pInfo.SetValue(component, oldValue, null);
|
|
||||||
// }
|
|
||||||
// componentChangeService.OnComponentChanged(component,
|
|
||||||
// member,
|
|
||||||
// newValue,
|
|
||||||
// oldValue);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Redo()
|
|
||||||
// {
|
|
||||||
// ComponentChangeService componentChangeService = (ComponentChangeService)host.GetService(typeof(System.ComponentModel.Design.IComponentChangeService));
|
|
||||||
//
|
|
||||||
// IComponent component = host.Container.Components[componentName];
|
|
||||||
// componentChangeService.OnComponentChanging(component, member);
|
|
||||||
// Type t = component.GetType();
|
|
||||||
// if (isCollection) {
|
|
||||||
// IList coll = (IList)t.InvokeMember(member.Name,
|
|
||||||
// BindingFlags.Public |
|
|
||||||
// BindingFlags.NonPublic |
|
|
||||||
// BindingFlags.Instance |
|
|
||||||
// BindingFlags.FlattenHierarchy |
|
|
||||||
// BindingFlags.GetProperty,
|
|
||||||
// null,
|
|
||||||
// component,
|
|
||||||
// null);
|
|
||||||
// coll.Clear();
|
|
||||||
// if (isComponentCollection) {
|
|
||||||
// foreach (string name in (object[])newValue) {
|
|
||||||
// coll.Add(host.Container.Components[name]);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// foreach (object o in (object[])newValue) {
|
|
||||||
// coll.Add(o);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// t.InvokeMember(member.Name,
|
|
||||||
// BindingFlags.Public |
|
|
||||||
// BindingFlags.NonPublic |
|
|
||||||
// BindingFlags.Instance |
|
|
||||||
// BindingFlags.FlattenHierarchy |
|
|
||||||
// BindingFlags.SetProperty,
|
|
||||||
// null,
|
|
||||||
// component,
|
|
||||||
// new object[] { newValue });
|
|
||||||
// }
|
|
||||||
// componentChangeService.OnComponentChanged(component,
|
|
||||||
// member,
|
|
||||||
// oldValue,
|
|
||||||
// newValue);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,89 +0,0 @@ |
|||||||
//// <file>
|
|
||||||
//// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
//// <license see="prj:///doc/license.txt"/>
|
|
||||||
//// <owner name="Mike Krger" email="mike@icsharpcode.net"/>
|
|
||||||
//// <version value="$version"/>
|
|
||||||
//// </file>
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using System.IO;
|
|
||||||
//using System.Collections;
|
|
||||||
//using System.Drawing;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
//using System.Reflection;
|
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Printing;
|
|
||||||
//using System.ComponentModel;
|
|
||||||
//using System.ComponentModel.Design;
|
|
||||||
//using System.Xml;
|
|
||||||
//using System.ComponentModel.Design.Serialization;
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui;
|
|
||||||
//using ICSharpCode.SharpDevelop.Project;
|
|
||||||
//using ICSharpCode.SharpDevelop.Internal.Undo;
|
|
||||||
//using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//using ICSharpCode.FormDesigner.Services;
|
|
||||||
//using ICSharpCode.Core;
|
|
||||||
//using ICSharpCode.TextEditor;
|
|
||||||
//
|
|
||||||
//using System.CodeDom;
|
|
||||||
//using System.CodeDom.Compiler;
|
|
||||||
//
|
|
||||||
//using Microsoft.CSharp;
|
|
||||||
//using Microsoft.VisualBasic;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.ErrorDialogs;
|
|
||||||
//using ICSharpCode.FormDesigner.Gui;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
|
||||||
//
|
|
||||||
//namespace ICSharpCode.FormDesigner {
|
|
||||||
//
|
|
||||||
// public class ComponentRemovedUndoAction : ICSharpCode.SharpDevelop.Internal.Undo.IUndoableOperation
|
|
||||||
// {
|
|
||||||
// IDesignerHost host;
|
|
||||||
//
|
|
||||||
// Type componentType;
|
|
||||||
// string componentName;
|
|
||||||
// string parent;
|
|
||||||
// IComponent oldComponent;
|
|
||||||
//
|
|
||||||
// public ComponentRemovedUndoAction(IDesignerHost host, ComponentEventArgs cea, string parent)
|
|
||||||
// {
|
|
||||||
// this.host = host;
|
|
||||||
// oldComponent = cea.Component;
|
|
||||||
// componentName = cea.Component.Site.Name;
|
|
||||||
// componentType = cea.Component.GetType();
|
|
||||||
// this.parent = parent;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Undo()
|
|
||||||
// {
|
|
||||||
// IComponent component = host.CreateComponent(componentType, componentName);
|
|
||||||
// if (parent != null && parent.Length > 0) {
|
|
||||||
// IComponent parentCtrl = host.Container.Components[parent];
|
|
||||||
// ((Control)parentCtrl).Controls.Add((Control)component);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(oldComponent.GetType());
|
|
||||||
// foreach (PropertyDescriptor pd in properties) {
|
|
||||||
// try {
|
|
||||||
// if (pd.ShouldSerializeValue(oldComponent) && pd.IsBrowsable) {
|
|
||||||
// if (pd.Name == "Visible") {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// pd.SetValue(component, pd.GetValue(oldComponent));
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Redo()
|
|
||||||
// {
|
|
||||||
// host.DestroyComponent(host.Container.Components[componentName]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -0,0 +1,62 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Design; |
||||||
|
|
||||||
|
namespace ICSharpCode.FormDesigner.FormDesigner.UndoRedo |
||||||
|
{ |
||||||
|
public class FormDesignerUndoEngine : UndoEngine, IUndoHandler |
||||||
|
{ |
||||||
|
Stack<UndoEngine.UndoUnit> undoStack = new Stack<UndoEngine.UndoUnit>(); |
||||||
|
Stack<UndoEngine.UndoUnit> redoStack = new Stack<UndoEngine.UndoUnit>(); |
||||||
|
|
||||||
|
public FormDesignerUndoEngine(IServiceProvider provider) : base(provider) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
#region IUndoHandler
|
||||||
|
public bool EnableUndo { |
||||||
|
get { |
||||||
|
return undoStack.Count > 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableRedo { |
||||||
|
get { |
||||||
|
return redoStack.Count > 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Undo() |
||||||
|
{ |
||||||
|
if (undoStack.Count > 0) { |
||||||
|
UndoEngine.UndoUnit unit = undoStack.Pop(); |
||||||
|
unit.Undo(); |
||||||
|
redoStack.Push(unit); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Redo() |
||||||
|
{ |
||||||
|
if (redoStack.Count > 0) { |
||||||
|
UndoEngine.UndoUnit unit = redoStack.Pop(); |
||||||
|
unit.Undo(); |
||||||
|
undoStack.Push(unit); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void AddUndoUnit(UndoEngine.UndoUnit unit) |
||||||
|
{ |
||||||
|
undoStack.Push(unit); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,71 +0,0 @@ |
|||||||
//// <file>
|
|
||||||
//// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
//// <license see="prj:///doc/license.txt"/>
|
|
||||||
//// <owner name="Mike Krger" email="mike@icsharpcode.net"/>
|
|
||||||
//// <version value="$version"/>
|
|
||||||
//// </file>
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using System.IO;
|
|
||||||
//using System.Collections;
|
|
||||||
//using System.Drawing;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
//using System.Reflection;
|
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Printing;
|
|
||||||
//using System.ComponentModel;
|
|
||||||
//using System.ComponentModel.Design;
|
|
||||||
//using System.Xml;
|
|
||||||
//using System.ComponentModel.Design.Serialization;
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui;
|
|
||||||
//using ICSharpCode.SharpDevelop.Project;
|
|
||||||
//using ICSharpCode.SharpDevelop.Internal.Undo;
|
|
||||||
//using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//using ICSharpCode.FormDesigner.Services;
|
|
||||||
//using ICSharpCode.Core;
|
|
||||||
//using ICSharpCode.TextEditor;
|
|
||||||
//
|
|
||||||
//using System.CodeDom;
|
|
||||||
//using System.CodeDom.Compiler;
|
|
||||||
//
|
|
||||||
//using Microsoft.CSharp;
|
|
||||||
//using Microsoft.VisualBasic;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.ErrorDialogs;
|
|
||||||
//using ICSharpCode.FormDesigner.Gui;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
|
||||||
//
|
|
||||||
//namespace ICSharpCode.FormDesigner {
|
|
||||||
//
|
|
||||||
// public class SelectComponentsUndoAction : ICSharpCode.SharpDevelop.Internal.Undo.IUndoableOperation
|
|
||||||
// {
|
|
||||||
// IDesignerHost host;
|
|
||||||
//
|
|
||||||
// ArrayList oldComponentNames;
|
|
||||||
// ArrayList newComponentNames;
|
|
||||||
//
|
|
||||||
// public SelectComponentsUndoAction(IDesignerHost host, ArrayList oldComponentNames)
|
|
||||||
// {
|
|
||||||
// this.host = host;
|
|
||||||
// this.oldComponentNames = oldComponentNames;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void SetNewSelection(ArrayList newComponentNames)
|
|
||||||
// {
|
|
||||||
// this.newComponentNames = newComponentNames;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Undo()
|
|
||||||
// {
|
|
||||||
// UndoHandler.SetSelectedComponentsPerName(host, oldComponentNames);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Redo()
|
|
||||||
// {
|
|
||||||
// UndoHandler.SetSelectedComponentsPerName(host, newComponentNames);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,266 +0,0 @@ |
|||||||
//// <version value="$version"/>
|
|
||||||
//// </file>
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using System.IO;
|
|
||||||
//using System.Collections;
|
|
||||||
//using System.Drawing;
|
|
||||||
//using System.Drawing.Design;
|
|
||||||
//using System.Reflection;
|
|
||||||
//using System.Windows.Forms;
|
|
||||||
//using System.Drawing.Printing;
|
|
||||||
//using System.ComponentModel;
|
|
||||||
//using System.ComponentModel.Design;
|
|
||||||
//using System.Xml;
|
|
||||||
//using System.ComponentModel.Design.Serialization;
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui;
|
|
||||||
//using ICSharpCode.SharpDevelop.Project;
|
|
||||||
//using ICSharpCode.SharpDevelop.Internal.Undo;
|
|
||||||
//using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.Core;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.FormDesigner.Services;
|
|
||||||
//using ICSharpCode.TextEditor;
|
|
||||||
//
|
|
||||||
//using System.CodeDom;
|
|
||||||
//using System.CodeDom.Compiler;
|
|
||||||
//
|
|
||||||
//using Microsoft.CSharp;
|
|
||||||
//using Microsoft.VisualBasic;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.ErrorDialogs;
|
|
||||||
//using ICSharpCode.FormDesigner.Gui;
|
|
||||||
//
|
|
||||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
|
||||||
//
|
|
||||||
//namespace ICSharpCode.FormDesigner {
|
|
||||||
//
|
|
||||||
// public class UndoHandler
|
|
||||||
// {
|
|
||||||
// IDesignerHost host;
|
|
||||||
// Hashtable sizePos = new Hashtable();
|
|
||||||
//
|
|
||||||
// ICSharpCode.SharpDevelop.Internal.Undo.UndoStack undoStack = new ICSharpCode.SharpDevelop.Internal.Undo.UndoStack();
|
|
||||||
//
|
|
||||||
// bool inUndoRedo = false;
|
|
||||||
// int transactionLevel = 0;
|
|
||||||
// int undoOperations = 0;
|
|
||||||
//
|
|
||||||
// public bool EnableUndo {
|
|
||||||
// get {
|
|
||||||
// return undoStack.CanUndo;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public bool EnableRedo {
|
|
||||||
// get {
|
|
||||||
// return undoStack.CanRedo;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Reset()
|
|
||||||
// {
|
|
||||||
// undoStack.ClearAll();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // BUG ALERT !!!
|
|
||||||
// // WINDOWS FORMS DESIGNER BUG:
|
|
||||||
// // MOVE/RESIZE IN THE DESIGNER --> OldValue == NewValue in change event
|
|
||||||
// // THEREFORE A WORKAROUND IS NEEDED (AN UGLY WORKAROUND)
|
|
||||||
// // BUG ALERT 2 !!!
|
|
||||||
// // SOME MS CODERS DON'T KNOW THE DIFFERENCE BETWEEN REFERENCE AND VALUE !!!
|
|
||||||
// // CONTROL COLLECTION new/old values are the same !!!!
|
|
||||||
// void InitSizePosTable()
|
|
||||||
// {
|
|
||||||
// sizePos.Clear();
|
|
||||||
// foreach (IComponent component in host.Container.Components) {
|
|
||||||
// Control ctrl = component as Control;
|
|
||||||
// if (ctrl != null) {
|
|
||||||
// object[] ctrlCol = new object[ctrl.Controls.Count];
|
|
||||||
// ctrl.Controls.CopyTo(ctrlCol, 0);
|
|
||||||
// sizePos[component.Site.Name] = new object[] { ctrl.Location, ctrl.Size, ctrlCol};
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void ComponentChanged(object sender, ComponentChangedEventArgs ea)
|
|
||||||
// {
|
|
||||||
// if (inUndoRedo) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (ea.Component == null || (ea.Component is IComponent == false)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ++undoOperations;
|
|
||||||
// if (ea.Member != null)
|
|
||||||
// {
|
|
||||||
// if (sizePos[((IComponent)ea.Component).Site.Name] != null)
|
|
||||||
// {
|
|
||||||
// if (ea.Member.Name == "Location")
|
|
||||||
// {
|
|
||||||
// ea = new ComponentChangedEventArgs(ea.Component, ea.Member, ((object[])sizePos[((IComponent)ea.Component).Site.Name])[0], ea.NewValue);
|
|
||||||
// }
|
|
||||||
// else if (ea.Member.Name == "Size")
|
|
||||||
// {
|
|
||||||
// ea = new ComponentChangedEventArgs(ea.Component, ea.Member, ((object[])sizePos[((IComponent)ea.Component).Site.Name])[1], ea.NewValue);
|
|
||||||
// }
|
|
||||||
// else if (ea.Member.Name == "Controls")
|
|
||||||
// {
|
|
||||||
// ea = new ComponentChangedEventArgs(ea.Component, ea.Member, ((object[])sizePos[((IComponent)ea.Component).Site.Name])[2], ea.NewValue);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// undoStack.Push(new ComponentChangedUndoAction(host, ea));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void ComponentAdded(object sender, ComponentEventArgs ea)
|
|
||||||
// {
|
|
||||||
// if (inUndoRedo) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// ++undoOperations;
|
|
||||||
// undoStack.Push(new ComponentAddedUndoAction(host, ea));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void ComponentRemoved(object sender, ComponentEventArgs ea)
|
|
||||||
// {
|
|
||||||
// if (inUndoRedo) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// ++undoOperations;
|
|
||||||
// string parentName = null;
|
|
||||||
// foreach (DictionaryEntry entry in sizePos) {
|
|
||||||
// object[] arr = (object[])entry.Value;
|
|
||||||
// if (arr[2] != null) {
|
|
||||||
// foreach (object ctr in ((IList)arr[2])) {
|
|
||||||
// if (ctr == ea.Component) {
|
|
||||||
// parentName = entry.Key.ToString();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// undoStack.Push(new ComponentRemovedUndoAction(host, ea, parentName));
|
|
||||||
// }
|
|
||||||
// SelectComponentsUndoAction selectComponentsUndoAction = null;
|
|
||||||
//
|
|
||||||
// void TransactionOpened(object sender, EventArgs e)
|
|
||||||
// {
|
|
||||||
// if (transactionLevel == 0) {
|
|
||||||
// undoOperations = 0;
|
|
||||||
// InitSizePosTable();
|
|
||||||
// selectComponentsUndoAction = new SelectComponentsUndoAction(host, GetSelectedComponentNames(host));
|
|
||||||
// undoStack.Push(selectComponentsUndoAction);
|
|
||||||
// }
|
|
||||||
// ++transactionLevel;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void TransactionClosed(object sender, DesignerTransactionCloseEventArgs e)
|
|
||||||
// {
|
|
||||||
// --transactionLevel;
|
|
||||||
// if (transactionLevel == 0 && undoOperations > 0) {
|
|
||||||
// if (selectComponentsUndoAction != null) {
|
|
||||||
// selectComponentsUndoAction.SetNewSelection(GetSelectedComponentNames(host));
|
|
||||||
// selectComponentsUndoAction = null;
|
|
||||||
// }
|
|
||||||
// undoStack.UndoLast(undoOperations + 1);
|
|
||||||
// ((DefaultWorkbench)WorkbenchSingleton.Workbench).UpdateToolbars();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static ArrayList GetSelectedComponentNames(IDesignerHost host)
|
|
||||||
// {
|
|
||||||
// ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService));
|
|
||||||
// ArrayList names = new ArrayList();
|
|
||||||
//
|
|
||||||
// foreach (IComponent component in selectionService.GetSelectedComponents()) {
|
|
||||||
// if (component.Site != null) {
|
|
||||||
// names.Add(component.Site.Name);
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// MessageService.ShowError(component + " has no site.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return names;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void SetSelectedComponentsPerName(IDesignerHost host, ArrayList names)
|
|
||||||
// {
|
|
||||||
// ArrayList components = new ArrayList();
|
|
||||||
//
|
|
||||||
// foreach (string name in names) {
|
|
||||||
// if (host.Container.Components[name] != null) {
|
|
||||||
// components.Add(host.Container.Components[name]);
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// MessageService.ShowError("Can't select component : Component " + name + " not found.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService));
|
|
||||||
// selectionService.SetSelectedComponents(components);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public void Attach(IDesignerHost host)
|
|
||||||
// {
|
|
||||||
// this.host = host;
|
|
||||||
//
|
|
||||||
// IComponentChangeService componentChangeService = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
|
|
||||||
// componentChangeService.ComponentChanged += new ComponentChangedEventHandler(ComponentChanged);
|
|
||||||
// componentChangeService.ComponentAdded += new ComponentEventHandler(ComponentAdded);
|
|
||||||
// componentChangeService.ComponentRemoved += new ComponentEventHandler(ComponentRemoved);
|
|
||||||
//
|
|
||||||
// host.TransactionOpened += new EventHandler(TransactionOpened);
|
|
||||||
// host.TransactionClosed += new DesignerTransactionCloseEventHandler(TransactionClosed);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Detach()
|
|
||||||
// {
|
|
||||||
// IComponentChangeService componentChangeService = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
|
|
||||||
// componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(ComponentChanged);
|
|
||||||
// componentChangeService.ComponentAdded -= new ComponentEventHandler(ComponentAdded);
|
|
||||||
// componentChangeService.ComponentRemoved -= new ComponentEventHandler(ComponentRemoved);
|
|
||||||
//
|
|
||||||
// host.TransactionOpened -= new EventHandler(TransactionOpened);
|
|
||||||
// host.TransactionClosed -= new DesignerTransactionCloseEventHandler(TransactionClosed);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Undo()
|
|
||||||
// {
|
|
||||||
// inUndoRedo = true;
|
|
||||||
// try {
|
|
||||||
// undoStack.Undo();
|
|
||||||
// UpdateSelectableObjects();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine("UndoException : " + e.ToString());
|
|
||||||
// } finally {
|
|
||||||
// inUndoRedo = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void Redo()
|
|
||||||
// {
|
|
||||||
// inUndoRedo = true;
|
|
||||||
// try {
|
|
||||||
// undoStack.Redo();
|
|
||||||
// UpdateSelectableObjects();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine("UndoException : " + e.ToString());
|
|
||||||
// } finally {
|
|
||||||
// inUndoRedo = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// protected void UpdateSelectableObjects()
|
|
||||||
// {
|
|
||||||
// if (host != null) {
|
|
||||||
// PropertyPad.SetSelectableObjects(host.Container.Components);
|
|
||||||
// ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService));
|
|
||||||
// if (selectionService != null) {
|
|
||||||
// ICSharpCode.SharpDevelop.Gui.PropertyPad.SetDesignableObject(selectionService.PrimarySelection);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
Loading…
Reference in new issue