The Problem SolverWIndows Workflow Foundation
HomeShow ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename



6-1-2007 20:25:256-1-2007 20:16:076-1-2007 20:15:02

List all versions

Save Workflow Image Example

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
        Dim view As New WorkflowView(CType(surface, IServiceProvider))
        view.SaveWorkflowImage("workflow.png", ImageFormat.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)

        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)
    End Sub

    Public Overrides ReadOnly Property FileName() As String
            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