![]() ![]() | ||||
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename
History | Required classes are the DesignSurface, WorkflowView and a custom WorkflowDesignerLoader.
Imports System
Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.Serialization
Imports System.Drawing.Imaging
Imports System.Workflow.Activities
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Design
Module Module1
Sub Main()
Dim workflow As New SequentialWorkflowActivity
workflow.Activities.Add(New DelayActivity())
Dim loader As New WorkflowLoader(workflow)
Dim surface As New DesignSurface
surface.BeginLoad(loader)
Dim view As New WorkflowView(CType(surface, IServiceProvider))
view.SaveWorkflowImage("workflow.png", ImageFormat.Png)
Process.Start("workflow.png")
End Sub
End Module
Public Class WorkflowLoader
Inherits WorkflowDesignerLoader
Private _workflowDefinition As Activity
Sub New(ByVal workflowDefinition As Activity)
_workflowDefinition = workflowDefinition
End Sub
Protected Overrides Sub PerformLoad(ByVal serializationManager As IDesignerSerializationManager)
MyBase.PerformLoad(serializationManager)
Dim designerHost As IDesignerHost = Me.GetService(GetType(IDesignerHost))
Dim allActivities As List(Of Activity) = WorkflowUtils.GetAllActivities(_workflowDefinition)
For Each item As Activity In allActivities
designerHost.Container.Add(item, item.QualifiedName)
Next
End Sub
Public Overrides ReadOnly Property FileName() As String
Get
Return ""
End Get
End Property
Public Overrides Function GetFileReader(ByVal filePath As String) As System.IO.TextReader
Throw New NotSupportedException()
End Function
Public Overrides Function GetFileWriter(ByVal filePath As String) As System.IO.TextWriter
Throw New NotSupportedException()
End Function
End Class
| Wiki Usage
This wiki site is supposed to be a shared resource. As a shared resource everyone is encouraged to add new content or modify existing content! Enjoy the WF wiki. Recent Topics
| ||