Browse Source

Add the WorkflowDesigner AddIn written by Russell Wilkins, see http://sdwwf.sf.net/

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2316 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
754731e161
  1. 22
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Configuration/AssemblyInfo.cs
  2. 45
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs
  3. 279
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs
  4. 333
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/NRefactoryDesignerLoader.cs
  5. 35
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs
  6. 95
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs
  7. 175
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs
  8. 36
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs
  9. 99
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs
  10. 113
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs
  11. 67
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs
  12. 79
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/CSharpWorkflowDesignerGeneratorService.cs
  13. 26
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/IWorkflowDesignerGeneratorService.cs
  14. 245
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/WorkflowDesignerGeneratorService.cs
  15. 186
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService.cs
  16. 73
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs
  17. 44
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/IdentifierCreationService.cs
  18. 80
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs
  19. 67
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs
  20. 255
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs
  21. 61
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft
  22. 26
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft
  23. 26
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt
  24. 46
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin
  25. 154
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj
  26. 4
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  27. 9
      src/SharpDevelop.sln

22
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Configuration/AssemblyInfo.cs

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
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("")]

45
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs generated

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
namespace WorkflowDesigner
{
partial class ViewContentControl
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the control.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// 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.
/// </summary>
private void InitializeComponent()
{
//
// ViewContentControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "ViewContentControl";
}
}
}

279
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs

@ -0,0 +1,279 @@ @@ -0,0 +1,279 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of ViewContentControl.
/// </summary>
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
}
}

333
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/NRefactoryDesignerLoader.cs

@ -0,0 +1,333 @@ @@ -0,0 +1,333 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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);
}
}
/// <summary>
/// Description of CodeDomLoader.
/// </summary>
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<IClass> 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<KeyValuePair<string, CompilationUnit>> compilationUnits = new List<KeyValuePair<string, CompilationUnit>>();
bool foundInitMethod = false;
foreach (IClass part in parts) {
string fileName = part.CompilationUnit.FileName;
if (fileName == null) continue;
bool found = false;
foreach (KeyValuePair<string, CompilationUnit> 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<string, CompilationUnit>(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<string, CompilationUnit> 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<IClass> 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 };
}
}
/// <summary>
/// Fix type names and remove unused methods.
/// </summary>
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
}
}

35
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.Runtime.Serialization;
namespace WorkflowDesigner
{
/// <summary>
/// Description of WorkflowDesignerLoaderException.
/// </summary>
[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)
{
}
}
}

95
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of XomlCodeSeparationDesignerLoader.
/// </summary>
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;
}
}
}

175
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs

@ -0,0 +1,175 @@ @@ -0,0 +1,175 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of XomlDesignerLoader.
/// </summary>
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();
}
}
}

36
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#region Using
using System;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of PrimaryDisplayBinding.
/// </summary>
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);
}
}
}

99
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Description of PrimaryViewContent.
/// </summary>
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
}
}

113
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs

@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of SecondaryDisplayBinding.
/// </summary>
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;
}
}
}

67
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of SecondaryViewContent.
/// </summary>
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();
}
}
}

79
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/CSharpWorkflowDesignerGeneratorService.cs

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Description of CSharpWorkflowDesignerGenerator.
/// </summary>
public class CSharpWorkflowDesignerGeneratorService : WorkflowDesignerGeneratorService
{
public CSharpWorkflowDesignerGeneratorService(IServiceProvider provider, string codeSeparationFileName) : base(provider, codeSeparationFileName)
{
}
/// <summary>
/// Finds the start line for the cursor when positioning inside a method.
/// </summary>
/// <param name="document"></param>
/// <param name="method"></param>
/// <returns></returns>
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;
}
}
}

26
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/IWorkflowDesignerGeneratorService.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel;
using System.Collections;
namespace WorkflowDesigner
{
/// <summary>
/// Description of IWorkflowDesignerGenerator.
/// </summary>
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);
}
}

245
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/DesignerGenerator/WorkflowDesignerGeneratorService.cs

@ -0,0 +1,245 @@ @@ -0,0 +1,245 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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
{
/// <summary>
/// Description of WorkflowDesignerGenerator.
/// </summary>
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;
}
/// <summary>
/// Gets a method implementing the signature specified by the event descriptor
/// </summary>
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;
}
/// <summary>
/// Gets a method implementing the signature specified by the event descriptor
/// </summary>
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"));
}
}
}
}
}
}

186
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService.cs

@ -0,0 +1,186 @@ @@ -0,0 +1,186 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.Collections;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace WorkflowDesigner
{
/// <summary>
/// Description of EventBindingService.
/// </summary>
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;
}
}
}

73
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.Workflow.ComponentModel.Design;
namespace WorkflowDesigner
{
/// <summary>
/// Description of ExtendedUIService.
/// </summary>
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<string, Type> GetXsdProjectItemsInfo()
{
throw new NotImplementedException();
}
public void AddAssemblyReference(System.Reflection.AssemblyName assemblyName)
{
throw new NotImplementedException();
}
}
}

44
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/IdentifierCreationService.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Description of IdentifierCreationService.
/// </summary>
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();
}
}
}

80
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.Workflow.ComponentModel.Design;
using ICSharpCode.Core;
namespace WorkflowDesigner
{
/// <summary>
/// Description of MemberCreationService.
/// </summary>
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();
}
}
}

67
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Description of MenuCommandService.
/// </summary>
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();
}
}
}

255
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs

@ -0,0 +1,255 @@ @@ -0,0 +1,255 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Russell Wilkins" email=""/>
// <version>$Revision$</version>
// </file>
#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();
// }
//
// }
}

61
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<Config
name = "Sequential Workflow (Code-only)"
icon = "Icons.32x32.XMLFileIcon"
category = "Workflow"
subcategory = "C#"
defaultname = "Workflow${Number}.cs"
language = "C#"/>
<Description>Sequential Workflow (Code-only)</Description>
<Files>
<File name="${Path}/${FileNameWithoutExtension}.Designer.cs" DependentUpon="${FileName}" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
partial class ${ClassName}
{
private void InitializeComponent()
{
this.Name = "${ClassName}";
}
}
}]]></File>
<File name="${FullName}" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
public partial class ${ClassName}: SequentialWorkflowActivity
{
public ${ClassName}()
{
//
// The InitializeComponent() call is required for designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
}
}]]></File>
</Files>
<AdditionalOptions/>
</Template>

26
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<Config
name = "Sequential Workflow (No Code)"
icon = "Icons.32x32.XMLFileIcon"
category = "Workflow"
defaultname = "Workflow${Number}.xoml"
language = "Xoml"/>
<Description>Sequential Workflow (No Code)</Description>
<Files>
<File name="${FullName}" language="Xoml"><![CDATA[
<SequentialWorkflowActivity x:Class="${StandardNamespace}.${ClassName}" x:Name="${ClassName}" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
</SequentialWorkflowActivity>
]]></File>
</Files>
<AdditionalOptions/>
</Template>

26
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<!-- Template Header -->
<TemplateConfiguration>
<Name>Workflow project</Name>
<Category>C#</Category>
<Subcategory>.NET 3.0</Subcategory>
<Icon>C#.Project.EmptyProject</Icon>
<Description>Empty workflow project</Description>
</TemplateConfiguration>
<Project language="C#" >
<Imports>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.0\Workflow.Targets" />
</Imports>
<ProjectItems>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Workflow.Activities" />
<Reference Include="System.Workflow.ComponentModel" />
<Reference Include="System.Workflow.Runtime" />
</ProjectItems>
</Project>
</Template>

46
src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
<AddIn name = "Workflow Foundation Designer"
author = "Russell Wilkins"
url = ""
description = "Windows Workflow Foundation Designer">
<Runtime>
<Import assembly = "WorkflowDesigner.dll"/>
</Runtime>
<Manifest>
<Identity name="WorkflowDesigner" version="@WorkflowDesigner.dll"/>
<Dependency addin="SharpDevelop" version="3.0"/>
</Manifest>
<!--Primary View -->
<Path name="/SharpDevelop/Workbench/FileFilter">
<FileFilter id = "WorkflowFileFilter"
name = "Workflow (*.xoml)"
extensions = "*.xoml"
insertbefore = "Boo"/>
</Path>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "WorkflowDisplayBinding"
class = "WorkflowDesigner.WorkflowPrimaryDisplayBinding"
insertbefore = "Text"
fileNamePattern = "\.(xoml)$"
languagePattern = "^Xoml$"
/>
</Path>
<!--Secondary View -->
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "WorkflowDesignerSecondary"
type = "Secondary"
class = "WorkflowDesigner.WorkflowDesignerSecondaryDisplayBinding"
fileNamePattern = "\.cs?$" />
</Path>
<!--Template path -->
<Path name = "/SharpDevelop/BackendBindings/Templates">
<Directory id = "WorkflowDesigner" path = "./Templates" />
</Path>
</AddIn>

154
src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj

@ -0,0 +1,154 @@ @@ -0,0 +1,154 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{533F4684-DBA6-4518-B005-C84F22A2DD57}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>WorkflowDesigner</RootNamespace>
<AssemblyName>WorkflowDesigner</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
<StartAction>Program</StartAction>
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="System">
<Private>False</Private>
</Reference>
<Reference Include="System.Data">
<Private>False</Private>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Drawing">
<Private>False</Private>
</Reference>
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Windows.Forms">
<Private>False</Private>
</Reference>
<Reference Include="System.Workflow.Activities">
<Private>False</Private>
</Reference>
<Reference Include="System.Workflow.ComponentModel">
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Templates\Files\CSharp\CodeSequentialWorkflow.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\CSharp\EmptyProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WorkflowDesigner.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\Gui\ViewContentControl.cs" />
<Compile Include="Src\Gui\ViewContentControl.Designer.cs">
<DependentUpon>ViewContentControl.cs</DependentUpon>
</Compile>
<Compile Include="Src\Loaders\NRefactoryDesignerLoader.cs" />
<Compile Include="Src\Loaders\WorkflowDesignerLoadException.cs" />
<Compile Include="Src\Loaders\XomlCodeSeparationDesignerLoader.cs" />
<Compile Include="Src\Loaders\XomlDesignerLoader.cs" />
<Compile Include="Src\PrimaryView\PrimaryDisplayBinding.cs" />
<Compile Include="Src\PrimaryView\PrimaryViewContent.cs" />
<Compile Include="Src\SecondaryView\SecondaryDisplayBinding.cs" />
<Compile Include="Src\SecondaryView\SecondaryViewContent.cs" />
<Compile Include="Src\Services\DesignerGenerator\CSharpWorkflowDesignerGeneratorService.cs" />
<Compile Include="Src\Services\DesignerGenerator\IWorkflowDesignerGeneratorService.cs" />
<Compile Include="Src\Services\DesignerGenerator\WorkflowDesignerGeneratorService.cs" />
<Compile Include="Src\Services\EventBindingService.cs" />
<Compile Include="Src\Services\IdentifierCreationService.cs" />
<Compile Include="Src\Services\MemberCreationService.cs" />
<Compile Include="Src\Services\WorkflowMenuCommandService.cs" />
<Compile Include="Src\Services\WorkflowToolboxService.cs" />
<None Include="Templates\Files\NoCodeSequentialWorkflow.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="Src\Gui" />
<Folder Include="Src\Loaders" />
<Folder Include="Src\Commands" />
<Folder Include="Src\PrimaryView" />
<Folder Include="Src\Services" />
<Folder Include="Src\Services\DesignerGenerator" />
<Folder Include="Templates" />
<Folder Include="Src\SecondaryView" />
<Folder Include="Templates\Files" />
<Folder Include="Templates\Files\CSharp" />
<Folder Include="Templates\Files\VB" />
<Folder Include="Templates\Projects" />
<Folder Include="Templates\Projects\CSharp" />
<Folder Include="Templates\Projects\VB" />
</ItemGroup>
</Project>

4
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -602,6 +602,10 @@ namespace ICSharpCode.SharpDevelop @@ -602,6 +602,10 @@ namespace ICSharpCode.SharpDevelop
return parseInformation;
}
/// <summary>
/// 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.
/// </summary>
public static string GetParseableFileContent(string fileName)
{
IViewContent viewContent = FileService.GetOpenFile(fileName);

9
src/SharpDevelop.sln

@ -1,7 +1,7 @@ @@ -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 @@ -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 @@ -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 @@ -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}

Loading…
Cancel
Save