Browse Source

Replace WorkflowDesigner with simple designer for Workflow Foundation 4.0.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4445 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
137bb94ea0
  1. 45
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.Designer.cs
  2. 222
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs
  3. 152
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/BasicWorkflowDesignerLoader.cs
  4. 290
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/CodeDesignerLoader.cs
  5. 35
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/WorkflowDesignerLoadException.cs
  6. 137
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs
  7. 36
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryDisplayBinding.cs
  8. 84
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/PrimaryView/PrimaryViewContent.cs
  9. 115
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryDisplayBinding.cs
  10. 67
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs
  11. 74
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs
  12. 201
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs
  13. 25
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs
  14. 425
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs
  15. 73
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/ExtendedUIService.cs
  16. 96
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/MemberCreationService.cs
  17. 75
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/PropertyValueUIService.cs
  18. 354
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/TypeProviderService.cs
  19. 137
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/TypeResolutionService.cs
  20. 139
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowMenuCommandService.cs
  21. 388
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs
  22. 204
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowToolboxService.cs
  23. 38
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/Activity.xft
  24. 38
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSeparationSequentialWorkflow.xft
  25. 61
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSequentialWorkflow.xft
  26. 26
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/NoCodeSequentialWorkflow.xft
  27. 27
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/Sequence.xft
  28. 103
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/ActivityLibrary.xpt
  29. 136
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/ConsoleProject.xpt
  30. 69
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/EmptyProject.xpt
  31. 34
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.addin
  32. 97
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesigner.csproj
  33. 114
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesignerViewContent.cs
  34. 58
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDisplayBinding.cs
  35. 4
      src/Setup/Files.wxs
  36. 3
      src/Setup/Setup.wxs

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

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// <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";
}
}
}

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

@ -1,222 +0,0 @@ @@ -1,222 +0,0 @@
// <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.Design;
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 ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using WorkflowDesigner.Loaders;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of ViewContentControl.
/// </summary>
public partial class ViewContentControl : UserControl, IHasPropertyContainer
{
private DesignSurface designSurface;
private BasicDesignerLoader loader;
private IViewContent viewContent;
private bool addedSideTab;
public ViewContentControl(IViewContent viewContent)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.viewContent = viewContent;
}
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)
{
StatusBarService.SetMessage("Loading workflow " + Path.GetFileName(viewContent.PrimaryFileName) + "...");
Application.UseWaitCursor = true;
Application.DoEvents();
if (!addedSideTab){
WorkflowSideTabService.AddViewContent(this.viewContent);
addedSideTab = true;
}
this.loader = loader;
try {
LoadDesigner();
if (designSurface != null && Controls.Count == 0) {
Control designer = designSurface.View as Control;
designer.Dock = DockStyle.Fill;
Controls.Add(designer);
DesignerHost.Activate();
}
} catch (Exception e) {
TextBox errorText = new TextBox();
errorText.Multiline = true;
errorText.ScrollBars = ScrollBars.Both;
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);
errorText.BringToFront();
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);
} finally {
StatusBarService.SetMessage(String.Empty);
Application.UseWaitCursor = false;
}
}
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)
{
viewContent.PrimaryFile.MakeDirty();
LoggingService.Debug("ComponentAddedHandler");
}
void ComponentAddingHandler(object sender, ComponentEventArgs args)
{
LoggingService.Debug("ComponentAddingHandler");
}
void ComponentChangedHandler(object sender, ComponentChangedEventArgs args)
{
viewContent.PrimaryFile.MakeDirty();
ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));
UpdatePropertyPadSelection(selectionService);
}
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;
propertyContainer.SelectedObjects = selArray;
}
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
}
}

152
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/BasicWorkflowDesignerLoader.cs

@ -1,152 +0,0 @@ @@ -1,152 +0,0 @@
// <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.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing.Design;
using System.Globalization;
using System.IO;
using System.Text;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
#endregion
namespace WorkflowDesigner.Loaders
{
/// <summary>
/// Description of BasicWorkflowDesignerLoader.
/// </summary>
public abstract class BasicWorkflowDesignerLoader : WorkflowDesignerLoader
{
private IViewContent viewContent;
private string ruleFileName;
private StringBuilder rules;
protected BasicWorkflowDesignerLoader(IViewContent viewContent)
{
this.viewContent = viewContent;
ruleFileName = Path.Combine(Path.GetDirectoryName(FileName),
Path.GetFileNameWithoutExtension(FileName) + ".rules");
}
#region Property Accessors
public IViewContent ViewContent {
get { return viewContent; }
}
public override string FileName {
get {
return viewContent.PrimaryFileName;
}
}
public IProject Project {
get {
return ProjectService.OpenSolution.FindProjectContainingFile(FileName);
}
}
#endregion
public override TextReader GetFileReader(string filePath)
{
return new StringReader(rules.ToString());
}
public override TextWriter GetFileWriter(string filePath)
{
if (rules == null) {
rules = new StringBuilder();
CreateRulesProjectItem();
}
return new StringWriter(rules, CultureInfo.CurrentCulture);
}
private void LoadRules()
{
// Load the rules
if (File.Exists(ruleFileName)) {
rules = new StringBuilder(File.ReadAllText(ruleFileName));
CreateRulesProjectItem();
}
}
private void UpdateRules()
{
if ((rules != null) && (rules.Length > 0))
File.WriteAllText(ruleFileName, rules.ToString());
}
private void CreateRulesProjectItem()
{
if (Project != null){
if (!Project.IsFileInProject(ruleFileName)) {
FileProjectItem rfpi = new FileProjectItem(Project,ItemType.EmbeddedResource);
rfpi.FileName = Path.Combine(Path.GetDirectoryName(FileName), Path.GetFileName(ruleFileName));
rfpi.DependentUpon = Path.GetFileName(FileName);
ProjectService.AddProjectItem(Project, rfpi);
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView();
Project.Save();
}
}
}
protected override void Initialize()
{
base.Initialize();
// Add the basic service required by all designers
LoaderHost.AddService(typeof(IToolboxService), new WorkflowToolboxService(LoaderHost));
LoaderHost.AddService(typeof(ITypeProvider), TypeProviderService.GetTypeProvider(Project));
LoaderHost.AddService(typeof(IMenuCommandService), new WorkflowMenuCommandService(LoaderHost));
LoaderHost.AddService(typeof(ITypeResolutionService), new TypeResolutionService(Project,LoaderHost));
LoaderHost.AddService(typeof(IPropertyValueUIService), new PropertyValueUIService());
}
public override void Dispose()
{
try {
// 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(IMenuCommandService));
LoaderHost.RemoveService(typeof(IPropertyValueUIService));
LoaderHost.RemoveService(typeof(ITypeResolutionService));
LoaderHost.RemoveService(typeof(IMemberCreationService));
}
} finally {
base.Dispose();
}
}
protected override void PerformLoad(IDesignerSerializationManager serializationManager)
{
DoPerformLoad(serializationManager);
LoadRules();
}
protected abstract void DoPerformLoad(IDesignerSerializationManager serializationManager);
protected override void PerformFlush(IDesignerSerializationManager serializationManager)
{
DoPerformFlush(serializationManager);
UpdateRules();
}
protected abstract void DoPerformFlush(IDesignerSerializationManager serializationManager);
}
}

290
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/CodeDesignerLoader.cs

@ -1,290 +0,0 @@ @@ -1,290 +0,0 @@
// <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.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.IO;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
#endregion
namespace WorkflowDesigner.Loaders
{
/// <summary>
/// Description of CodeDesignerLoader.
/// </summary>
public class CodeDesignerLoader : BasicWorkflowDesignerLoader
{
public CodeDesignerLoader(IViewContent viewContent) : base(viewContent)
{
}
protected override void Initialize()
{
base.Initialize();
LoaderHost.AddService(typeof(IMemberCreationService), new MemberCreationService(LoaderHost));
LoaderHost.AddService(typeof(CodeDomProvider), Project.LanguageProperties.CodeDomProvider);
LoaderHost.AddService(typeof(IEventBindingService), new CSharpWorkflowDesignerEventBindingService(LoaderHost, ViewContent.PrimaryFileName));
}
protected override void DoPerformLoad(IDesignerSerializationManager serializationManager)
{
// Step 1, Get the CodeDom
CodeCompileUnit ccu = Parse();
// Step 2, Find the first class
CodeTypeDeclaration codeTypeDeclaration = ccu.Namespaces[0].Types[0];
TypeResolutionService typeResolutionService = GetService(typeof(ITypeResolutionService)) as TypeResolutionService;
Type baseType = typeResolutionService.GetType(codeTypeDeclaration.BaseTypes[0].BaseType);
if (baseType == null)
throw new WorkflowDesignerLoadException("Unable to resolve type " + codeTypeDeclaration.BaseTypes[0].BaseType);
// Step 3, Deserialize it!
TypeCodeDomSerializer serializer = serializationManager.GetSerializer(baseType, typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
#if DEBUG
Project.LanguageProperties.CodeDomProvider.GenerateCodeFromType(codeTypeDeclaration, Console.Out, null);
#endif
// Step 4, load up the designer.
Activity rootActivity = serializer.Deserialize(serializationManager, codeTypeDeclaration) as Activity;
// FIXME: This is a workaraound as the deserializer does not appear to add the
// components to the container with the activity.name so
// the designer complains the name is already used when the
// name of an activity is the same as a field name in the workflow!
// When I work out how the IMemberCreationService fits into
// the scheme of things this will probably go away!
// (Worth noting CodeDomDesignerLoader has the same problem!)
//int i = 0;
foreach(IComponent c in LoaderHost.Container.Components) {
if (c is Activity) {
LoaderHost.Container.Remove(c);
LoaderHost.Container.Add(c, ((Activity)c).Name);
}
}
SetBaseComponentClassName(ccu.Namespaces[0].Name + "." + codeTypeDeclaration.Name);
}
protected override void DoPerformFlush(IDesignerSerializationManager serializationManager)
{
// TODO: Update the InitializeComponent() method here.
}
#region Taken from FormDesigner.NRefactoryDesignerLoad to get a single CodeCompileUnit for the activity.
protected CodeCompileUnit Parse()
{
ParseInformation parseInfo = ParserService.GetParseInformation(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"}}
));
}
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);
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)
{
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).Parts;
} else {
return new IClass[] { formClass };
}
}
/// <summary>
/// Fix type names and remove unused methods.
/// </summary>
public static 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);
}
}
}
}
public static void FixTypeReference(TypeReference type, Location location, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu)
{
if (type == null)
return;
if (type.IsKeyword)
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

@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
// <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.Loaders
{
/// <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)
{
}
}
}

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

@ -1,137 +0,0 @@ @@ -1,137 +0,0 @@
// <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.Globalization;
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 System.Collections;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
#endregion
namespace WorkflowDesigner.Loaders
{
enum AuthoringMode {
NoCode,
CodeSeparation
}
/// <summary>
/// Description of XomlDesignerLoader.
/// </summary>
public class XomlDesignerLoader : BasicWorkflowDesignerLoader
{
private AuthoringMode authoringMode = AuthoringMode.NoCode;
private string xoml;
private string codeBesideFileName;
public XomlDesignerLoader(IViewContent viewContent) : base(viewContent)
{
// Look for a code beside file for CodeSeparation mode.
if (Project != null) {
FileProjectItem fpi = Project.FindFile(FileName);
string codeFileName = FileName + "." + Project.LanguageProperties.CodeDomProvider.FileExtension;
FileProjectItem dfpi = Project.FindFile(codeFileName);
if (dfpi.DependentUpon == Path.GetFileName(fpi.VirtualName)) {
authoringMode = AuthoringMode.CodeSeparation;
codeBesideFileName = codeFileName;
}
}
}
public XomlDesignerLoader(IViewContent viewContent, Stream stream) : this(viewContent)
{
Encoding encoding = ICSharpCode.SharpDevelop.ParserService.DefaultFileEncoding;
xoml = ICSharpCode.TextEditor.Util.FileReader.ReadFileContent(stream, ref encoding);
}
public string Xoml {
get { return xoml; }
set { xoml = value; }
}
protected override void Initialize()
{
base.Initialize();
// Install the additional services into the designer.
if (authoringMode == AuthoringMode.CodeSeparation) {
LoaderHost.AddService(typeof(IMemberCreationService), new MemberCreationService(LoaderHost));
LoaderHost.AddService(typeof(IEventBindingService), new CSharpWorkflowDesignerEventBindingService(LoaderHost,codeBesideFileName));
}
}
protected override void DoPerformFlush(IDesignerSerializationManager serializationManager)
{
Activity rootActivity = LoaderHost.RootComponent as Activity;
if (rootActivity != null) {
StringBuilder sb = new StringBuilder();
XmlTextWriter xmlWriter = new XmlTextWriter(new StringWriter(sb, CultureInfo.CurrentCulture));
try {
WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
xomlSerializer.Serialize(serializationManager, xmlWriter, rootActivity);
xoml = sb.ToString();
} finally {
xmlWriter.Close();
}
}
}
protected override void DoPerformLoad(IDesignerSerializationManager serializationManager)
{
LoadXoml(serializationManager);
}
protected void LoadXoml(IDesignerSerializationManager serializationManager)
{
// 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(serializationManager, reader) as Activity;
} finally {
reader.Close();
}
LoaderHost.Container.Add(rootActivity, rootActivity.QualifiedName);
CompositeActivity compositeActivity = rootActivity as CompositeActivity;
if (compositeActivity != null)
AddChildren(compositeActivity);
SetBaseComponentClassName(rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string);
}
protected void AddChildren(CompositeActivity compositeActivity)
{
foreach (Activity activity in compositeActivity.Activities) {
LoaderHost.Container.Add(activity, activity.QualifiedName);
CompositeActivity compositeActivity2 = activity as CompositeActivity;
if (compositeActivity2 != null)
AddChildren(compositeActivity2);
}
}
}
}

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

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// <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);
}
}
}

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

@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
// <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 WorkflowDesigner.Loaders;
namespace WorkflowDesigner
{
/// <summary>
/// Description of PrimaryViewContent.
/// </summary>
public class WorkflowPrimaryViewContent : AbstractViewContent, IHasPropertyContainer, IToolsHost
{
ViewContentControl control;
public WorkflowPrimaryViewContent(OpenedFile primaryFile) : base(primaryFile)
{
if (primaryFile == null)
throw new ArgumentNullException("primaryFile");
this.TabPageText = "Workflow";
control = new ViewContentControl(this);
primaryFile.ForceInitializeView(this); // call Load()
}
public override object Control {
get {
return control;
}
}
public override void Load(OpenedFile file, Stream stream)
{
Debug.Assert(file == this.PrimaryFile);
control.LoadWorkflow(new XomlDesignerLoader(this, stream));
}
public override void Save(OpenedFile file, Stream stream)
{
Debug.Assert(file == this.PrimaryFile);
control.SaveWorkflow(stream);
}
public void LoadContent(string content)
{
if (content == null)
throw new ArgumentNullException("content");
XomlDesignerLoader xomlDesignerLoader = new XomlDesignerLoader(this);
xomlDesignerLoader.Xoml = content;
control.LoadWorkflow(xomlDesignerLoader);
}
#region IHasPropertyContainer
public PropertyContainer PropertyContainer {
get {
return control.PropertyContainer;
}
}
#endregion
object IToolsHost.ToolsContent {
get {
return WorkflowSideTabService.WorkflowSideBar;
}
}
}
}

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

@ -1,115 +0,0 @@ @@ -1,115 +0,0 @@
// <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 == null)
throw new ArgumentNullException("content");
if (content is ITextEditorControlProvider) {
ITextEditorControlProvider textAreaControlProvider = (ITextEditorControlProvider)content;
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

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
// <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;
using WorkflowDesigner.Loaders;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of SecondaryViewContent.
/// </summary>
public class WorkflowDesignerSecondaryViewContent : AbstractSecondaryViewContent, IHasPropertyContainer, IToolsHost
{
ViewContentControl control;
#region Constructors
public WorkflowDesignerSecondaryViewContent(IViewContent primaryViewContent) : base(primaryViewContent)
{
this.TabPageText = "Workflow";
control = new ViewContentControl(primaryViewContent);
}
#endregion
#region Property Accessors
public override object Control {
get {
return control;
}
}
public PropertyContainer PropertyContainer {
get {
return control.PropertyContainer;
}
}
#endregion
protected override void LoadFromPrimary()
{
control.LoadWorkflow(new CodeDesignerLoader(this.PrimaryViewContent));
}
protected override void SaveToPrimary()
{
control.UnloadWorkflow();
}
object IToolsHost.ToolsContent {
get {
return WorkflowSideTabService.WorkflowSideBar;
}
}
}
}

74
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs

@ -1,74 +0,0 @@ @@ -1,74 +0,0 @@
// <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;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Ast;
namespace WorkflowDesigner
{
/// <summary>
/// Description of CSharpWorkflowDesignerGenerator.
/// </summary>
public class CSharpWorkflowDesignerEventBindingService : WorkflowDesignerEventBindingService
{
public CSharpWorkflowDesignerEventBindingService(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 TextLocation(r.BeginColumn - 1, r.BeginLine - 1));
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 = GenerateParameters(completeClass, edesc, true);
StringBuilder b = new StringBuilder();
b.AppendLine(indentation);
b.AppendLine(indentation + "void " + eventMethodName + "(" + param + ")");
b.AppendLine(indentation + "{");
b.AppendLine(indentation + "\t" + body);
b.AppendLine(indentation + "}");
return b.ToString();
}
protected static string GenerateParameters(IClass completeClass, EventDescriptor eventDescriptor, bool paramNames)
{
CSharpOutputVisitor v = new CSharpOutputVisitor();
MethodDeclaration md = ConvertDescriptorToNRefactory(completeClass, eventDescriptor, "name");
if (md != null) {
v.AppendCommaSeparatedList(md.Parameters);
}
return v.Text;
}
}
}

201
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs

@ -1,201 +0,0 @@ @@ -1,201 +0,0 @@
/*
* Created by SharpDevelop.
* User: Russell Wilkins
* Date: 30/01/2007
* Time: 12:17
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
#region Using
using System;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Collections;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of EventPropertyDescriptor.
/// </summary>
public class EventPropertyDescriptor : PropertyDescriptor
{
internal EventDescriptor eventDescriptor;
private IServiceProvider provider;
private TypeConverter converter;
public EventPropertyDescriptor(IServiceProvider provider, EventDescriptor eventDescriptor) : base(eventDescriptor, null)
{
this.eventDescriptor = eventDescriptor;
this.provider = provider;
}
public override Type ComponentType {
get {
return eventDescriptor.ComponentType;
}
}
public override bool IsReadOnly {
get {
return false;
}
}
public override TypeConverter Converter {
get {
if (converter == null)
converter = new EventPropertyTypeConverter(this);
return converter;
}
}
public override Type PropertyType {
get {
return eventDescriptor.EventType;
}
}
public override bool CanResetValue(object component)
{
return false;
}
public override object GetValue(object component)
{
Activity activity = component as Activity;
if (component == null)
throw new ArgumentException("component must be derived from Activity");
string value = null;
// Find method name associated with the EventDescriptor.
Hashtable events = activity.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
if (events != null) {
if (events.ContainsKey(this.eventDescriptor.Name))
value = events[this.eventDescriptor.Name] as string;
}
return value;
}
public override void ResetValue(object component)
{
SetValue(component, null);
}
public override void SetValue(object component, object value)
{
// Validate the parameters.
DependencyObject dependencyObject = component as DependencyObject;
if (dependencyObject == null)
throw new ArgumentException(component.ToString() + " must be derived from DependencyObject", "component");
// Get the event list form the dependency object.
Hashtable events = dependencyObject.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
if (events == null) {
events = new Hashtable();
dependencyObject.SetValue(WorkflowMarkupSerializer.EventsProperty, events);
}
string oldValue = events[this.eventDescriptor.Name] as string;
// Value not changed need go no further.
if (oldValue != null) {
if (oldValue.CompareTo(value) == 0)
return;
}
IComponentChangeService componentChangedService = provider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
componentChangedService.OnComponentChanging(component, this.eventDescriptor);
// Update to new value.
events[this.eventDescriptor.Name] = value;
componentChangedService.OnComponentChanged(component, this.eventDescriptor, oldValue, value);
}
public override bool ShouldSerializeValue(object component)
{
if (GetValue (component) == null) return false;
return true;
}
/// <summary>
/// To allow the designer to convert the descriptor to/from string.
/// </summary>
class EventPropertyTypeConverter : TypeConverter
{
private EventPropertyDescriptor eventPropertyDescriptor;
internal EventPropertyTypeConverter(EventPropertyDescriptor eventPropertyDescriptor)
{
this.eventPropertyDescriptor = eventPropertyDescriptor;
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
return value;
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
return value;
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
ICollection compatibleMethods = null;;
if (context != null) {
IEventBindingService eventBindingService = context.GetService(typeof(IEventBindingService)) as IEventBindingService;
if (eventBindingService != null)
compatibleMethods = eventBindingService.GetCompatibleMethods(eventPropertyDescriptor.eventDescriptor);
}
return new StandardValuesCollection(compatibleMethods);
}
}
}
}

25
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
// <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.Collections;
using System.ComponentModel.Design;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of IWorkflowDesignerGenerator.
/// </summary>
public interface IWorkflowDesignerEventBindingService : IEventBindingService
{
string CodeFileName { get;}
void UpdateCodeCompileUnit();
}
}

425
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs

@ -1,425 +0,0 @@ @@ -1,425 +0,0 @@
// <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 System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Workflow.ComponentModel.Design;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel.Compiler;
using System.CodeDom;
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;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop.Project;
using WorkflowDesigner.Loaders;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of WorkflowDesignerGenerator.
/// </summary>
public abstract class WorkflowDesignerEventBindingService : IWorkflowDesignerEventBindingService, IServiceProvider
{
string codeFileName;
protected WorkflowDesignerEventBindingService(IServiceProvider provider, string codeFileName)
{
this.provider = provider;
this.codeFileName = codeFileName;
}
#region IWorkflowDesignerEventBindingService implementation
public void UpdateCodeCompileUnit()
{
LoggingService.Debug("UpdateCCU");
IProject project = ProjectService.OpenSolution.FindProjectContainingFile(codeFileName);
FileProjectItem fpi = project.FindFile(codeFileName);
TypeProviderService.UpdateCodeCompileUnit(fpi);
}
public string CodeFileName {
get {
return codeFileName;
}
}
private void RefreshCCU(object sender, EventArgs e)
{
}
#endregion
CodeCompileUnit Parse()
{
ParseInformation parseInfo = ParserService.GetParseInformation(codeFileName);
IClass formClass = null;
bool isFirstClassInFile;
IList<IClass> parts = FindFormClassParts(parseInfo, out formClass, out isFirstClassInFile);
// Get all the related compilation units.
List<KeyValuePair<string, CompilationUnit>> compilationUnits = new List<KeyValuePair<string, CompilationUnit>>();
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 parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(fileContent));
parser.Parse();
if (parser.Errors.Count > 0) {
throw new WorkflowDesignerLoadException("Syntax errors in " + fileName + ":\r\n" + parser.Errors.ErrorOutput);
}
compilationUnits.Add(new KeyValuePair<string, CompilationUnit>(fileName, parser.CompilationUnit));
}
if (compilationUnits.Count == 1)
{
CodeDomVisitor visitor1 = new CodeDomVisitor();
visitor1.VisitCompilationUnit(compilationUnits[0].Value, null);
return visitor1.codeCompileUnit;
}
return null;
//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);
// return visitor.codeCompileUnit;
}
public static IList<IClass> FindFormClassParts(ParseInformation parseInfo, out IClass formClass, out bool isFirstClassInFile)
{
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).Parts;
} else {
return new IClass[] { formClass };
}
}
#region IServiceProvider implementation
IServiceProvider provider;
public object GetService(Type serviceType)
{
return provider.GetService(serviceType);
}
#endregion
#region IEventBindingService implemention
public string CreateUniqueMethodName(IComponent component, EventDescriptor e)
{
if (component == null)
throw new ArgumentNullException("component");
if (e == null)
throw new ArgumentNullException("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 EventDescriptor GetEvent(PropertyDescriptor property)
{
EventPropertyDescriptor epd = property as EventPropertyDescriptor;
if (epd == null)
return null;
return epd.eventDescriptor;
}
public PropertyDescriptorCollection GetEventProperties(EventDescriptorCollection events)
{
if (events == null)
throw new ArgumentNullException("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(this,e);
}
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.codeFileName);
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;
}
public bool ShowCode()
{
FileService.OpenFile(codeFileName);
return true;
}
public bool ShowCode(int lineNumber)
{
ITextEditorControlProvider t = FileService.OpenFile(codeFileName) as ITextEditorControlProvider;
t.TextEditorControl.ActiveTextAreaControl.JumpTo(lineNumber);
return true;
}
public bool ShowCode(IComponent component, EventDescriptor e)
{
if (component == null)
throw new ArgumentNullException("component");
if (e == null)
throw new ArgumentNullException("e");
Activity activity = component as Activity;
if (component == null)
throw new ArgumentException("component must be derived from Activity");
string methodName = string.Empty;
// Find method name associated with the EventDescriptor.
Hashtable events = activity.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
if (events != null) {
if (events.ContainsKey(e.Name))
methodName = events[e.Name] as string;
}
return UseMethod(component, e, methodName);
}
#endregion
protected virtual int GetCursorLine(IDocument document, IMethod method)
{
return method.BodyRegion.BeginLine + 1;
}
protected abstract string CreateEventHandler(IClass completeClass, EventDescriptor eventDescriptor, string eventMethodName, string body, string indentation);
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.codeFileName);
ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
ITextEditorControlProvider t = FileService.OpenFile(codeFileName) 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 eventDescriptor, string methodName)
{
return ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertMember(
ConvertDescriptorToDom(completeClass, eventDescriptor, 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 bool UseMethod(IComponent component, EventDescriptor eventDescriptor, string methodName)
{
LoggingService.DebugFormatted("UseMethod {0}", methodName);
LoggingService.DebugFormatted("CodeFileName={0}", this.codeFileName);
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(codeFileName) as ITextEditorControlProvider;
LoggingService.DebugFormatted("DesignerHost.RootComponent={0}", rootDesigner.Component.Site.Name);
ParseInformation info = ParserService.ParseFile(this.codeFileName);
ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
MethodInfo methodInfo = eventDescriptor.EventType.GetMethod("Invoke");
completeClass = cu.Classes[0].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 true;
}
}
}
LoggingService.DebugFormatted("Creating new method...");
int line = GetEventHandlerInsertionLine(cu.Classes[0]);
int offset = t.TextEditorControl.Document.GetLineSegment(line - 1).Offset;
t.TextEditorControl.Document.Insert(offset, CreateEventHandler(completeClass, eventDescriptor, methodName, "", "\t\t"));
UpdateCodeCompileUnit();
return ShowCode(component, eventDescriptor, methodName);
}
return false;
}
}
}

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

@ -1,73 +0,0 @@ @@ -1,73 +0,0 @@
// <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();
}
}
}

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

@ -1,96 +0,0 @@ @@ -1,96 +0,0 @@
// <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.CodeDom;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;
using ICSharpCode.Core;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of MemberCreationService.
/// </summary>
public class MemberCreationService : IMemberCreationService, IServiceProvider
{
private string typeName = string.Empty;
#region IServiceProvider implementation
IServiceProvider provider;
public object GetService(Type serviceType)
{
return provider.GetService(serviceType);
}
#endregion
public MemberCreationService(IServiceProvider provider)
{
this.provider = provider;
}
public void CreateField(string className, string fieldName, Type fieldType, Type[] genericParameterTypes, MemberAttributes attributes, System.CodeDom.CodeSnippetExpression initializationExpression, bool overwriteExisting)
{
throw new NotImplementedException();
}
public void CreateProperty(string className, string propertyName, Type propertyType, AttributeInfo[] attributes, bool emitDependencyProperty, bool isMetaProperty, bool isAttached, Type ownerType, bool isReadOnly)
{
throw new NotImplementedException();
}
public void CreateEvent(string className, string eventName, Type eventType, AttributeInfo[] attributes, bool emitDependencyProperty)
{
throw new NotImplementedException();
}
public void UpdateTypeName(string oldClassName, string newClassName)
{
LoggingService.DebugFormatted("UpdateTypeName(oldClassName={0}, newClassName={1})", oldClassName, newClassName);
typeName = newClassName;
}
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(Activity activity, string methodName, Type delegateType)
{
throw new NotImplementedException();
}
public void ShowCode()
{
throw new NotImplementedException();
}
}
}

75
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/PropertyValueUIService.cs

@ -1,75 +0,0 @@ @@ -1,75 +0,0 @@
// <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.Drawing.Design;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of PropertyValueUIService.
/// </summary>
public class PropertyValueUIService : IPropertyValueUIService
{
private PropertyValueUIHandler handler;
public PropertyValueUIService()
{
}
public event EventHandler PropertyUIValueItemsChanged;
public void AddPropertyValueUIHandler(PropertyValueUIHandler newHandler)
{
if (newHandler == null)
throw new ArgumentNullException("newHandler");
handler += newHandler;
}
public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
{
if (context == null)
throw new ArgumentNullException("context");
if (propDesc == null)
throw new ArgumentNullException("propDesc");
if (handler != null){
ArrayList valueUIItemList = new ArrayList();
handler(context, propDesc, valueUIItemList);
if (valueUIItemList.Count > 0) {
PropertyValueUIItem[] valueItems = new PropertyValueUIItem[valueUIItemList.Count];
valueUIItemList.CopyTo(valueItems, 0);
return valueItems;
}
}
return null;
}
public void NotifyPropertyValueUIItemsChanged()
{
if (PropertyUIValueItemsChanged != null)
PropertyUIValueItemsChanged(this, EventArgs.Empty);
}
public void RemovePropertyValueUIHandler(PropertyValueUIHandler newHandler)
{
if (newHandler == null)
throw new ArgumentNullException("newHandler");
handler -= newHandler;
}
}
}

354
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/TypeProviderService.cs

@ -1,354 +0,0 @@ @@ -1,354 +0,0 @@
// <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.Specialized;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Workflow.ComponentModel.Compiler;
using System.Reflection;
using System.CodeDom;
using System.CodeDom.Compiler;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// This service maintains a single TypeProvider for each workflow project. All designers in
/// the project will use the same typeprovider. The providers are kept up to date with the
/// project references so the designers do no need manage it themselves.
/// </summary>
public class TypeProviderService
{
private static Dictionary<IProject, TypeProvider> providers;
private static Dictionary<FileProjectItem, CodeCompileUnit> codeCompileUnits;
#region Property Accessors
private static Dictionary<IProject, TypeProvider> Providers {
get {
if (providers == null)
providers = new Dictionary<IProject, TypeProvider>();
return providers;
}
}
private static Dictionary<FileProjectItem, CodeCompileUnit> CodeCompileUnits {
get {
if (codeCompileUnits == null)
codeCompileUnits = new Dictionary<FileProjectItem, CodeCompileUnit>();
return codeCompileUnits;
}
}
#endregion
static TypeProviderService()
{
ProjectService.ProjectItemRemoved += ProjectItemRemovedEventHandler;
ProjectService.ProjectItemAdded += ProjectItemAddedEventHandler;
ProjectService.SolutionClosing += SolutionClosingEventHandler;
}
/// <summary>
/// Return the type provider for the specified project.
/// </summary>
/// <param name="project">Project whose ITypeProvider is required</param>
/// <returns>The ITypeProvider for the pass IProject, or a default provider if
/// no project passed.</returns>
public static ITypeProvider GetTypeProvider(IProject project)
{
if ((project != null) && (Providers.ContainsKey(project)))
return Providers[project];
TypeProvider typeProvider = new TypeProvider(null);
// Add the essential designer assemblies.
typeProvider.AddAssembly(typeof(System.Object).Assembly);
typeProvider.AddAssembly(typeof(System.ComponentModel.Design.Serialization.CodeDomSerializer).Assembly);
typeProvider.AddAssembly(typeof(System.Workflow.ComponentModel.DependencyObject).Assembly);
typeProvider.AddAssembly(typeof(System.Workflow.Activities.SequentialWorkflowActivity).Assembly);
typeProvider.AddAssembly(typeof(System.Workflow.Runtime.WorkflowRuntime).Assembly);
// Just return the basic provider if not related to a project.
if (project == null)
return typeProvider;
LoadProjectReferences(project, typeProvider);
RefreshCodeCompileUnits(project, typeProvider);
Providers.Add(project, typeProvider);
MSBuildBasedProject p = project as MSBuildBasedProject;
p.ActiveConfigurationChanged += ActiveConfigurationChangedEventHandler;
return typeProvider;
}
private static void LoadProjectReferences(IProject project, TypeProvider typeProvider)
{
foreach (ProjectItem item in project.Items) {
Assembly assembly = LoadAssembly(item, AppDomain.CurrentDomain);
if (assembly != null) {
if (!typeProvider.ReferencedAssemblies.Contains(assembly))
typeProvider.AddAssembly(assembly);
}
}
}
private static void ProjectItemAddedEventHandler(object sender, ProjectItemEventArgs e)
{
if (e.Project == null) return;
if (!Providers.ContainsKey(e.Project)) return;
ReferenceProjectItem item = e.ProjectItem as ReferenceProjectItem;
if (item == null) return;
Assembly assembly = LoadAssembly(item);
if (assembly != null)
Providers[e.Project].AddAssembly(assembly);
}
private static void ProjectItemRemovedEventHandler(object sender, ProjectItemEventArgs e)
{
if (e.Project == null) return;
if (!Providers.ContainsKey(e.Project)) return;
ReferenceProjectItem item = e.ProjectItem as ReferenceProjectItem;
if (item == null) return;
Assembly assembly = LoadAssembly(item);
if (assembly != null)
Providers[e.Project].RemoveAssembly(assembly);
}
private static Assembly LoadAssembly(ProjectItem item)
{
return LoadAssembly(item, AppDomain.CurrentDomain);
}
private static Assembly LoadAssembly(ProjectItem item, AppDomain appDomain)
{
Assembly assembly = null;
if (item is ProjectReferenceProjectItem) {
ProjectReferenceProjectItem pitem = item as ProjectReferenceProjectItem;
// TODO: This is only a temporary solution so the assembly is not locked.
// Need to look at this in terms of using a separate domain.
if (File.Exists(pitem.ReferencedProject.OutputAssemblyFullPath))
assembly = appDomain.Load(File.ReadAllBytes(pitem.ReferencedProject.OutputAssemblyFullPath));
} else if (item is ReferenceProjectItem) {
ReflectionProjectContent pc = ParserService.GetProjectContentForReference((ReferenceProjectItem)item) as ReflectionProjectContent;
if (pc != null) {
AssemblyName name = new AssemblyName();
name.CodeBase = pc.AssemblyLocation;
assembly = appDomain.Load(name);
}
if (assembly == null) {
AssemblyName name = new AssemblyName();
name.CodeBase = item.FileName;
assembly = appDomain.Load(name);
}
}
return assembly;
}
private static void SolutionClosingEventHandler(object sender, SolutionEventArgs e)
{
// Remove unsed providers for closed projects.
foreach (IProject project in e.Solution.Projects) {
if (Providers.ContainsKey(project)) {
Providers[project].Dispose();
Providers.Remove(project);
}
}
}
private static void ActiveConfigurationChangedEventHandler(object sender, EventArgs e)
{
IProject project = sender as IProject;
if (!Providers.ContainsKey(project))
return;
// Reload the typeprovider.
ICSharpCode.Core.LoggingService.DebugFormatted("Reloading TypeProvider assemblies for project {0}", project.Name);
TypeProvider typeProvider = Providers[project];
foreach (Assembly asm in typeProvider.ReferencedAssemblies)
typeProvider.RemoveAssembly(asm);
LoadProjectReferences(project, typeProvider);
}
private static void RefreshCodeCompileUnits(IProject project, TypeProvider typeProvider)
{
ICSharpCode.Core.LoggingService.Debug("RefreshCodeCompileUnits");
// First use the workflow compiler to create one ccu for all the workflows
StringCollection files = new StringCollection();
foreach (ProjectItem item in project.GetItemsOfType(ItemType.Content)){
files.AddRange(GetRelatedFiles(project, item.FileName));
}
CodeCompileUnit ccu;
if (files.Count > 0) {
string[] s = new string[files.Count];
for (int i = 0; i < files.Count; i++)
s[i] = files[i];
ccu = ParseXoml(project, s);
if (ccu != null) {
typeProvider.AddCodeCompileUnit(ccu);
cp.UserCodeCompileUnits.Add(ccu);
}
}
// Now create one ccu for each source file.
foreach (ProjectItem item in project.GetItemsOfType(ItemType.Compile)){
ICSharpCode.Core.LoggingService.Debug(item.FileName);
if (item is FileProjectItem){
if (!Path.GetFileName(item.FileName).StartsWith("AssemblyInfo")){
ccu = Parse(item.FileName);
if (ccu != null) {
typeProvider.AddCodeCompileUnit(ccu);
cp.UserCodeCompileUnits.Add(ccu);
CodeCompileUnits.Add(item as FileProjectItem, ccu);
}
}
}
}
}
public static void UpdateCodeCompileUnit(FileProjectItem item)
{
TypeProvider typeProvider = Providers[item.Project];
if (typeProvider == null)
return;
// Remove the old ccu
if (CodeCompileUnits.ContainsKey(item))
typeProvider.RemoveCodeCompileUnit(CodeCompileUnits[item]);
// Build the new unit.
CodeCompileUnit codeCompileUnit = Parse(item.FileName);
// Now add the new unit.
if ( codeCompileUnit != null) {
typeProvider.AddCodeCompileUnit(codeCompileUnit);
if (CodeCompileUnits.ContainsKey(item))
CodeCompileUnits[item] = codeCompileUnit;
else
CodeCompileUnits.Add(item, codeCompileUnit);
}
}
static WorkflowCompilerParameters cp = new WorkflowCompilerParameters();
private static string[] GetRelatedFiles(IProject project, string fileName)
{
StringCollection files = new StringCollection();
files.Add(fileName);
foreach (ProjectItem item in project.Items){
if (item is FileProjectItem) {
FileProjectItem fItem = item as FileProjectItem;
if ((item.ItemType == ItemType.Compile) || (item.ItemType == ItemType.Content)) {
if (fItem.DependentUpon == Path.GetFileName(fileName)){
files.Add(item.FileName);
}
}
}
}
string[] s = new string[files.Count];
for (int i = 0; i < files.Count; i++)
s[i] = files[i];
return s;
}
private static CodeCompileUnit ParseXoml(IProject project, string[] fileNames)
{
ICSharpCode.Core.LoggingService.DebugFormatted("ParseXoml {0}", fileNames);
cp.GenerateCodeCompileUnitOnly = true;
cp.LanguageToUse = "CSharp";
WorkflowCompiler compiler = new WorkflowCompiler();
WorkflowCompilerResults results = compiler.Compile(cp, fileNames);
if (results.Errors.Count > 0) {
foreach (CompilerError e in results.Errors) {
ICSharpCode.Core.LoggingService.ErrorFormatted("{0}: {1}: {2}", e.Line, e.ErrorNumber, e.ErrorText);
}
return null;
}
return results.CompiledUnit;
}
private static CodeCompileUnit Parse(string fileName)
{
ICSharpCode.Core.LoggingService.DebugFormatted("Parse {0}", fileName);
string fileContent = ParserService.GetParseableFileContent(fileName);
ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(fileContent));
parser.Parse();
if (parser.Errors.Count > 0) {
return null;
}
CodeDomVisitor visitor = new CodeDomVisitor();
try {
visitor.VisitCompilationUnit(parser.CompilationUnit, null);
return visitor.codeCompileUnit;
} catch (Exception e) {
ICSharpCode.Core.LoggingService.Error("Parse", e);
return null;
}
}
}
}

137
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/TypeResolutionService.cs

@ -1,137 +0,0 @@ @@ -1,137 +0,0 @@
// <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 System.Reflection;
using System.ComponentModel.Design;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Dom;
using System.Workflow.ComponentModel.Compiler;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of TypeResolutionService.
/// </summary>
public class TypeResolutionService : ITypeResolutionService, IServiceProvider
{
IProject project;
#region Constructors
public TypeResolutionService(IProject project, IServiceProvider provider)
{
this.project = project;
this.provider = provider;
}
#endregion
#region IServiceProvider implementation
IServiceProvider provider;
public object GetService(Type serviceType)
{
return provider.GetService(serviceType);
}
#endregion
#region ITypeResolutionService implementation
public Assembly GetAssembly(AssemblyName name)
{
return GetAssembly(name, true);
}
public Assembly GetAssembly(AssemblyName name, bool throwOnError)
{
throw new NotImplementedException();
}
public Type GetType(string name)
{
return GetType(name, false);
}
public Type GetType(string name, bool throwOnError)
{
return GetType(name, throwOnError, false);
}
public Type GetType(string name, bool throwOnError, bool ignoreCase)
{
Type type = null;
// Ignoring versions numbers on types.
string[] splitName = name.Split(',');
string typeName = splitName[0].Replace('+','.');
// Check for the type ourselves in the projects referenced assemblies
// as the System.Workflow.ComponentModel.Compiler.TypeProvider does
// not seem find private types in referenced assemblies!
TypeProvider typeProvider = provider.GetService(typeof(ITypeProvider)) as TypeProvider;
if (typeProvider != null) {
foreach (Assembly asm in typeProvider.ReferencedAssemblies){
foreach (Module module in asm.GetModules()){
type = module.GetType(typeName, throwOnError, ignoreCase);
if (type != null)
return type;
}
}
}
if (type == null)
type = typeProvider.GetType(typeName, throwOnError);
// TODO: Need to check current project see if we can find it!
if (type == null) {
LoggingService.WarnFormatted("TypeResolutionService failed to find type {0}", typeName);
if (throwOnError)
throw new TypeLoadException(name + " not found by TypeResolutionService");
}
return type;
}
public void ReferenceAssembly(AssemblyName name)
{
// Check if assembly already exist in project, add it if not.
TypeProvider typeProvider = provider.GetService(typeof(ITypeProvider)) as TypeProvider;
if (typeProvider == null)
return;
foreach (Assembly asm in typeProvider.ReferencedAssemblies){
if (asm.FullName == name.FullName)
return;
}
LoggingService.DebugFormatted("TypeResolutionService.ReferenceAssembly {0}", name);
// TODO: Not in project so add the reference.
// IProject project = ProjectService.CurrentProject;
// if (project != null) {
// ReferenceProjectItem rpi = new ReferenceProjectItem(project, name.Name);
// rpi.Include = name.Name;
// ProjectService.AddProjectItem(project, rpi);
// project.Save();
// }
throw new NotImplementedException();
}
public string GetPathOfAssembly(AssemblyName name)
{
throw new NotImplementedException();
}
#endregion
}
}

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

@ -1,139 +0,0 @@ @@ -1,139 +0,0 @@
// <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.Design;
using System.Workflow.ComponentModel.Design;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// Description of MenuCommandService.
/// </summary>
public class WorkflowMenuCommandService : System.ComponentModel.Design.MenuCommandService
{
private const string DESIGNER_ACTION_GUID = "3bd4a275-fccd-49f0-b617-765ce63b4340";
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");
ContextMenuStrip contextMenu = null;
if (menuID == WorkflowMenuCommands.DesignerActionsMenu) {
Guid designerActionGuid = new Guid(DESIGNER_ACTION_GUID);
ICollection collection = this.GetCommandList(menuID.Guid);
foreach (System.ComponentModel.Design.MenuCommand menuCommand in collection) {
// Only interested in the errors.
if (menuCommand.CommandID.ID == 8342) {
if (contextMenu == null)
contextMenu = new ContextMenuStrip();
ToolStripMenuItem menuItem = new ToolStripMenuItem(menuCommand.Properties["Text"].ToString());
menuItem.Click += new EventHandler(DesignerActionsMenuClickHandler);
menuItem.Tag = menuCommand.Properties[designerActionGuid];
contextMenu.Items.Add(menuItem);
}
}
} else if (menuID == WorkflowMenuCommands.SelectionMenu) {
foreach (DesignerVerb verb in Verbs) {
if (verb.Visible) {
if (contextMenu == null)
contextMenu = new ContextMenuStrip();
ToolStripMenuItem menuItem = new ToolStripMenuItem(verb.Text);
menuItem.Click += new EventHandler(SelectionMenuClickHandler);
menuItem.Enabled = verb.Enabled;
menuItem.Checked = verb.Checked;
menuItem.Tag = verb;
contextMenu.Items.Add(menuItem);
}
}
}
if (contextMenu != null) {
//WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
//contextMenu.Show(workflowView , workflowView.PointToClient(new Point(x, y)));
contextMenu.Show(x, y);
//contextMenu.Capture = true;
}
}
private void SelectionMenuClickHandler(object sender, EventArgs e)
{
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
if (menuItem != null){
System.ComponentModel.Design.MenuCommand command = menuItem.Tag as System.ComponentModel.Design.MenuCommand;
if (command != null)
command.Invoke();
}
}
void DesignerActionsMenuClickHandler(object sender, EventArgs e)
{
DesignerAction designerAction = ((ToolStripMenuItem)sender).Tag as DesignerAction;
if (designerAction == null)
return;
designerAction.Invoke(); // Will change the selectedObject in the designer
if (!string.IsNullOrEmpty( designerAction.PropertyName)) {
// No easy way I can find to search for a specific griditem so
// find the root item in the grid, and search for items for the property.
GridItem item = PropertyPad.Grid.SelectedGridItem;
while (item.Parent != null) {
item = item.Parent;
}
GridItem item2 = FindGridItem(item, designerAction.PropertyName);
if (item2 != null) {
PropertyPad.Grid.SelectedGridItem = item2;
PropertyPad.Grid.Focus();
}
}
}
static GridItem FindGridItem(GridItem gridItem, string name)
{
foreach (GridItem item in gridItem.GridItems){
if (item.Label == name)
return item;
GridItem item2 = FindGridItem(item, name);
if (item2 != null)
return item2;
}
return null;
}
}
}

388
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs

@ -1,388 +0,0 @@ @@ -1,388 +0,0 @@
// <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 System.Drawing;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Design;
using System.ComponentModel.Design;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Widgets.SideBar;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Dom;
#endregion
namespace WorkflowDesigner
{
/// <summary>
/// This class manages the display of the SideTabs in the tools pad.
/// There a three types of SideTab:
/// Standard - contains the standard workflow components from System.Workflow.Activities.
/// Project - contains the activities in the current project.
/// References - One sidetab for each project assembly reference that contains activities.
/// </summary>
public sealed class WorkflowSideTabService
{
private static IViewContent activeViewContent;
private static IProject activeProject;
private static SideTab standardSideTab;
private static int viewCount;
private static Dictionary<IProject, Dictionary<ReferenceProjectItem, SideTab>> projects;
private static bool initialised;
#region Properties
private static IProject ActiveProject {
get { return activeProject; }
set {
if (activeProject == value)
return;
if (value == null)
RemoveAllSideTabs();
else {
if (activeProject != null)
RemoveProjectSideTabs(activeProject);
ShowSideTabsForProject(value);
}
activeProject = value;
}
}
private static Dictionary<IProject, Dictionary<ReferenceProjectItem, SideTab>> Projects {
get {
if (projects == null)
projects = new Dictionary<IProject, Dictionary<ReferenceProjectItem, SideTab>> ();
return projects;
}
}
private static int ViewCount {
get { return viewCount; }
set {
viewCount = value;
if (viewCount == 0) {
standardSideTab = null;
ActiveProject = null;
}
}
}
static SharpDevelopSideBar workflowSideBar;
public static SharpDevelopSideBar WorkflowSideBar {
get {
Debug.Assert(WorkbenchSingleton.InvokeRequired == false);
if (workflowSideBar == null) {
workflowSideBar = new SharpDevelopSideBar();
workflowSideBar.Tabs.Add(standardSideTab);
WorkflowSideBar.ActiveTab = standardSideTab;
}
return workflowSideBar;
}
}
#endregion
private static void Initialise()
{
// Make sure the side bar has actually been created!
ProjectService.ProjectItemRemoved += ProjectItemRemovedEventHandler;
ProjectService.ProjectItemAdded += ProjectItemAddedEventHandler;
ProjectService.SolutionClosing += SolutionClosingEventHandler;
initialised = true;
}
public static void AddViewContent(IViewContent viewContent)
{
if (viewContent == null)
throw new ArgumentNullException("viewContent");
if (!initialised)
Initialise();
// Make sure the standard workflow sidebar exists
if (standardSideTab == null) {
LoggingService.Debug("Creating standard workflow sidetab");
standardSideTab = CreateSideTabFromAssembly("Workflow", new AssemblyName("System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
LoadSideTabItemsFromAssembly(new AssemblyName("System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"), standardSideTab);
}
// Attach the handlers.
//viewContent.Disposed += ViewContentDisposedEventHandler;
ViewCount++;
}
#region ProjectService event handlers
private static void ProjectItemAddedEventHandler(object sender, ProjectItemEventArgs e)
{
if (e.Project == null) return;
if (!Projects.ContainsKey(e.Project)) return;
ReferenceProjectItem item = e.ProjectItem as ReferenceProjectItem;
if (item == null) return;
Dictionary<ReferenceProjectItem, SideTab> references = Projects[e.Project];
if (item is ProjectReferenceProjectItem) {
references.Add(item, CreateSideTabForProjectItem(item));
return;
} else if (item is ReferenceProjectItem) {
if (!e.ProjectItem.Include.StartsWith("System")){
references.Add(item, CreateSideTabForProjectItem(item));
}
} else {
return;
}
if (ActiveProject == e.Project)
{
if (!WorkflowSideBar.Tabs.Contains(references[item])) {
WorkflowSideBar.Tabs.Add(references[item]);
}
}
}
private static void ProjectItemRemovedEventHandler(object sender, ProjectItemEventArgs e)
{
if (e.Project == null) return;
if (!Projects.ContainsKey(e.Project)) return;
ReferenceProjectItem item = e.ProjectItem as ReferenceProjectItem;
if (item == null) return;
Dictionary<ReferenceProjectItem, SideTab> references = Projects[e.Project];
if (references.ContainsKey(item)){
if (WorkflowSideBar.Tabs.Contains(references[item])) {
WorkflowSideBar.Tabs.Remove(references[item]);
}
references.Remove(item);
}
}
private static void SolutionClosingEventHandler(object sender, SolutionEventArgs e)
{
foreach (IProject project in e.Solution.Projects) {
if (Projects.ContainsKey(project)) {
RemoveProjectSideTabs(project);
Projects.Remove(project);
}
}
}
#endregion
#region IViewContent event handlers
private static void ViewContentDisposedEventHandler(object sender, EventArgs args)
{
LoggingService.DebugFormatted("ViewContentDisposedEventHandler {0}", sender);
ViewCount--;
}
private static void ViewContentActivatedEventHandler(object sender, EventArgs args)
{
LoggingService.DebugFormatted("ViewActivated {0}", sender);
if (activeViewContent == sender)
return;
// Make sure the standard workflow sidebar is on screen.
if (!WorkflowSideBar.Tabs.Contains(standardSideTab)) {
WorkflowSideBar.Tabs.Add(standardSideTab);
if (WorkflowSideBar.Tabs.Count == 1) {
WorkflowSideBar.ActiveTab = WorkflowSideBar.Tabs[0];
}
}
LoggingService.DebugFormatted("ViewActivated {0}", sender);
activeViewContent = sender as IViewContent;
ActiveProject = ProjectService.OpenSolution.FindProjectContainingFile(activeViewContent.PrimaryFileName);
WorkflowSideBar.Refresh();
}
#endregion;
private static void ShowSideTabsForProject(IProject project)
{
if (!Projects.ContainsKey(project)){
Dictionary<ReferenceProjectItem, SideTab> tabs = new Dictionary<ReferenceProjectItem, SideTab>();
tabs.Add(new ReferenceProjectItem(project), CreateCustomComponentsSideTab(project));
LoadProjectReferenceSideTabs(project, tabs);
Projects.Add(project, tabs);
}
Dictionary<ReferenceProjectItem, SideTab> references = Projects[project];
foreach (SideTab sideTab in references.Values) {
if (sideTab.Items.Count > 1) {
if (!WorkflowSideBar.Tabs.Contains(sideTab)) {
WorkflowSideBar.Tabs.Add(sideTab);
}
}
}
}
private static SideTab CreateCustomComponentsSideTab(IProject project)
{
AssemblyName assemblyName = new AssemblyName();
assemblyName.CodeBase = project.OutputAssemblyFullPath;
SideTab sideTab = new SideTab("Project components");
sideTab.CanSaved = false;
AddPointerToSideTab(sideTab);
// TODO: Need to load the sidetab with activities from the current project.
// Cannot use LoadSideTabFromAssembly as it will only
// load public components from the assembly.
IProjectContent projectContent = ParserService.GetProjectContent(project);
foreach (IProjectContent pc in projectContent.ReferencedContents){
//LoggingService.DebugFormatted(pc.ToString());
}
SortSideTabItems(sideTab);
return sideTab;
}
private static void RemoveAllSideTabs()
{
foreach (IProject project in Projects.Keys) {
RemoveProjectSideTabs(project);
}
}
private static void RemoveProjectSideTabs(IProject project)
{
if (!Projects.ContainsKey(project))
return;
Dictionary<ReferenceProjectItem, SideTab> references = Projects[project];
foreach (SideTab sideTab in references.Values) {
if (WorkflowSideBar.Tabs.Contains(sideTab)) {
WorkflowSideBar.Tabs.Remove(sideTab);
}
}
}
private static void LoadProjectReferenceSideTabs(IProject project, Dictionary<ReferenceProjectItem, SideTab> tabs)
{
foreach (ProjectItem item in project.Items) {
if (item is ProjectReferenceProjectItem) {
if (File.Exists(((ProjectReferenceProjectItem)item).ReferencedProject.OutputAssemblyFullPath)){
tabs.Add(item as ReferenceProjectItem, CreateSideTabForProjectItem(item));
}
} else if (item is ReferenceProjectItem) {
if (!item.Include.StartsWith("System")){
tabs.Add(item as ReferenceProjectItem, CreateSideTabForProjectItem(item));
}
}
}
}
private static SideTab CreateSideTabForProjectItem(ProjectItem item)
{
AssemblyName assemblyName = null;
if (item is ProjectReferenceProjectItem) {
ProjectReferenceProjectItem pitem = item as ProjectReferenceProjectItem;
assemblyName = new AssemblyName();
assemblyName.CodeBase = pitem.ReferencedProject.OutputAssemblyFullPath;
return CreateSideTabFromAssembly(pitem.ReferencedProject.Name, assemblyName);
} else if (item is ReferenceProjectItem) {
assemblyName = new AssemblyName();
assemblyName.CodeBase = item.FileName;
return CreateSideTabFromAssembly(Path.GetFileNameWithoutExtension(item.FileName) + " components",assemblyName);
}
return null;
}
private static SideTab CreateSideTabFromAssembly(AssemblyName assemblyName)
{
return CreateSideTabFromAssembly(assemblyName.FullName + " components", assemblyName);
}
private static SideTab CreateSideTabFromAssembly(string name, AssemblyName assemblyName)
{
SideTab sideTab = new SideTab(name);
sideTab.CanSaved = false;
AddPointerToSideTab(sideTab);
LoadSideTabItemsFromAssembly(assemblyName, sideTab);
SortSideTabItems(sideTab);
return sideTab;
}
private static void AddPointerToSideTab(SideTab sideTab)
{
// 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);
}
private static void LoadSideTabItemsFromAssembly(AssemblyName assemblyName, SideTab sideTab)
{
ICollection toolboxItems = System.Drawing.Design.ToolboxService.GetToolboxItems(assemblyName);
foreach (ToolboxItem tbi in toolboxItems)
{
//TODO: Add further checking to see if this component can actually be put on the sidetab.
SharpDevelopSideTabItem sti = new SharpDevelopSideTabItem(tbi.DisplayName);
sti.CanBeDeleted = false;
sti.CanBeRenamed = false;
sti.Tag = tbi;
sti.Icon = tbi.Bitmap;
sideTab.Items.Add(sti);
}
System.Drawing.Design.ToolboxService.UnloadToolboxItems();
}
private static void SortSideTabItems(SideTab sideTab)
{
SortedDictionary<string, SideTabItem> list = new SortedDictionary<string, SideTabItem>();
SideTabItem pointer = sideTab.Items[0];
sideTab.Items.RemoveAt(0);
foreach (SideTabItem item in sideTab.Items)
list.Add(item.Name, item);
sideTab.Items.Clear();
sideTab.Items.Add(pointer);
foreach (SideTabItem item in list.Values)
sideTab.Items.Add(item);
}
}
}

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

@ -1,204 +0,0 @@ @@ -1,204 +0,0 @@
// <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.Collections.Generic;
using System.Drawing.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Workflow.Activities;
using ICSharpCode.Core;
using System.Reflection;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Widgets.SideBar;
#endregion
namespace WorkflowDesigner
{
// TODO - Replace this a class based on System.Drawing.Design.ToolboxService
public class WorkflowToolboxService : IToolboxService, IServiceProvider
{
private string category = "Workflow";
public WorkflowToolboxService(IServiceProvider provider)
{
this.provider = provider;
}
#region IServiceProvider implementation
IServiceProvider provider;
public object GetService(Type serviceType)
{
return provider.GetService(serviceType);
}
#endregion
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();
}
}
}

38
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/Activity.xft

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins" version="1.0">
<Config
name = "Activity"
icon = "Icons.32x32.XMLFileIcon"
category = "Workflow"
subcategory = "C#"
defaultname = "Activity${Number}.xoml"
language = "C#"/>
<Description>Custom Activity</Description>
<Files>
<File name="${Path}/${FileNameWithoutExtension}.xoml.cs" DependentUpon="${FileName}" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
partial class ${ClassName} : SequenceActivity
{
}
}]]></File>
<File name="${FullName}" language="Xoml" buildAction="Content" SubType="Component"><![CDATA[<SequenceActivity
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" />
]]></File>
</Files>
<AdditionalOptions/>
</Template>

38
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/CSharp/CodeSeparationSequentialWorkflow.xft

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins" version="1.0">
<Config
name = "Sequential Workflow (Code Separation)"
icon = "Icons.32x32.XMLFileIcon"
category = "Workflow"
subcategory = "C#"
defaultname = "Workflow${Number}.xoml"
language = "C#"/>
<Description>Sequential Workflow (Code Separation)</Description>
<Files>
<File name="${Path}/${FileNameWithoutExtension}.xoml.cs" DependentUpon="${FileName}" language="C#"><![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
public partial class ${ClassName} : SequentialWorkflowActivity
{
}
}]]></File>
<File name="${FullName}" language="Xoml" buildAction="Content" SubType="Component"><![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" />
]]></File>
</Files>
<AdditionalOptions/>
</Template>

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

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
<?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

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
<?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>

27
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Files/Sequence.xft

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
<?xml version="1.0"?>
<Template author="Daniel Grunwald" version="1.0">
<Config
name = "Sequential Workflow"
icon = "Icons.32x32.XMLFileIcon"
category = "Workflow"
defaultname = "Sequence${Number}.xaml"
language = "XML"/>
<Description></Description>
<Files>
<File name="${FullName}" language="XML"><![CDATA[<?xml version="1.0"?>
<p:Activity x:Class="${StandardNamespace}.${ClassName}"
xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<p:Sequence>
</p:Sequence>
</p:Activity>]]>
</File>
</Files>
<AdditionalOptions/>
</Template>

103
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/ActivityLibrary.xpt

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<!-- Template Header -->
<TemplateConfiguration>
<Name>Workflow Activity Library</Name>
<Category>Workflow</Category>
<Subcategory>C#</Subcategory>
<Icon>C#.Project.EmptyProject</Icon>
<Description>A project for creating a reuseable library ofr custom activities for use by other projects</Description>
</TemplateConfiguration>
<Actions>
<Open filename="Activity1.xoml" />
</Actions>
<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>
<PropertyGroup>
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup escapeValue="false">
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<Files>
<!-- Assembly -->
<File name="Configuration\AssemblyInfo.cs">
<![CDATA[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("${ProjectName}")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("${ProjectName}")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.0.0")]
]]>
</File>
<!-- Workflow Code -->
<File name="Activity1.xoml.cs" DependentUpon="Activity1.xoml" language="C#">
<![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
partial class Activity1 : SequenceActivity
{
}
}]]>
</File>
<!-- Workflow -->
<File name="Activity1.xoml" language="Xoml" buildAction="Content" SubType="Component">
<![CDATA[<SequenceActivity
x:Class="${StandardNamespace}.Activity1"
x:Name="Activity1"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow" >
</SequenceActivity>
]]>
</File>
</Files>
</Project>
</Template>

136
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Templates/Projects/CSharp/ConsoleProject.xpt

@ -1,136 +0,0 @@ @@ -1,136 +0,0 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<!-- Template Header -->
<TemplateConfiguration>
<Name>Sequential workflow console project</Name>
<Category>Workflow</Category>
<Subcategory>C#</Subcategory>
<Icon>C#.Project.EmptyProject</Icon>
<Description>A project for creating a sequential workflow console application</Description>
</TemplateConfiguration>
<Actions>
<Open filename="Workflow1.xoml" />
</Actions>
<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>
<PropertyGroup escapeValue="false">
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<Files>
<!-- Main -->
<File name="Main.cs">
<![CDATA[${StandardHeader.C#}
using System;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace ${StandardNamespace}
{
class MainClass
{
public static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {
AutoResetEvent waitEvent = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {
waitEvent.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) {
Console.WriteLine(e.Exception.Message);
waitEvent.Set();
};
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(${StandardNamespace}.Workflow1));
workflowInstance.Start();
waitEvent.WaitOne();
}
}
}
}]]>
</File>
<!-- Assembly -->
<File name="Configuration\AssemblyInfo.cs">
<![CDATA[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("${ProjectName}")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("${ProjectName}")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.0.0")]
]]>
</File>
<!-- Workflow Code -->
<File name="Workflow1.xoml.cs" DependentUpon="Workflow1.xoml" language="C#">
<![CDATA[${StandardHeader.C#}
using System;
using System.Workflow.Activities;
namespace ${StandardNamespace}
{
public partial class Workflow1 : SequentialWorkflowActivity
{
}
}]]>
</File>
<!-- Workflow -->
<File name="Workflow1.xoml" language="Xoml" buildAction="Content" SubType="Component">
<![CDATA[<SequentialWorkflowActivity
x:Class="${StandardNamespace}.Workflow1"
x:Name="Workflow1"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow" >
</SequentialWorkflowActivity>
]]>
</File>
</Files>
</Project>
</Template>

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

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
<?xml version="1.0"?>
<Template author="Russell Wilkins">
<!-- Template Header -->
<TemplateConfiguration>
<Name>Empty workflow project</Name>
<Category>Workflow</Category>
<Subcategory>C#</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>
<PropertyGroup escapeValue="false">
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<Files>
<!-- Assembly -->
<File name="Configuration\AssemblyInfo.cs">
<![CDATA[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("${ProjectName}")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("${ProjectName}")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.0.0")]
]]>
</File>
</Files>
</Project>
</Template>

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

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
<AddIn name = "Workflow Foundation Designer"
author = "Russell Wilkins"
url = ""
description = "Windows Workflow Foundation Designer">
<AddIn name = "Workflow Designer"
author = "Daniel Grunwald"
description = "Windows Workflow Foundation 4.0 Designer">
<Runtime>
<Import assembly = "WorkflowDesigner.dll"/>
@ -10,36 +9,17 @@ @@ -10,36 +9,17 @@
<Manifest>
<Identity name="WorkflowDesigner"/>
</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?$" />
class = "ICSharpCode.WorkflowDesigner.WorkflowDisplayBinding"
fileNamePattern = "\.xaml?$" />
</Path>
<!--Template path -->
<Path name = "/SharpDevelop/BackendBindings/Templates">
<!--<Path name = "/SharpDevelop/BackendBindings/Templates">
<Directory id = "WorkflowDesigner" path = "./Templates" />
</Path>
</Path>-->
</AddIn>

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

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>WorkflowDesigner</RootNamespace>
<RootNamespace>ICSharpCode.WorkflowDesigner</RootNamespace>
<AssemblyName>WorkflowDesigner</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
@ -39,9 +39,22 @@ @@ -39,9 +39,22 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System">
<Private>False</Private>
</Reference>
<Reference Include="System.Activities" />
<Reference Include="System.Activities.Core.Design" />
<Reference Include="System.Activities.Design" />
<Reference Include="System.Activities.Design.Base" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data">
<Private>False</Private>
</Reference>
@ -49,40 +62,20 @@ @@ -49,40 +62,20 @@
<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.Workflow.Runtime" />
<Reference Include="System.Xml">
<Private>False</Private>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Templates\Files\CSharp\Activity.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Files\CSharp\CodeSeparationSequentialWorkflow.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Files\CSharp\CodeSequentialWorkflow.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\CSharp\ActivityLibrary.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\CSharp\ConsoleProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\CSharp\EmptyProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="WorkflowDesignerViewContent.cs" />
<Compile Include="WorkflowDisplayBinding.cs" />
<None Include="Templates\Files\Sequence.xft" />
<None Include="WorkflowDesigner.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -90,39 +83,8 @@ @@ -90,39 +83,8 @@
<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\BasicWorkflowDesignerLoader.cs" />
<Compile Include="Src\Loaders\CodeDesignerLoader.cs" />
<Compile Include="Src\Loaders\WorkflowDesignerLoadException.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\EventBindingService\CSharpWorkflowDesignerEventBindingService.cs" />
<Compile Include="Src\Services\EventBindingService\EventPropertyDescriptor.cs" />
<Compile Include="Src\Services\EventBindingService\IWorkflowDesignerEventBindingService.cs" />
<Compile Include="Src\Services\EventBindingService\WorkflowDesignerEventBindingService.cs" />
<Compile Include="Src\Services\MemberCreationService.cs" />
<Compile Include="Src\Services\PropertyValueUIService.cs" />
<Compile Include="Src\Services\TypeProviderService.cs" />
<Compile Include="Src\Services\TypeResolutionService.cs" />
<Compile Include="Src\Services\WorkflowSideTabService.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>
@ -143,27 +105,8 @@ @@ -143,27 +105,8 @@
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj">
<Project>{80318B5F-A25D-45AB-8A95-EF31D2370A4C}</Project>
<Name>ICSharpCode.SharpDevelop.Sda</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>
<Folder Include="Src\Gui" />
<Folder Include="Src\Loaders" />
<Folder Include="Src\Commands" />
<Folder Include="Src\PrimaryView" />
<Folder Include="Src\Services" />
<Folder Include="Src\Services\EventBindingService" />
<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" />

114
src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDesignerViewContent.cs

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
/*
* Created by SharpDevelop.
* User: Daniel
* Date: 15.07.2009
* Time: 21:26
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Activities.Core.Design;
using System.Activities.Design;
using System.Activities.Design.Metadata;
using System.Activities.Design.Validation;
using System.Activities.Statements;
using System.ComponentModel;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WorkflowDesigner
{
/// <summary>
/// ViewContent for the workflow designer.
/// </summary>
public class WorkflowDesignerViewContent : AbstractViewContent, IHasPropertyContainer, IToolsHost
{
System.Activities.Design.WorkflowDesigner designer;
public WorkflowDesignerViewContent(OpenedFile file) : base(file)
{
this.PropertyContainer = new PropertyContainer();
this.TabPageText = "Workflow Designer";
}
public PropertyContainer PropertyContainer { get; private set; }
void InitializeDesigner()
{
if (designer == null) {
RegisterMetadata();
designer = new System.Activities.Design.WorkflowDesigner();
this.PropertyContainer.PropertyGridReplacementContent = designer.PropertyInspectorView;
}
}
public override object Control {
get {
InitializeDesigner();
return designer.View;
}
}
ToolboxControl toolbox;
public object ToolsContent {
get {
if (toolbox == null)
toolbox = CreateToolboxControl();
return toolbox;
}
}
public override void Load(OpenedFile file, Stream stream)
{
if (file == PrimaryFile) {
InitializeDesigner();
using (StreamReader r = new StreamReader(stream)) {
designer.Context.Items.SetValue(new WorkflowFileItem() { LoadedFile = file.FileName });
designer.Text = r.ReadToEnd();
designer.Load();
}
}
}
public override void Save(OpenedFile file, Stream stream)
{
if (file == PrimaryFile && designer != null) {
designer.Flush();
using (StreamWriter w = new StreamWriter(stream)) {
w.Write(designer.Text);
}
var validationService = designer.Context.Services.GetService<ValidationService>();
if (validationService != null)
validationService.ValidateWorkflow();
}
}
void RegisterMetadata()
{
AttributeTableBuilder builder = new AttributeTableBuilder();
// Register Designers.
builder.AddCustomAttributes(typeof(Sequence),
new DesignerAttribute(typeof(SequenceDesigner)));
// Apply the metadata
MetadataStore.AddAttributeTable(builder.CreateTable());
}
static ToolboxControl CreateToolboxControl()
{
ToolboxControl ctrl = new ToolboxControl();
ToolboxCategoryItemsCollection category = new ToolboxCategoryItemsCollection("Workflow");
//Adding the toolboxItems to the category.
category.Tools.Add(new ToolboxItemWrapper("System.Activities.Statements.Sequence",
"System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
null, "Sequence"));
ctrl.Categories.Add(category);
return ctrl;
}
}
}

58
src/AddIns/DisplayBindings/WorkflowDesigner/Project/WorkflowDisplayBinding.cs

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
/*
* Created by SharpDevelop.
* User: Daniel
* Date: 15.07.2009
* Time: 21:26
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using ICSharpCode.Core;
using System;
using System.Linq;
using System.Xml;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WorkflowDesigner
{
/// <summary>
/// Display binding that attaches the workflow designer to .xaml files.
/// </summary>
public class WorkflowDisplayBinding : ISecondaryDisplayBinding
{
public bool CanAttachTo(IViewContent content)
{
ITextEditorProvider p = content as ITextEditorProvider;
if (p != null) {
try {
using (XmlTextReader r = new XmlTextReader(p.TextEditor.Document.CreateReader())) {
r.XmlResolver = null;
// find the opening of the root element:
while (r.Read() && r.NodeType != XmlNodeType.Element);
// attach if this is a workflow node
return r.NamespaceURI == "http://schemas.microsoft.com/netfx/2009/xaml/activities";
}
} catch (XmlException e) {
LoggingService.Debug("WorkflowDisplayBinding got exception: " + e.Message);
return false;
}
} else {
return false;
}
}
/// <summary>
/// When you return true for this property, the CreateSecondaryViewContent method
/// is called again after the LoadSolutionProjects thread has finished.
/// </summary>
public bool ReattachWhenParserServiceIsReady {
get { return false; }
}
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{
return new IViewContent[] { new WorkflowDesignerViewContent(viewContent.PrimaryFile) };
}
}
}

4
src/Setup/Files.wxs

@ -1361,7 +1361,7 @@ @@ -1361,7 +1361,7 @@
<Component Guid="69BD4F05-0ADD-48C9-AD46-72D9B0C4A569" Id="WorkflowDesignerDll" DiskId="1">
<File Source="..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\WorkflowDesigner.dll" Id="WorkflowDesigner.dll" Name="WorkflowDesigner.dll" />
</Component>
<Directory Id="WorkflowDesignerTemplatesFolder" Name="Templates">
<!-- <Directory Id="WorkflowDesignerTemplatesFolder" Name="Templates">
<Directory Id="WorkflowDesignerFilesFolder" Name="Files">
<Component Guid="DA3146B7-E769-4240-9C6E-74956A395782" Id="NoCodeSequentialWorkflowXft" DiskId="1">
<File Source="..\..\AddIns\AddIns\DisplayBindings\WorkflowDesigner\Templates\Files\NoCodeSequentialWorkflow.xft" Id="NoCodeSequentialWorkflow.xft" Name="NoCodeSequentialWorkflow.xft" />
@ -1383,7 +1383,7 @@ @@ -1383,7 +1383,7 @@
</Component>
</Directory>
</Directory>
</Directory>
</Directory> -->
</Directory>
<!--
<Directory Id="WpfDesign" Name="WpfDesign">

3
src/Setup/Setup.wxs

@ -345,9 +345,6 @@ @@ -345,9 +345,6 @@
<ComponentRef Id="WorkflowDesignerAddin"/>
<ComponentRef Id="WorkflowDesignerDll"/>
<ComponentRef Id="WorkflowDesignerCSharpFilesTemplates"/>
<ComponentRef Id="WorkflowDesignerCSharpProjectTemplates"/>
<ComponentRef Id="NoCodeSequentialWorkflowXft"/>
<ComponentRef Id="XmlEditorFiles"/>
<ComponentRef Id="AddInManagerFiles"/>

Loading…
Cancel
Save