Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Windows Workflow Designer Hosting - Part 3 (Fixing some stuff from Part 2)

Blogs

Mike Taulty's Blog

Elsewhere

Back in part 2 I'd basically managed to get something from the Workflow Designer on the screen and I'd got a property grid but if you'd run the code as it stood so far you'd know that if you tried to drag and drop things around in the designer or even if you'd simply tried to switch between the different tabs (Workflow/Cancellation/Faults/etc) then that didn't work very well.

So far, I've been just creating the "workflow definition" that's supposed to be on the screen somewhat arbitrarily and adding it into the designer through a somewhat odd mechanism and (by using this technique) I can see that the Designer has been crying out for many things including a DesignerLoader and so I can add one of those things in by deriving something from the WorkflowDesignerLoader base class and adding that as a service.

In deriving from WorkflowDesignerLoader, I have to implement three things;

  class MyWorkflowDesignerLoader : WorkflowDesignerLoader
  {
    public override string FileName
    {
      get 
      { 
        throw new Exception(
          "The method or operation is not implemented."); 
      }
    }
    public override System.IO.TextReader GetFileReader(
      string filePath)
    {
      throw new Exception(
        "The method or operation is not implemented.");
    }
    public override System.IO.TextWriter GetFileWriter(
      string filePath)
    {
      throw new Exception(
        "The method or operation is not implemented.");
    }
  }

In so far as I can work out (i.e. from Reflector), the FileName property is used by the designer to save layout information. If you don't have one of these it'll generate a file with a .layout extension on it. It seems that GetFileReader and GetFileWriter are used by rules/layout persistence so, again, I'm ignoring those for the time being.

Instead, I override the PerformLoad method and essentially move the code that I had previously for trying to load up a Workflow definition from a XAML file into that method.

There's still a lot of things that don't work (saving, menus, code generation, lots and lots) and my implementation's a bit sketchy but I'm understanding it a bit better piece by piece - having the DesignerLoader rather than using my hacky method makes the whole thing work better. I knew that my method was doomed all along as the article that I originally talked about uses a DesignerLoader but I figure that I'll learn more if I plug the pieces together slowly and by hand.

The code for as far as I'm up to right now is here - Designer Part 4.


Posted Tue, Aug 22 2006 7:21 AM by mtaulty

Comments

Mike Taulty's Blog wrote Windows Workflow Designer Hosting - Part 4, Trying to make the Toolbox work
on Thu, Aug 24 2006 6:31 AM
Following on from this post. I struggled a lot with trying to get the toolbox to work. In the end, the...
Mike Taulty's Blog wrote Workflow Designer Hosting - Summing Up (for now)
on Wed, Sep 6 2006 9:53 AM
I've been playing with the Workflow designer hosting for a little while, trying to get my head around...
Wilm’s FuzzyLogic » Blog Archive » New Windows Workflow Foundation Links wrote Wilm’s FuzzyLogic » Blog Archive » New Windows Workflow Foundation Links
on Wed, Feb 14 2007 4:49 AM