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.