The Problem SolverWIndows Workflow Foundation
HomeHide ChangesEditPrintRecent ChangesSubscriptionsLost and FoundFind ReferencesRename

Search

History

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

List all versions

Save Workflow Image Example
.
Summary

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 loader As New WorkflowLoader
        loader.WorkflowDefinition = 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
    Public 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)
        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