diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Configuration/AssemblyInfo.cs
new file mode 100644
index 0000000000..99498c3b77
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Configuration/AssemblyInfo.cs
@@ -0,0 +1,22 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("WorkflowDesigner")]
+[assembly: AssemblyDescription("Windows Workflow Foundation Addin for SharpDevelop 3.0")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs
new file mode 100644
index 0000000000..7df759f134
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs
@@ -0,0 +1,45 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+namespace WorkflowDesigner
+{
+ partial class ViewContentControl
+ {
+ ///
+ /// Designer variable used to keep track of non-visual components.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Disposes resources used by the control.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) {
+ if (components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ ///
+ private void InitializeComponent()
+ {
+ //
+ // ViewContentControl
+ //
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Name = "ViewContentControl";
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs
new file mode 100644
index 0000000000..75aea51af7
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs
@@ -0,0 +1,279 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Collections;
+using System.Windows.Forms;
+using System.Workflow.ComponentModel.Design;
+using System.Workflow.Activities;
+using System.ComponentModel.Design.Serialization;
+using System.IO;
+using System.Drawing.Design;
+using System.Reflection;
+
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Widgets.SideBar;
+using ICSharpCode.FormsDesigner;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+#endregion
+
+namespace WorkflowDesigner
+{
+
+
+ ///
+ /// Description of ViewContentControl.
+ ///
+ public partial class ViewContentControl : UserControl, IHasPropertyContainer
+ {
+ private DesignSurface designSurface;
+ private BasicDesignerLoader loader;
+ private IViewContent viewContent;
+ private string codeSeparationFileName ;
+
+ // HACK: Temporary sidebar creation.
+ static SideTab sideTab;
+
+ static ViewContentControl()
+ {
+ sideTab = new SideTab("Workflow");
+
+ // Make sure the side bar has actually bee created!
+ if (SharpDevelopSideBar.SideBar == null)
+ WorkbenchSingleton.Workbench.GetPad(typeof(SideBarView)).CreatePad();
+
+ sideTab.CanSaved = false;
+
+ // Add the standard pointer.
+ SharpDevelopSideTabItem sti = new SharpDevelopSideTabItem("Pointer");
+ sti.CanBeRenamed = false;
+ sti.CanBeDeleted = false;
+ Bitmap pointerBitmap = new Bitmap(IconService.GetBitmap("Icons.16x16.FormsDesigner.PointerIcon"), 16, 16);
+ sti.Icon = pointerBitmap;
+ sti.Tag = null;
+ sideTab.Items.Add(sti);
+
+
+ // Load activities from the standard assembly.
+ Assembly assembly = AppDomain.CurrentDomain.Load("System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
+ ICollection toolboxItems = System.Drawing.Design.ToolboxService.GetToolboxItems(assembly.GetName());
+ foreach (ToolboxItem tbi in toolboxItems)
+ {
+ sti = new SharpDevelopSideTabItem(tbi.DisplayName);
+ sti.CanBeDeleted = false;
+ sti.CanBeRenamed = false;
+ sti.Tag = tbi;
+ sti.Icon = tbi.Bitmap;
+ sideTab.Items.Add(sti);
+ }
+
+ }
+
+ public string CodeSeparationFileName {
+ get { return codeSeparationFileName; }
+ set { codeSeparationFileName = value; }
+ }
+
+
+ public ViewContentControl(IViewContent viewContent)
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ this.viewContent = viewContent;
+
+ // Make sure the standard workflow sidebar is on screen.
+ if (!SharpDevelopSideBar.SideBar.Tabs.Contains(sideTab)) {
+ SharpDevelopSideBar.SideBar.Tabs.Add(sideTab);
+ SharpDevelopSideBar.SideBar.Refresh();
+ }
+
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ if (!Visible) this.Deselected();
+ base.OnVisibleChanged(e);
+ }
+
+
+ public IDesignerHost DesignerHost {
+ get {
+ if (designSurface == null)
+ return null;
+
+ return (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
+ }
+ }
+
+ public IRootDesigner RootDesigner
+ {
+ get
+ {
+ return DesignerHost.GetDesigner(DesignerHost.RootComponent) as IRootDesigner;
+ }
+ }
+
+ public WorkflowView WorkflowView
+ {
+ get
+ {
+ return (WorkflowView)RootDesigner.GetView(ViewTechnology.Default);
+ }
+ }
+
+
+
+ internal void LoadWorkflow(BasicDesignerLoader loader)
+ {
+
+
+ this.loader = loader;
+
+ try {
+
+ LoadDesigner();
+
+ if (designSurface != null && Controls.Count == 0) {
+ Control designer = designSurface.View as Control;
+ designer.Dock = DockStyle.Fill;
+ Controls.Add(designer);
+ }
+ } catch (Exception e) {
+ TextBox errorText = new TextBox();
+ errorText.Multiline = true;
+ if (!designSurface.IsLoaded && designSurface.LoadErrors != null) {
+ errorText.Text = "Error loading designer:\r\n\r\n";
+ foreach(Exception le in designSurface.LoadErrors) {
+ errorText.Text += le.ToString();
+ errorText.Text += "\r\n";
+ }
+ } else {
+ errorText.Text = e.ToString();
+ }
+
+ errorText.Dock = DockStyle.Fill;
+ Controls.Add(errorText);
+ Control title = new Label();
+ title.Text = "Failed to load designer. Check the source code for syntax errors and check if all references are available.";
+ title.Dock = DockStyle.Top;
+ Controls.Add(title);
+ }
+ }
+
+ internal void SaveWorkflow(Stream stream)
+ {
+ loader.Flush();
+
+ if (loader is XomlDesignerLoader) {
+ using (StreamWriter w = new StreamWriter(stream)) {
+ w.Write(((XomlDesignerLoader)loader).Xoml);
+ }
+ }
+ }
+
+ internal void UnloadWorkflow()
+ {
+ UnloadDesigner();
+ }
+
+ void UnloadDesigner()
+ {
+ this.Controls.Clear();
+ designSurface.Dispose();
+ designSurface = null;
+
+ }
+
+ void LoadDesigner()
+ {
+
+ designSurface = new DesignSurface();
+ designSurface.BeginLoad(loader);
+
+ // Monitor for updates and make the view dirty.
+ //IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService));
+ //componentChangeService.ComponentAdding += new ComponentEventHandler(ComponentAddingHandler);
+ //componentChangeService.ComponentAdded += new ComponentEventHandler(ComponentAddedHandler);
+ //componentChangeService.ComponentChanged += new ComponentChangedEventHandler(ComponentChangedHandler);
+
+ // Attach the selection service to capture objects selection changes to update property pad.
+ ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));
+ selectionService.SelectionChanged += new EventHandler(SelectionChangedHandler);
+
+ }
+
+ void ComponentAddedHandler(object sender, ComponentEventArgs args)
+ {
+ ((XomlCodeSeparationDesignerLoader)loader).UpdateCCU();
+ LoggingService.Debug("ComponentAddedHandler");
+ }
+
+ void ComponentAddingHandler(object sender, ComponentEventArgs args)
+ {
+ LoggingService.Debug("ComponentAddingHandler");
+ }
+
+ void ComponentChangedHandler(object sender, ComponentChangedEventArgs args)
+ {
+ ((XomlCodeSeparationDesignerLoader)loader).UpdateCCU();
+ viewContent.PrimaryFile.MakeDirty();
+ }
+
+ void SelectionChangedHandler(object sender, EventArgs args)
+ {
+ UpdatePropertyPadSelection((ISelectionService)sender);
+ }
+
+ void UpdatePropertyPadSelection(ISelectionService selectionService)
+ {
+ ICollection selection = selectionService.GetSelectedComponents();
+ object[] selArray = new object[selection.Count];
+ selection.CopyTo(selArray, 0);
+ propertyContainer.SelectableObjects = DesignerHost.Container.Components;
+ //propertyContainer.Host = DesignerHost.RootComponent.Site;
+ propertyContainer.SelectedObjects = selArray;
+ PropertyPad.Grid.CommandsVisibleIfAvailable = false;
+ PropertyPad.Grid.Site = DesignerHost.RootComponent.Site;
+
+ }
+
+ internal void Selected()
+ {
+ SharpDevelopSideBar.SideBar.ActiveTab = sideTab;
+ }
+
+ internal void Deselected()
+ {
+ propertyContainer.SelectableObjects = null;
+ propertyContainer.Host = null;
+ propertyContainer.SelectedObjects = null;
+ }
+
+ #region IHasPropertyContainer
+ PropertyContainer propertyContainer = new PropertyContainer();
+ public PropertyContainer PropertyContainer {
+ get {
+ return propertyContainer;
+ }
+ }
+ #endregion
+
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/NRefactoryDesignerLoader.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/NRefactoryDesignerLoader.cs
new file mode 100644
index 0000000000..3ddae09b79
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/NRefactoryDesignerLoader.cs
@@ -0,0 +1,333 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using ICSharpCode.Core;
+using ICSharpCode.NRefactory;
+using ICSharpCode.NRefactory.Ast;
+using ICSharpCode.NRefactory.Visitors;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.TextEditor;
+using ICSharpCode.FormsDesigner;
+using ICSharpCode.SharpDevelop.Gui;
+
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing.Design;
+using System.IO;
+using System.Reflection;
+using System.Workflow.ComponentModel.Compiler;
+using System.Workflow.ComponentModel.Design;
+using System.Windows.Forms;
+#endregion
+
+namespace WorkflowDesigner
+{
+ public class DefaultMemberRelationshipService : MemberRelationshipService
+ {
+ public override bool SupportsRelationship(MemberRelationship source, MemberRelationship relationship)
+ {
+ return true;
+ }
+ protected override MemberRelationship GetRelationship(MemberRelationship source)
+ {
+ return base.GetRelationship(source);
+ }
+ }
+
+ ///
+ /// Description of CodeDomLoader.
+ ///
+ public class NRefactoryDesignerLoader : CodeDomDesignerLoader
+ {
+ TextEditorControl textEditorControl;
+ ITypeResolutionService typeResolutionService;
+ IDesignerGenerator generator = new CSharpDesignerGenerator();
+ IViewContent viewContent;
+
+ #region Constructors
+ public NRefactoryDesignerLoader(TextEditorControl textEditorControl, IViewContent viewContent) : base()
+ {
+ this.textEditorControl = textEditorControl;
+ this.viewContent = viewContent;
+ }
+ #endregion
+
+ protected override CodeDomProvider CodeDomProvider {
+ get {
+ return generator.CodeDomProvider;
+ }
+ }
+
+ protected override ITypeResolutionService TypeResolutionService {
+ get {
+ return this.typeResolutionService;
+ }
+ }
+
+
+ protected override void Write(CodeCompileUnit unit)
+ {
+ LoggingService.Debug("NRefactoryDesignerLoader.Write()");
+ throw new NotImplementedException();
+ }
+
+
+
+ public override void BeginLoad(IDesignerLoaderHost host)
+ {
+ if (host == null)
+ throw new ArgumentNullException("host");
+
+ LoggingService.Debug("NRefactoryDesignerLoader.BeginLoad()");
+
+ host.AddService(typeof(ITypeResolutionService), new ICSharpCode.FormsDesigner.Services.TypeResolutionService(viewContent.PrimaryFileName));
+ host.AddService(typeof(IIdentifierCreationService), new IdentifierCreationService());
+ host.AddService(typeof(IMemberCreationService), new MemberCreationService());
+ host.AddService(typeof(IEventBindingService), new EventBindingService(host));
+ host.AddService(typeof(IToolboxService), new WorkflowToolboxService());
+ host.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
+ host.AddService(typeof(IMenuCommandService), new WorkflowMenuCommandService(host));
+ TypeProvider tp = new TypeProvider(host);
+ host.AddService(typeof(ITypeProvider), tp);
+
+ // HACK: Load all assemblies in the #D - should only be references for the current project!
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ tp.AddAssembly(assembly);
+ }
+
+ typeResolutionService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService));
+ base.BeginLoad(host);
+
+ }
+
+
+ #region Taken from FormDesigner.NRefactoryDesignerLoad to get a CodeCompileUnit for the activity.
+ string lastTextContent;
+ protected override CodeCompileUnit Parse()
+ {
+ LoggingService.Debug("NRefactoryDesignerLoader.Parse()");
+
+ lastTextContent = textEditorControl.Document.TextContent;
+
+ ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName);
+
+ IClass formClass;
+ bool isFirstClassInFile;
+ IList parts = FindFormClassParts(parseInfo, out formClass, out isFirstClassInFile);
+
+ const string missingReferenceMessage = "Your project is missing a reference to '${Name}' - please add it using 'Project > Add Reference'.";
+
+ if (formClass.ProjectContent.GetClass("System.Workflow.Activities.CodeActivity", 0) == null) {
+ throw new WorkflowDesignerLoadException(
+ StringParser.Parse(
+ missingReferenceMessage, new string[,] {{ "Name" , "System.Workflow.Activities"}}
+ ));
+ }
+ /*if (formClass.ProjectContent.GetClass("System.Windows.Forms.Form", 0) == null) {
+ throw new WorkflowDesignerLoadException(
+ StringParser.Parse(
+ missingReferenceMessage, new string[,] {{ "Name" , "System.Windows.Forms"}}
+ ));
+ }*/
+
+ List> compilationUnits = new List>();
+ bool foundInitMethod = false;
+ foreach (IClass part in parts) {
+ string fileName = part.CompilationUnit.FileName;
+ if (fileName == null) continue;
+ bool found = false;
+ foreach (KeyValuePair entry in compilationUnits) {
+ if (FileUtility.IsEqualFileName(fileName, entry.Key)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) continue;
+
+ string fileContent = ParserService.GetParseableFileContent(fileName);
+
+ ICSharpCode.NRefactory.IParser p = ICSharpCode.NRefactory.ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(fileContent));
+ p.Parse();
+ if (p.Errors.Count > 0) {
+ throw new WorkflowDesignerLoadException("Syntax errors in " + fileName + ":\r\n" + p.Errors.ErrorOutput);
+ }
+
+ // Try to fix the type names to fully qualified ones
+ FixTypeNames(p.CompilationUnit, part.CompilationUnit, ref foundInitMethod);
+ compilationUnits.Add(new KeyValuePair(fileName, p.CompilationUnit));
+ }
+
+ if (!foundInitMethod)
+ throw new WorkflowDesignerLoadException("The InitializeComponent method was not found. Designer cannot be loaded.");
+
+ CompilationUnit combinedCu = new CompilationUnit();
+ NamespaceDeclaration nsDecl = new NamespaceDeclaration(formClass.Namespace);
+ combinedCu.AddChild(nsDecl);
+ TypeDeclaration formDecl = new TypeDeclaration(Modifiers.Public, null);
+ nsDecl.AddChild(formDecl);
+ formDecl.Name = formClass.Name;
+ foreach (KeyValuePair entry in compilationUnits) {
+ foreach (object o in entry.Value.Children) {
+ TypeDeclaration td = o as TypeDeclaration;
+ if (td != null && td.Name == formDecl.Name) {
+ foreach (INode node in td.Children)
+ formDecl.AddChild(node);
+ formDecl.BaseTypes.AddRange(td.BaseTypes);
+ }
+ if (o is NamespaceDeclaration) {
+ foreach (object o2 in ((NamespaceDeclaration)o).Children) {
+ td = o2 as TypeDeclaration;
+ if (td != null && td.Name == formDecl.Name) {
+ foreach (INode node in td.Children)
+ formDecl.AddChild(node);
+ formDecl.BaseTypes.AddRange(td.BaseTypes);
+ }
+ }
+ }
+ }
+ }
+
+ CodeDomVisitor visitor = new CodeDomVisitor();
+ visitor.EnvironmentInformationProvider = new ICSharpCode.SharpDevelop.Dom.NRefactoryResolver.NRefactoryInformationProvider(formClass.ProjectContent);
+ visitor.VisitCompilationUnit(combinedCu, null);
+
+ // output generated CodeDOM to the console :
+ #if DEBUG
+// if ((Control.ModifierKeys & Keys.Control) == Keys.Control) {
+// CodeDomVerboseOutputGenerator outputGenerator = new CodeDomVerboseOutputGenerator();
+// outputGenerator.GenerateCodeFromMember(visitor.codeCompileUnit.Namespaces[0].Types[0], Console.Out, null);
+// this.CodeDomProvider.GenerateCodeFromCompileUnit(visitor.codeCompileUnit, Console.Out, null);
+// }
+ #endif
+
+ LoggingService.Debug("NRefactoryDesignerLoader.Parse() finished");
+
+ if (!isFirstClassInFile) {
+ MessageService.ShowWarning("The form must be the first class in the file in order for form resources be compiled correctly.\n" +
+ "Please move other classes below the form class definition or move them to other files.");
+ }
+
+ return visitor.codeCompileUnit;
+ }
+
+ public static IList FindFormClassParts(ParseInformation parseInfo, out IClass formClass, out bool isFirstClassInFile)
+ {
+ #if DEBUG
+ if ((Control.ModifierKeys & (Keys.Alt | Keys.Control)) == (Keys.Alt | Keys.Control)) {
+ System.Diagnostics.Debugger.Break();
+ }
+ #endif
+
+ formClass = null;
+ isFirstClassInFile = true;
+ foreach (IClass c in parseInfo.BestCompilationUnit.Classes) {
+ if (WorkflowDesignerSecondaryDisplayBinding.BaseClassIsWorkflow(c)) {
+ formClass = c;
+ break;
+ }
+ isFirstClassInFile = false;
+ }
+ if (formClass == null)
+ throw new WorkflowDesignerLoadException("No class derived from Form or UserControl was found.");
+
+ // Initialize designer for formClass
+ formClass = formClass.GetCompoundClass();
+ if (formClass is CompoundClass) {
+ return (formClass as CompoundClass).GetParts();
+ } else {
+ return new IClass[] { formClass };
+ }
+ }
+
+ ///
+ /// Fix type names and remove unused methods.
+ ///
+ void FixTypeNames(object o, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu, ref bool foundInitMethod)
+ {
+ if (domCu == null)
+ return;
+ CompilationUnit cu = o as CompilationUnit;
+ if (cu != null) {
+ foreach (object c in cu.Children) {
+ FixTypeNames(c, domCu, ref foundInitMethod);
+ }
+ return;
+ }
+ NamespaceDeclaration namespaceDecl = o as NamespaceDeclaration;
+ if (namespaceDecl != null) {
+ foreach (object c in namespaceDecl.Children) {
+ FixTypeNames(c, domCu, ref foundInitMethod);
+ }
+ return;
+ }
+ TypeDeclaration typeDecl = o as TypeDeclaration;
+ if (typeDecl != null) {
+ foreach (TypeReference tref in typeDecl.BaseTypes) {
+ FixTypeReference(tref, typeDecl.StartLocation, domCu);
+ }
+ for (int i = 0; i < typeDecl.Children.Count; i++) {
+ object child = typeDecl.Children[i];
+ MethodDeclaration method = child as MethodDeclaration;
+ if (method != null) {
+ // remove all methods except InitializeComponents
+ if ((method.Name == "InitializeComponents" || method.Name == "InitializeComponent") && method.Parameters.Count == 0) {
+ method.Name = "InitializeComponent";
+ if (foundInitMethod) {
+ throw new WorkflowDesignerLoadException("There are multiple InitializeComponent methods in the class. Designer cannot be loaded.");
+ }
+ foundInitMethod = true;
+ } else {
+ typeDecl.Children.RemoveAt(i--);
+ }
+ } else if (child is TypeDeclaration || child is FieldDeclaration) {
+ FixTypeNames(child, domCu, ref foundInitMethod);
+ } else {
+ // child is property, event etc.
+ typeDecl.Children.RemoveAt(i--);
+ }
+ }
+
+ return;
+ }
+ FieldDeclaration fieldDecl = o as FieldDeclaration;
+ if (fieldDecl != null) {
+ FixTypeReference(fieldDecl.TypeReference, fieldDecl.StartLocation, domCu);
+ foreach (VariableDeclaration var in fieldDecl.Fields) {
+ if (var != null) {
+ FixTypeReference(var.TypeReference, fieldDecl.StartLocation, domCu);
+ }
+ }
+ }
+ }
+
+ void FixTypeReference(TypeReference type, Location location, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu)
+ {
+ if (type == null)
+ return;
+ if (type.SystemType != type.Type)
+ return;
+ foreach (TypeReference tref in type.GenericTypes) {
+ FixTypeReference(tref, location, domCu);
+ }
+ ICSharpCode.SharpDevelop.Dom.IClass curType = domCu.GetInnermostClass(location.Y, location.X);
+ ICSharpCode.SharpDevelop.Dom.IReturnType rt = domCu.ProjectContent.SearchType(new SearchTypeRequest(type.Type, type.GenericTypes.Count, curType, domCu, location.Y, location.X)).Result;
+ if (rt != null) {
+ type.Type = rt.FullyQualifiedName;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs
new file mode 100644
index 0000000000..93df416784
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs
@@ -0,0 +1,35 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Runtime.Serialization;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of WorkflowDesignerLoaderException.
+ ///
+ [Serializable()]
+ public class WorkflowDesignerLoadException : Exception
+ {
+ public WorkflowDesignerLoadException() : base()
+ {
+ }
+
+ public WorkflowDesignerLoadException(string message) : base(message)
+ {
+ }
+
+ public WorkflowDesignerLoadException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected WorkflowDesignerLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs
new file mode 100644
index 0000000000..9b0761ad4b
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs
@@ -0,0 +1,95 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.Text;
+using System.IO;
+using ICSharpCode.SharpDevelop.Gui;
+using System.ComponentModel.Design;
+using System.Workflow.ComponentModel.Design;
+using System.Workflow.ComponentModel.Compiler;
+using System.CodeDom;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.NRefactory.Visitors;
+using ICSharpCode.NRefactory;
+using ICSharpCode.NRefactory.Ast;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of XomlCodeSeparationDesignerLoader.
+ ///
+ public class XomlCodeSeparationDesignerLoader : XomlDesignerLoader
+ {
+ private string codeFileName;
+
+ public XomlCodeSeparationDesignerLoader(IViewContent viewContent, string fileName, Stream stream, string codeFileName) : base(viewContent, fileName, stream)
+ {
+ this.codeFileName = codeFileName;
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ // TODO: Install the Add the additional services into the designer here.
+ LoaderHost.AddService(typeof(IMemberCreationService), new MemberCreationService());
+ LoaderHost.AddService(typeof(IEventBindingService), new EventBindingService(LoaderHost));
+ LoaderHost.AddService(typeof(IWorkflowDesignerGeneratorService), new CSharpWorkflowDesignerGeneratorService(LoaderHost,codeFileName));
+ }
+
+ protected override void Load()
+ {
+ UpdateCCU();
+
+ LoadFromXoml();
+
+ LoaderHost.Activate();
+ }
+
+ CodeCompileUnit ccu;
+ public void UpdateCCU()
+ {
+ LoggingService.Debug("UpdateCCU");
+
+ TypeProvider typeProvider = (TypeProvider)this.GetService(typeof(ITypeProvider));
+
+ if (ccu != null)
+ typeProvider.RemoveCodeCompileUnit(ccu);
+
+ ccu = Parse();
+
+ if (ccu != null)
+ typeProvider.AddCodeCompileUnit(ccu);
+
+ }
+
+ CodeCompileUnit Parse()
+ {
+ LoggingService.Debug("NRefactoryDesignerLoader.Parse()");
+
+ string fileContent = ParserService.GetParseableFileContent(codeFileName);
+
+ ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(fileContent));
+ parser.Parse();
+ if (parser.Errors.Count > 0) {
+ throw new Exception("Syntax errors in " + codeFileName + ":\r\n" + parser.Errors.ErrorOutput);
+ }
+
+ CodeDomVisitor visitor = new CodeDomVisitor();
+ visitor.VisitCompilationUnit(parser.CompilationUnit, null);
+
+ LoggingService.Debug("NRefactoryDesignerLoader.Parse() finished");
+ return visitor.codeCompileUnit;
+ }
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs
new file mode 100644
index 0000000000..efaf371365
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs
@@ -0,0 +1,175 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.Text;
+using System.Workflow.ComponentModel;
+using System.Workflow.ComponentModel.Serialization;
+using System.Workflow.ComponentModel.Design;
+using System.Workflow.ComponentModel.Compiler;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+using System.Xml;
+using System.Reflection;
+using System.Drawing.Design;
+using System.IO;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.Core;
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of XomlDesignerLoader.
+ ///
+ public class XomlDesignerLoader : WorkflowDesignerLoader
+ {
+ private string xoml = string.Empty;
+ private string fileName = string.Empty;
+ private IViewContent viewContent;
+
+ public XomlDesignerLoader(IViewContent viewContent)
+ {
+ this.viewContent = viewContent;
+ }
+
+ public XomlDesignerLoader(IViewContent viewContent, string fileName, Stream stream) : this(viewContent)
+ {
+ this.fileName = fileName;
+ Encoding encoding = ICSharpCode.SharpDevelop.ParserService.DefaultFileEncoding;
+ xoml = ICSharpCode.TextEditor.Util.FileReader.ReadFileContent(stream, ref encoding, encoding);
+ }
+
+ public string Xoml {
+ get { return xoml; }
+ set { xoml = value; }
+ }
+
+ public override string FileName {
+ get {
+ return fileName;
+ }
+ }
+
+ public override TextReader GetFileReader(string filePath)
+ {
+ // TODO: Is this correct?
+ return null;
+ }
+
+ public override TextWriter GetFileWriter(string filePath)
+ {
+ // TODO: Is this correct?
+ return null;
+ }
+
+ protected override void PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager)
+ {
+ Activity rootActivity = LoaderHost.RootComponent as Activity;
+ if (rootActivity != null)
+ {
+ StringBuilder sb = new StringBuilder();
+ XmlTextWriter xmlWriter = new XmlTextWriter(new StringWriter(sb));
+ try
+ {
+ WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
+ xomlSerializer.Serialize(xmlWriter, rootActivity);
+ xoml = sb.ToString();
+ }
+ finally
+ {
+ xmlWriter.Close();
+ }
+ }
+ }
+
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ LoaderHost.AddService(typeof(IToolboxService), new WorkflowToolboxService());
+
+ // HACK: Use default type provider and load all assemblies in #D,
+ // should really only use the references for the current project!
+ TypeProvider typeProvider = new TypeProvider(LoaderHost);
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ typeProvider.AddAssembly(assembly);
+ }
+ LoaderHost.AddService(typeof(ITypeProvider), typeProvider);
+ LoaderHost.AddService(typeof(IMenuCommandService), new WorkflowMenuCommandService(LoaderHost));
+
+ }
+
+ protected override void PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager)
+ {
+ base.PerformLoad(serializationManager);
+
+ Load();
+ }
+
+
+ protected virtual void Load()
+ {
+ LoadFromXoml();
+ LoaderHost.Activate();
+ }
+
+ protected void LoadFromXoml()
+ {
+ // get the root activity from the xml.
+ XmlReader reader = new XmlTextReader(new StringReader(xoml));
+ Activity rootActivity = null;
+ try
+ {
+ WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
+ rootActivity = xomlSerializer.Deserialize(reader) as Activity;
+
+ }
+ finally
+ {
+ reader.Close();
+ }
+
+ LoaderHost.Container.Add(rootActivity, rootActivity.QualifiedName);
+ if (rootActivity is CompositeActivity)
+ AddChildren(rootActivity as CompositeActivity);
+
+ SetBaseComponentClassName(rootActivity.GetType().FullName);
+ }
+
+ protected void AddChildren(CompositeActivity compositeActivity)
+ {
+ foreach (Activity activity in compositeActivity.Activities)
+ {
+ LoaderHost.Container.Add(activity, activity.QualifiedName);
+ if (activity is CompositeActivity)
+ AddChildren(activity as CompositeActivity);
+ }
+ }
+
+ public override void Dispose()
+ {
+ // Remove all the services from the from the host designer.
+ if (LoaderHost != null)
+ {
+ LoaderHost.RemoveService(typeof(IToolboxService));
+ LoaderHost.RemoveService(typeof(ITypeProvider));
+ LoaderHost.RemoveService(typeof(IEventBindingService));
+ LoaderHost.RemoveService(typeof(IMemberCreationService));
+ LoaderHost.RemoveService(typeof(IMenuCommandService));
+ }
+
+ base.Dispose();
+ }
+
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs
new file mode 100644
index 0000000000..403f33dd67
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs
@@ -0,0 +1,36 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.IO;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of PrimaryDisplayBinding.
+ ///
+ public class WorkflowPrimaryDisplayBinding : IDisplayBinding
+ {
+ public WorkflowPrimaryDisplayBinding()
+ {
+ }
+
+ public bool CanCreateContentForFile(string fileName)
+ {
+ return Path.GetExtension(fileName).Equals(".xoml", StringComparison.OrdinalIgnoreCase) ;
+ }
+
+ public IViewContent CreateContentForFile(OpenedFile file)
+ {
+ return new WorkflowPrimaryViewContent(file);
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs
new file mode 100644
index 0000000000..22df2d18d1
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs
@@ -0,0 +1,99 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.FormsDesigner;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of PrimaryViewContent.
+ ///
+ public class WorkflowPrimaryViewContent : AbstractViewContent, IHasPropertyContainer
+ {
+ ViewContentControl control;
+
+ public WorkflowPrimaryViewContent(OpenedFile primaryFile) : base(primaryFile)
+ {
+ this.TabPageText = "Workflow";
+ control = new ViewContentControl(this);
+
+ primaryFile.ForceInitializeView(this); // call Load()
+ }
+
+ public override System.Windows.Forms.Control Control {
+ get {
+ return control;
+ }
+ }
+
+ public override void Load(OpenedFile file, Stream stream)
+ {
+ Debug.Assert(file == this.PrimaryFile);
+
+ XomlDesignerLoader loader = null;
+
+ // First look for a code separation file.
+ // FIXME: The loader does nont know the project this belongs
+ // to as ProjectService.CurrentProject is not set at this point
+ // so look for all possible language files.
+ LoggingService.DebugFormatted("Looking for code separation file");
+ StringBuilder sb = new StringBuilder(file.FileName);
+ bool found = false;
+ if (File.Exists(file.FileName + ".cs")) {
+ sb.Append(".cs");
+ found = true;
+ } else if (File.Exists(file.FileName + ".vb")) {
+ sb.Append(".vb");
+ found = true;
+ }
+ if (found) {
+ control.CodeSeparationFileName = sb.ToString();
+ LoggingService.DebugFormatted("Found code file {0}", control.CodeSeparationFileName);
+ loader = new XomlCodeSeparationDesignerLoader(this, file.FileName, stream, control.CodeSeparationFileName);
+ }
+
+ // No separation file so the nocode loader will be used.
+ if (loader == null)
+ loader = new XomlDesignerLoader(this, file.FileName, stream);
+
+ control.LoadWorkflow(loader);
+ }
+
+ public override void Save(OpenedFile file, Stream stream)
+ {
+ Debug.Assert(file == this.PrimaryFile);
+
+ control.SaveWorkflow(stream);
+ }
+
+ public void LoadContent(string content)
+ {
+ XomlDesignerLoader xomlDesignerLoader = new XomlDesignerLoader(this);
+ xomlDesignerLoader.Xoml = content;
+ control.LoadWorkflow(xomlDesignerLoader);
+ }
+
+ // control.Selected();
+ // control.Deselected();
+
+ #region IHasPropertyContainer
+ public PropertyContainer PropertyContainer {
+ get {
+ return control.PropertyContainer;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs
new file mode 100644
index 0000000000..bf6c15a082
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs
@@ -0,0 +1,113 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.IO;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of SecondaryDisplayBinding.
+ ///
+ public class WorkflowDesignerSecondaryDisplayBinding : ISecondaryDisplayBinding
+ {
+ public WorkflowDesignerSecondaryDisplayBinding()
+ {
+ }
+
+ public bool ReattachWhenParserServiceIsReady {
+ get {
+ return true;
+ }
+ }
+
+
+ public bool CanAttachTo(IViewContent content)
+ {
+ if (content is ITextEditorControlProvider) {
+ ITextEditorControlProvider textAreaControlProvider = (ITextEditorControlProvider)content;
+ string fileExtension = String.Empty;
+ string fileName = content.PrimaryFileName;
+ if (fileName == null)
+ return false;
+
+ switch (Path.GetExtension(fileName).ToLowerInvariant()) {
+ case ".cs":
+ case ".vb":
+ ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false);
+
+ if (IsDesignable(info))
+ return true;
+ break;
+ }
+ }
+ return false;
+ }
+
+ public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
+ {
+ //HACK: Just create a view for now
+ return new IViewContent[] { new WorkflowDesignerSecondaryViewContent(viewContent)};
+ }
+
+ public static bool IsInitializeComponentsMethodName(string name)
+ {
+ return name == "InitializeComponents" || name == "InitializeComponent";
+ }
+
+ public static IMethod GetInitializeComponents(IClass c)
+ {
+ c = c.GetCompoundClass();
+ foreach (IMethod method in c.Methods) {
+ if (IsInitializeComponentsMethodName(method.Name) && method.Parameters.Count == 0) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ public static bool BaseClassIsWorkflow(IClass c)
+ {
+ // Simple test for fully qualified name
+ c = c.GetCompoundClass();
+ foreach (IReturnType baseType in c.BaseTypes) {
+ if (baseType.FullyQualifiedName == "System.Workflow.ComponentModel.Activity"
+ // also accept when could not be resolved
+ || baseType.FullyQualifiedName == "Activity" )
+ {
+ return true;
+ }
+ }
+
+ IClass form = c.ProjectContent.GetClass("System.Workflow.ComponentModel.Activity", 0);
+ if (form != null && c.IsTypeInInheritanceTree(form))
+ return true;
+ return false;
+ }
+
+ public static bool IsDesignable(ParseInformation info)
+ {
+ if (info != null) {
+ ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
+ foreach (IClass c in cu.Classes) {
+ IMethod method = GetInitializeComponents(c);
+ if (method != null) {
+ return BaseClassIsWorkflow(c);
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs
new file mode 100644
index 0000000000..a4f0820e20
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs
@@ -0,0 +1,67 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.Windows.Forms;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+using ICSharpCode.SharpDevelop.Widgets.SideBar;
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of SecondaryViewContent.
+ ///
+ public class WorkflowDesignerSecondaryViewContent : AbstractSecondaryViewContent, IHasPropertyContainer
+ {
+ IViewContent viewContent;
+ ViewContentControl control;
+
+ #region Constructors
+ public WorkflowDesignerSecondaryViewContent(IViewContent primaryViewContent) : base(primaryViewContent)
+ {
+ this.TabPageText = "Workflow";
+ this.viewContent = primaryViewContent;
+ control = new ViewContentControl(primaryViewContent);
+
+ // HACK to ensure SideBarPad exists! - Normally handled by FormsDesigner
+ //PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(SideBarView));
+ //.pad.CreatePad();
+
+ }
+ #endregion
+
+ #region Property Accessors
+ public override Control Control {
+ get {
+ return control;
+ }
+ }
+
+ public PropertyContainer PropertyContainer {
+ get {
+ return control.PropertyContainer;
+ }
+ }
+ #endregion
+
+
+ protected override void LoadFromPrimary()
+ {
+ control.LoadWorkflow(new NRefactoryDesignerLoader(((ITextEditorControlProvider)viewContent).TextEditorControl, viewContent));
+ control.Selected();
+ }
+
+ protected override void SaveToPrimary()
+ {
+ control.UnloadWorkflow();
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/CSharpWorkflowDesignerGeneratorService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/CSharpWorkflowDesignerGeneratorService.cs
new file mode 100644
index 0000000000..9806a26afe
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/CSharpWorkflowDesignerGeneratorService.cs
@@ -0,0 +1,79 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Drawing;
+using System.Text;
+using System.ComponentModel;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.NRefactory.PrettyPrinter;
+using ICSharpCode.NRefactory.Ast;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of CSharpWorkflowDesignerGenerator.
+ ///
+ public class CSharpWorkflowDesignerGeneratorService : WorkflowDesignerGeneratorService
+ {
+ public CSharpWorkflowDesignerGeneratorService(IServiceProvider provider, string codeSeparationFileName) : base(provider, codeSeparationFileName)
+ {
+ }
+
+ ///
+ /// Finds the start line for the cursor when positioning inside a method.
+ ///
+ ///
+ ///
+ ///
+ protected override int GetCursorLine(IDocument document, IMethod method)
+ {
+ DomRegion r = method.BodyRegion;
+ int offset = document.PositionToOffset(new Point(r.BeginColumn - 1, r.BeginLine - 1));
+ string tmp = document.GetText(offset, 10);
+ while (offset < document.TextLength) {
+ char c = document.GetCharAt(offset++);
+ if (c == '{') {
+ return r.BeginLine + 1;
+ }
+ if (c != ' ') {
+ break;
+ }
+ }
+ return r.BeginLine + 2;
+ }
+
+ protected override string CreateEventHandler(IClass completeClass, EventDescriptor edesc, string eventMethodName, string body, string indentation)
+ {
+ string param = GenerateParams(completeClass, edesc, true);
+
+ StringBuilder b = new StringBuilder();
+ b.AppendLine(indentation);
+ b.AppendLine(indentation + "void " + eventMethodName + "(" + param + ")");
+ b.AppendLine(indentation + "{");
+ if (string.IsNullOrEmpty(body)) {
+ if (ICSharpCode.FormsDesigner.Gui.OptionPanels.GeneralOptionsPanel.InsertTodoComment) {
+ body = "// TODO: Implement " + eventMethodName;
+ }
+ }
+ b.AppendLine(indentation + "\t" + body);
+ b.AppendLine(indentation + "}");
+ return b.ToString();
+ }
+
+ protected string GenerateParams(IClass completeClass, EventDescriptor edesc, bool paramNames)
+ {
+ CSharpOutputVisitor v = new CSharpOutputVisitor();
+ MethodDeclaration md = ConvertDescriptorToNRefactory(completeClass, edesc, "name");
+ if (md != null) {
+ v.AppendCommaSeparatedList(md.Parameters);
+ }
+ return v.Text;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/IWorkflowDesignerGeneratorService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/IWorkflowDesignerGeneratorService.cs
new file mode 100644
index 0000000000..d6c6e0126a
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/IWorkflowDesignerGeneratorService.cs
@@ -0,0 +1,26 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of IWorkflowDesignerGenerator.
+ ///
+ public interface IWorkflowDesignerGeneratorService
+ {
+ string CodeSeparationFileName { get;}
+ ICollection GetCompatibleMethods(EventDescriptor edesc);
+ bool ShowCode();
+ bool ShowCode(int lineNumber);
+ bool ShowCode(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName);
+ void UseMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName);
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/WorkflowDesignerGeneratorService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/WorkflowDesignerGeneratorService.cs
new file mode 100644
index 0000000000..b735798119
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/WorkflowDesignerGeneratorService.cs
@@ -0,0 +1,245 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Workflow.ComponentModel.Design;
+using System.Reflection;
+
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Dom.ReflectionLayer;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+using ICSharpCode.TextEditor.Document;
+
+#endregion
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of WorkflowDesignerGenerator.
+ ///
+ public abstract class WorkflowDesignerGeneratorService : IWorkflowDesignerGeneratorService, IServiceProvider
+ {
+ IServiceProvider provider;
+ string codeSeparationFileName;
+
+ public WorkflowDesignerGeneratorService(IServiceProvider provider, string codeSeparationFileName)
+ {
+ this.provider = provider;
+ this.codeSeparationFileName = codeSeparationFileName;
+ }
+
+ public object GetService(Type serviceType)
+ {
+ return provider.GetService(serviceType);
+ }
+
+ public string CodeSeparationFileName {
+ get {
+ return codeSeparationFileName;
+ }
+ }
+
+ public virtual ICollection GetCompatibleMethods(EventDescriptor edesc)
+ {
+ ArrayList compatibleMethods = new ArrayList();
+ IClass completeClass;
+
+ IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
+ if (designerHost != null && designerHost.RootComponent != null)
+ {
+ IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
+
+ LoggingService.DebugFormatted("DesignerHost.RootComponent={0}", rootDesigner.Component.Site.Name);
+
+ ParseInformation info = ParserService.ParseFile(this.codeSeparationFileName);
+ ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
+ MethodInfo methodInfo = edesc.EventType.GetMethod("Invoke");
+
+ foreach (IClass c in cu.Classes) {
+ if (c.Name == rootDesigner.Component.Site.Name){
+ LoggingService.DebugFormatted("Got designer class!");
+ completeClass = c.GetCompoundClass();
+
+ LoggingService.DebugFormatted("Looking for compatible methods");
+
+ foreach (IMethod method in completeClass.Methods) {
+ if (method.Parameters.Count == methodInfo.GetParameters().Length) {
+ bool found = true;
+ for (int i = 0; i < methodInfo.GetParameters().Length; ++i) {
+ ParameterInfo pInfo = methodInfo.GetParameters()[i];
+ IParameter p = method.Parameters[i];
+ if (p.ReturnType.FullyQualifiedName != pInfo.ParameterType.ToString()) {
+ found = false;
+ break;
+ }
+ }
+ if (found) {
+ compatibleMethods.Add(method.Name);
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ return compatibleMethods;
+ }
+
+ protected virtual int GetCursorLine(IDocument document, IMethod method)
+ {
+ return method.BodyRegion.BeginLine + 1;
+ }
+
+ protected abstract string CreateEventHandler(IClass completeClass, EventDescriptor edesc, string eventMethodName, string body, string indentation);
+
+
+ public bool ShowCode()
+ {
+ FileService.OpenFile(codeSeparationFileName);
+
+ return true;
+ }
+
+ public bool ShowCode(int lineNumber)
+ {
+ ITextEditorControlProvider t = FileService.OpenFile(codeSeparationFileName) as ITextEditorControlProvider;
+ t.TextEditorControl.ActiveTextAreaControl.JumpTo(lineNumber);
+
+ return true;
+ }
+
+ public bool ShowCode(IComponent component, EventDescriptor e, string methodName)
+ {
+ LoggingService.DebugFormatted("ShowCode {0}", methodName);
+
+ IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
+ IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
+
+ ParseInformation info = ParserService.ParseFile(this.codeSeparationFileName);
+ ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
+
+ ITextEditorControlProvider t = FileService.OpenFile(codeSeparationFileName) as ITextEditorControlProvider;
+
+ IClass completeClass;
+ foreach (IClass c in cu.Classes) {
+ if (c.Name == rootDesigner.Component.Site.Name){
+ completeClass = c.GetCompoundClass();
+
+ foreach (IMethod method in completeClass.Methods) {
+ if (method.Name == methodName)
+ {
+ int position = GetCursorLine(t.TextEditorControl.Document, method);
+ t.TextEditorControl.ActiveTextAreaControl.JumpTo(position-1);
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ ///
+ /// Gets a method implementing the signature specified by the event descriptor
+ ///
+ protected static IMethod ConvertDescriptorToDom(IClass completeClass, EventDescriptor edesc, string methodName)
+ {
+ MethodInfo mInfo = edesc.EventType.GetMethod("Invoke");
+ DefaultMethod m = new DefaultMethod(completeClass, methodName);
+ m.ReturnType = ReflectionReturnType.Create(m, mInfo.ReturnType, false);
+ foreach (ParameterInfo pInfo in mInfo.GetParameters()) {
+ m.Parameters.Add(new ReflectionParameter(pInfo, m));
+ }
+ return m;
+ }
+
+ ///
+ /// Gets a method implementing the signature specified by the event descriptor
+ ///
+ protected static ICSharpCode.NRefactory.Ast.MethodDeclaration
+ ConvertDescriptorToNRefactory(IClass completeClass, EventDescriptor edesc, string methodName)
+ {
+ return ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertMember(
+ ConvertDescriptorToDom(completeClass, edesc, methodName),
+ new ClassFinder(completeClass, completeClass.BodyRegion.BeginLine + 1, 1)
+ ) as ICSharpCode.NRefactory.Ast.MethodDeclaration;
+ }
+
+ protected virtual int GetEventHandlerInsertionLine(IClass c)
+ {
+ return c.Region.EndLine;
+ }
+
+ public void UseMethod(IComponent component, EventDescriptor edesc, string methodName)
+ {
+ LoggingService.DebugFormatted("UseMethod {0}", methodName);
+ IClass completeClass;
+
+ IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
+ if (designerHost != null && designerHost.RootComponent != null)
+ {
+ IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
+ ITextEditorControlProvider t = FileService.OpenFile(codeSeparationFileName) as ITextEditorControlProvider;
+
+ LoggingService.DebugFormatted("DesignerHost.RootComponent={0}", rootDesigner.Component.Site.Name);
+
+ ParseInformation info = ParserService.ParseFile(this.codeSeparationFileName);
+ ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
+ MethodInfo methodInfo = edesc.EventType.GetMethod("Invoke");
+
+ foreach (IClass c in cu.Classes) {
+ if (c.Name == rootDesigner.Component.Site.Name){
+ LoggingService.DebugFormatted("Got designer class!");
+ completeClass = c.GetCompoundClass();
+
+ LoggingService.DebugFormatted("Looking for matching methods...");
+
+
+ foreach (IMethod method in completeClass.Methods) {
+ if ((method.Name == methodName) &&
+ (method.Parameters.Count == methodInfo.GetParameters().Length)) {
+ bool found = true;
+ LoggingService.DebugFormatted("Name & nbr parms match, checking types...");
+ for (int i = 0; i < methodInfo.GetParameters().Length; ++i) {
+ ParameterInfo pInfo = methodInfo.GetParameters()[i];
+ IParameter p = method.Parameters[i];
+ if (p.ReturnType.FullyQualifiedName != pInfo.ParameterType.ToString()) {
+ found = false;
+ break;
+ }
+ }
+ if (found) {
+ LoggingService.DebugFormatted("Found matching method {0}", method.Name);
+ int position = GetCursorLine(t.TextEditorControl.Document, method);
+ t.TextEditorControl.ActiveTextAreaControl.JumpTo(position-1);
+ return;
+ }
+ }
+
+ }
+
+ LoggingService.DebugFormatted("Creating new method...");
+ int line = GetEventHandlerInsertionLine(c);
+ int offset = t.TextEditorControl.Document.GetLineSegment(line - 1).Offset;
+ t.TextEditorControl.Document.Insert(offset, CreateEventHandler(completeClass, edesc, methodName, "", "\t\t"));
+
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService.cs
new file mode 100644
index 0000000000..802ec3435a
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService.cs
@@ -0,0 +1,186 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel.Design;
+using System.ComponentModel;
+using System.Collections;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of EventBindingService.
+ ///
+ public class EventBindingService : IEventBindingService, IServiceProvider
+ {
+ IServiceProvider provider;
+
+ public EventBindingService(IServiceProvider provider)
+ {
+ this.provider = provider;
+ }
+
+ public object GetService(Type serviceType)
+ {
+ return provider.GetService(serviceType);
+ }
+
+ internal IWorkflowDesignerGeneratorService GeneratorService{
+ get{
+ return (IWorkflowDesignerGeneratorService)GetService(typeof(IWorkflowDesignerGeneratorService));
+ }
+ }
+
+ public string CreateUniqueMethodName(IComponent component, EventDescriptor e)
+ {
+ LoggingService.Debug("CreateUniqueMethodName(" + component + ", " + e + ")");
+ return String.Format("{0}{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName);
+ }
+
+ public ICollection GetCompatibleMethods(EventDescriptor e)
+ {
+
+ LoggingService.Debug("GetCompatibleMethods(" + e + ")");
+
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ return GeneratorService.GetCompatibleMethods(e);
+
+ return new string[]{};
+ }
+
+ public EventDescriptor GetEvent(PropertyDescriptor property)
+ {
+ EventPropertyDescriptor epd = property as EventPropertyDescriptor;
+ if (epd == null)
+ return null;
+
+ return epd.eventDescriptor;
+ }
+
+ public PropertyDescriptorCollection GetEventProperties(EventDescriptorCollection events)
+ {
+ ArrayList props = new ArrayList ();
+
+ foreach (EventDescriptor e in events)
+ props.Add (GetEventProperty (e));
+
+ return new PropertyDescriptorCollection ((PropertyDescriptor[]) props.ToArray (typeof (PropertyDescriptor)));
+ }
+
+ public PropertyDescriptor GetEventProperty(EventDescriptor e)
+ {
+ return new EventPropertyDescriptor(e);
+ }
+
+ public bool ShowCode()
+ {
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ return GeneratorService.ShowCode();
+
+ return false;
+ }
+
+ public bool ShowCode(int lineNumber)
+ {
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ return GeneratorService.ShowCode(lineNumber);
+
+ return false;
+
+ }
+
+ public bool ShowCode(IComponent component, EventDescriptor e)
+ {
+
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ return GeneratorService.ShowCode();
+
+ return false;
+ }
+
+ public bool ShowCode(IComponent component, EventDescriptor e, string methodName)
+ {
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ return GeneratorService.ShowCode(component, e, methodName);
+
+ return false;
+ }
+
+ public void UseMethod(IComponent component, EventDescriptor e, string methodName)
+ {
+ LoggingService.Debug("UseMethod()");
+
+ IWorkflowDesignerGeneratorService generatorService = GeneratorService;
+ if (generatorService != null)
+ GeneratorService.UseMethod(component, e, methodName);
+
+ }
+ }
+
+ public class EventPropertyDescriptor : PropertyDescriptor
+ {
+ internal EventDescriptor eventDescriptor;
+
+ public EventPropertyDescriptor(EventDescriptor eventDescriptor) : base(eventDescriptor)
+ {
+ this.eventDescriptor = eventDescriptor;
+ }
+
+ public override Type ComponentType {
+ get {
+ return eventDescriptor.ComponentType;
+ }
+ }
+
+ public override bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ public override Type PropertyType {
+ get {
+ return eventDescriptor.EventType;
+ }
+ }
+
+ public override bool CanResetValue(object component)
+ {
+ return false;
+ }
+
+ public override object GetValue(object component)
+ {
+ //TODO: Implement this
+ return null;
+ }
+
+ public override void ResetValue(object component)
+ {
+
+ }
+
+ public override void SetValue(object component, object value)
+ {
+ //TODO: Implement this
+ }
+
+ public override bool ShouldSerializeValue(object component)
+ {
+ if (GetValue (component) == null) return false;
+ return true;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs
new file mode 100644
index 0000000000..ad8c432f04
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs
@@ -0,0 +1,73 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Workflow.ComponentModel.Design;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of ExtendedUIService.
+ ///
+ public class ExtendedUIService : IExtendedUIService
+ {
+ public ExtendedUIService()
+ {
+ }
+
+ public System.Windows.Forms.DialogResult AddWebReference(out Uri url, out Type proxyClass)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Uri GetUrlForProxyClass(Type proxyClass)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Type GetProxyClassForUrl(Uri url)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddDesignerActions(DesignerAction[] actions)
+ {
+ //throw new NotImplementedException();
+ }
+
+ public void RemoveDesignerActions()
+ {
+ //throw new NotImplementedException();
+ }
+
+ public bool NavigateToProperty(string propName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public System.ComponentModel.ITypeDescriptorContext GetSelectedPropertyContext()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ShowToolsOptions()
+ {
+ throw new NotImplementedException();
+ }
+
+ public System.Collections.Generic.Dictionary GetXsdProjectItemsInfo()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddAssemblyReference(System.Reflection.AssemblyName assemblyName)
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/IdentifierCreationService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/IdentifierCreationService.cs
new file mode 100644
index 0000000000..962e05001d
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/IdentifierCreationService.cs
@@ -0,0 +1,44 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Workflow.ComponentModel.Design;
+using ICSharpCode.Core;
+
+using System.Collections;
+using System.Collections.Generic;
+using System.Workflow.Activities;
+using System.Workflow.ComponentModel;
+using System.ComponentModel;
+using System.Text;
+//using System
+
+ namespace WorkflowDesigner
+{
+ ///
+ /// Description of IdentifierCreationService.
+ ///
+ public class IdentifierCreationService : IIdentifierCreationService
+ {
+ public IdentifierCreationService()
+ {
+ }
+
+ public void EnsureUniqueIdentifiers(System.Workflow.ComponentModel.CompositeActivity parentActivity, System.Collections.ICollection childActivities)
+ {
+ LoggingService.DebugFormatted("EnsureUniqueIdentifiers(parentActivity={0}, childActivities={1})", parentActivity, childActivities);
+ //throw new NotImplementedException();
+ }
+
+ public void ValidateIdentifier(System.Workflow.ComponentModel.Activity activity, string identifier)
+ {
+ LoggingService.DebugFormatted("ValidateIdentifier(ValidateIdentifier={0}, identifier={1})", activity, identifier);
+ //throw new NotImplementedException();
+ }
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs
new file mode 100644
index 0000000000..ba95ca0b9f
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs
@@ -0,0 +1,80 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Workflow.ComponentModel.Design;
+using ICSharpCode.Core;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of MemberCreationService.
+ ///
+ public class MemberCreationService : IMemberCreationService
+ {
+ public MemberCreationService()
+ {
+ }
+
+ public void CreateField(string className, string fieldName, Type fieldType, Type[] genericParameterTypes, System.CodeDom.MemberAttributes attributes, System.CodeDom.CodeSnippetExpression initializationExpression, bool overwriteExisting)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void CreateProperty(string className, string propertyName, Type propertyType, System.Workflow.ComponentModel.Compiler.AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty, bool isAttached, Type ownerType, bool isReadOnly)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void CreateEvent(string className, string eventName, Type eventType, System.Workflow.ComponentModel.Compiler.AttributeInfo[] attributes, bool emitDependencyProperty)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateTypeName(string oldClassName, string newClassName)
+ {
+ LoggingService.DebugFormatted("UpdateTypeName(oldClassName={0}, newClassName={1})", oldClassName, newClassName);
+ //throw new NotImplementedException();
+ }
+
+ public void UpdateBaseType(string className, Type baseType)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateProperty(string className, string oldPropertyName, Type oldPropertyType, string newPropertyName, Type newPropertyType, System.Workflow.ComponentModel.Compiler.AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void UpdateEvent(string className, string oldEventName, Type oldEventType, string newEventName, Type newEventType, System.Workflow.ComponentModel.Compiler.AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveProperty(string className, string propertyName, Type propertyType)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveEvent(string className, string eventName, Type eventType)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ShowCode(System.Workflow.ComponentModel.Activity activity, string methodName, Type delegateType)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ShowCode()
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs
new file mode 100644
index 0000000000..8003456550
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs
@@ -0,0 +1,67 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel.Design;
+using System.Workflow.ComponentModel.Design;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace WorkflowDesigner
+{
+ ///
+ /// Description of MenuCommandService.
+ ///
+ public class WorkflowMenuCommandService : System.ComponentModel.Design.MenuCommandService
+ {
+
+ public WorkflowMenuCommandService(IServiceProvider host) : base(host)
+ {
+
+ }
+
+ public override void ShowContextMenu(CommandID menuID, int x, int y)
+ {
+ if (menuID == null)
+ throw new ArgumentNullException("menuID");
+
+ LoggingService.Debug("ShowContextMenu");
+
+ if (menuID == WorkflowMenuCommands.DesignerActionsMenu)
+ {
+ ContextMenuStrip contextMenu = new ContextMenuStrip();
+
+ ICollection collection = this.GetCommandList(menuID.Guid);
+ foreach (System.ComponentModel.Design.MenuCommand menuCommand in collection)
+ {
+ // Only interested in the errors.
+ if (menuCommand.CommandID.ID == 8342)
+ {
+ ToolStripMenuItem menuItem = new ToolStripMenuItem(menuCommand.Properties["Text"].ToString());
+ menuItem.Click += ClickHandler;
+ contextMenu.Items.Add(menuItem);
+ }
+ }
+
+ WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
+ contextMenu.Show(workflowView , workflowView.PointToClient(new Point(x, y)));
+
+ }
+ }
+
+ void ClickHandler(object sender, EventArgs e)
+ {
+ // TODO: Move focus to the property in the property pad.
+ throw new NotImplementedException();
+ }
+
+ }
+}
+
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs
new file mode 100644
index 0000000000..2341de6e5e
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs
@@ -0,0 +1,255 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+#region Using
+using System;
+using System.Collections;
+using System.Drawing.Design;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Workflow.Activities;
+using ICSharpCode.Core;
+using System.Reflection;
+using System.Windows.Forms;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Project;
+#endregion
+
+namespace WorkflowDesigner
+{
+ // TODO - Replace this a class based on System.Drawing.Design.ToolboxService
+ public class WorkflowToolboxService : IToolboxService
+ {
+ private string category = "Workflow";
+
+ public WorkflowToolboxService()
+ {
+ }
+
+ public CategoryNameCollection CategoryNames {
+ get {
+ return new CategoryNameCollection(new string[] { "Workflow" });
+ }
+ }
+
+ public string SelectedCategory {
+ get {
+ return category;
+ }
+ set {
+ category = value;
+ }
+ }
+
+ public void AddCreator(ToolboxItemCreatorCallback creator, string format)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddCreator(ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddLinkedToolboxItem(ToolboxItem toolboxItem, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddToolboxItem(ToolboxItem toolboxItem)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void AddToolboxItem(ToolboxItem toolboxItem, string category)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItem DeserializeToolboxItem(object serializedObject)
+ {
+ return DeserializeToolboxItem(serializedObject, null);
+ }
+
+ public ToolboxItem DeserializeToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
+ {
+ IDataObject dataObject = (System.Windows.Forms.IDataObject)serializedObject;
+
+ SharpDevelopSideTabItem sti = (SharpDevelopSideTabItem)dataObject.GetData(typeof(SharpDevelopSideTabItem));
+ ToolboxItem toolboxItem = (ToolboxItem)sti.Tag;
+
+ return toolboxItem;
+ }
+
+ public ToolboxItem GetSelectedToolboxItem()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItem GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItemCollection GetToolboxItems()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItemCollection GetToolboxItems(System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItemCollection GetToolboxItems(string category)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ToolboxItemCollection GetToolboxItems(string category, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsSupported(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
+ {
+ return true;
+ }
+
+ public bool IsSupported(object serializedObject, System.Collections.ICollection filterAttributes)
+ {
+ return true;
+ }
+
+ public bool IsToolboxItem(object serializedObject)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Refresh()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveCreator(string format)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveCreator(string format, System.ComponentModel.Design.IDesignerHost host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveToolboxItem(ToolboxItem toolboxItem)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveToolboxItem(ToolboxItem toolboxItem, string category)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SelectedToolboxItemUsed()
+ {
+ throw new NotImplementedException();
+ }
+
+ public object SerializeToolboxItem(ToolboxItem toolboxItem)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool SetCursor()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetSelectedToolboxItem(ToolboxItem toolboxItem)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ }
+// public class ToolboxService2 : System.Drawing.Design.ToolboxService
+// {
+// private CategoryNameCollection categoryNameCollection = new CategoryNameCollection(new string[] {});
+// private string selectedCategory;
+// private ArrayList items = new ArrayList(); // TODO: replace by category item lists.
+//
+// public ToolboxService2() : base()
+// {
+// foreach (Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies())
+// {
+// if (assembly.GetName().Name == "System.Workflow.Activities")
+// {
+// ICollection toolboxItems = System.Drawing.Design.ToolboxService.GetToolboxItems(assembly.GetName());
+// LoggingService.DebugFormatted("ToolboxItems count = {0}", toolboxItems.Count);
+//
+// foreach (ToolboxItem tbi in toolboxItems)
+// {
+// ((IToolboxService)this).AddToolboxItem(tbi);
+// }
+// }
+//
+// }
+// }
+//
+//
+// protected override CategoryNameCollection CategoryNames {
+// get {
+// return categoryNameCollection;
+// }
+// }
+//
+// protected override string SelectedCategory {
+// get {
+// return selectedCategory;
+// }
+// set {
+// selectedCategory = value;
+// }
+// }
+//
+// protected override ToolboxItemContainer SelectedItemContainer {
+// get {
+// throw new NotImplementedException();
+// }
+// set {
+// throw new NotImplementedException();
+// }
+// }
+//
+// protected override System.Collections.IList GetItemContainers()
+// {
+// return items;
+// }
+//
+// protected override System.Collections.IList GetItemContainers(string categoryName)
+// {
+// return items;
+// }
+//
+// protected override void Refresh()
+// {
+// throw new NotImplementedException();
+// }
+//
+// }
+}
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft
new file mode 100644
index 0000000000..8372e54508
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft
@@ -0,0 +1,61 @@
+
+
+
+
+
+ Sequential Workflow (Code-only)
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft
new file mode 100644
index 0000000000..621b0226a6
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft
@@ -0,0 +1,26 @@
+
+
+
+
+
+ Sequential Workflow (No Code)
+
+
+
+
+
+
+]]>
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt
new file mode 100644
index 0000000000..7357f5533e
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt
@@ -0,0 +1,26 @@
+
+
+
+
+
+ Workflow project
+ C#
+ .NET 3.0
+ C#.Project.EmptyProject
+ Empty workflow project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin
new file mode 100644
index 0000000000..6b9b61cc60
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj
new file mode 100644
index 0000000000..9b9b921453
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj
@@ -0,0 +1,154 @@
+
+
+ {533F4684-DBA6-4518-B005-C84F22A2DD57}
+ Debug
+ AnyCPU
+ Library
+ WorkflowDesigner
+ WorkflowDesigner
+ False
+ False
+ 4
+ false
+
+
+ ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\
+ true
+ Full
+ True
+ DEBUG;TRACE
+ False
+ Program
+ ..\..\..\..\..\bin\SharpDevelop.exe
+
+
+ ..\..\..\..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\
+ false
+ None
+ False
+ TRACE
+ False
+
+
+ False
+ Auto
+ 4194304
+ AnyCPU
+ 4096
+
+
+
+
+ False
+
+
+ False
+
+
+
+ False
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Configuration\GlobalAssemblyInfo.cs
+
+
+
+
+ ViewContentControl.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+ {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
+ ICSharpCode.TextEditor
+ False
+
+
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
+ NRefactory
+ False
+
+
+ {2748AD25-9C63-4E12-877B-4DCE96FBED54}
+ ICSharpCode.SharpDevelop
+ False
+
+
+ {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
+ ICSharpCode.Core
+ False
+
+
+ {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
+ ICSharpCode.SharpDevelop.Dom
+ False
+
+
+ {8035765F-D51F-4A0C-A746-2FD100E19419}
+ ICSharpCode.SharpDevelop.Widgets
+ False
+
+
+ {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}
+ FormsDesigner
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
index 28c2ccf2bd..6f24c44202 100644
--- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
+++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
@@ -602,6 +602,10 @@ namespace ICSharpCode.SharpDevelop
return parseInformation;
}
+ ///
+ /// Gets the content of the file using encoding auto-detection (or DefaultFileEncoding, if that fails).
+ /// If the file is already open, gets the text in the opened view content.
+ ///
public static string GetParseableFileContent(string fileName)
{
IViewContent viewContent = FileService.GetOpenFile(fileName);
diff --git a/src/SharpDevelop.sln b/src/SharpDevelop.sln
index 6473ddbdec..9659f2fa59 100644
--- a/src/SharpDevelop.sln
+++ b/src/SharpDevelop.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
-# SharpDevelop 2.1.0.2294
+# SharpDevelop 2.1.0.2314
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkflowDesigner", "AddIns\DisplayBindings\WorkflowDesigner\Project\WorkflowDesigner.csproj", "{533F4684-DBA6-4518-B005-C84F22A2DD57}"
+EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{DB137F0B-9B62-4232-AE92-F7BE0280B8D3}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@@ -444,6 +446,10 @@ Global
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.Build.0 = Release|Any CPU
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {533F4684-DBA6-4518-B005-C84F22A2DD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {533F4684-DBA6-4518-B005-C84F22A2DD57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {533F4684-DBA6-4518-B005-C84F22A2DD57}.Release|Any CPU.Build.0 = Release|Any CPU
+ {533F4684-DBA6-4518-B005-C84F22A2DD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
@@ -455,6 +461,7 @@ Global
{0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{DB137F0B-9B62-4232-AE92-F7BE0280B8D3} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
+ {533F4684-DBA6-4518-B005-C84F22A2DD57} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{08F772A1-F0BE-433E-8B37-F6522953DB05} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}
{F5E059BB-96C2-4398-BED0-8598CD434173} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}
{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}