locked
Custom composite activity designer RRS feed

  • Question

  • I've created two custom activities (both derived from CodeActivity).
    The first one "GetInput" defines an outargument. This outargument can be configured at design time through a custom made designer (GetInputDesigner) (created using the "activity designer" template).
    The second activity "ShowInput" defines an inargument and shows the received argument using a messagebox.

    We have rehosted the Flowchart designer in our test project.
    Normally in a workflow I would created a sequence which contains both activities and use a variable to pass the output of the first activity to the second activity.

    Now my idea is to have a composite activity "GetAndShowInput" that defines a sequence including both activities and the variable that is already correctly assigned. This would simplify the use of the both activites. When I drag & drop this "GetAndShowInput" activity to our workflow, I only see the standard symboly "WF" for custom activities. But what I want to see is either the complete sequence including both activites (just like when you drop an "ReceiveAndSendReply" activity on the workflow) or another custom designer "GetAndShowInputDesigner" that would me allow to configure the outargument of the first activity.

    Is it possible to achieve one of the described options or do I have to go another direction?
    Tuesday, July 7, 2009 11:59 AM

Answers

  • fox p,

    There is an internal interface in beta1 (IActivityTemplate) or something similar to that which will be made public in beta2 to address this scenario.

    Thanks,

    matt
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Thursday, July 9, 2009 8:55 PM

All replies

  • fox p,

    There is an internal interface in beta1 (IActivityTemplate) or something similar to that which will be made public in beta2 to address this scenario.

    Thanks,

    matt
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Thursday, July 9, 2009 8:55 PM
  • Could you please elaborate more fully on what is meant by IActivityTemplate?  I am looking for a code sample or some reference as I have exactly the same type of issue.
    Matthew Christopher
    Monday, October 19, 2009 3:39 PM
  • Were you ever able to solve this issue?

    Matthew Christopher
    Monday, October 19, 2009 3:43 PM
  • Now that Beta2 docs are available, here is the API Matt means:

    http://msdn.microsoft.com/en-us/library/system.activities.presentation.iactivitytemplatefactory_members(VS.100).aspx


    Tim

    P.S This doesn't create a custom or composite activity, this is is for creating a preconfigured activity or group of activities, i.e. when drag dropped from the toolbox, create the sequence and its contents and the OutArgument joined to the InArgument automatically.
    Monday, October 19, 2009 5:34 PM
  • This is helpful but do you have a code sample that you could direct me to showing how this was implemented?

    Matthew Christopher
    Monday, October 19, 2009 8:29 PM
  • Matt, there is a snippet in my blog post here.

    Basically, you create a type that implements IActivityTemplateFactory and then it can be treated like an activity, but on drop will materialize whatever is in the Create() method.


      1:  public sealed class PickWithTwoBranchesFactory : IActivityTemplateFactory
       2:  {
       3:      public Activity Create(DependencyObject target)
       4:      {
       5:          return new Pick
       6:          {
       7:              Branches =
       8:              {
       9:                  new PickBranch
      10:                  {
      11:                      DisplayName = "Branch1"
      12:                  },
      13:                  new PickBranch
      14:                  {
      15:                      DisplayName = "Branch2"
      16:                  }
      17:              }
      18:          };
      19:      }
      20:  }

    Program Manager -- wf designer -- http://blogs.msdn.com/mwinkle
    Tuesday, October 20, 2009 7:59 PM
  • This is a great sample but could you please elaborate on how you would tie a designer to it.  Also what happens if you have other custom activities before or contained within this activities.  How would I tie a designer too it.

    Lastly does this concept of IActivityTemplateFactory have a graphical XAML equivelent?

    Thanks

    Matthew Christopher
    Thursday, November 12, 2009 4:31 PM
  • Matthew C, maybe these sources will be helpful to you:

    I think what you want is to create something like the PrePostSequence in
    channel9's "Introduction to Workflow 4.0":
    http://channel9.msdn.com/learn/courses/VS2010/WCFWF/IntroToWF/
    specifically, the file PrePostSequenceDesigner.xaml defines the layout of this multi-part activity.
    video version of that:
    http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Lab-Introduction-to-Workflow-in-NET-4/


    Or maybe start from download for WCF and WF 4 Beta 2 Samples:
    Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4.0 Beta 2
    http://www.microsoft.com/downloads/details.aspx?familyid=35EC8682-D5FD-4BC3-A51A-D8AD115A8792&displaylang=en
    specifically:
    WF / Basic / CustomActivities / Composite - Survey.xaml is an activity whose xaml defines some detail.


    [EDIT] I just learned of another example:
    Channel9 / Courses > Visual Studio 2010 and .NET Framework 4 Training Course > Windows Communication Foundation and Workflow >
    Workflow Designer Programming Model
    http://channel9.msdn.com/learn/courses/VS2010/WCFWF/WorkflowDesignerProgrammingModel/
    See:
    Exercise 4: Building a Composite Activity Designer
    • Proposed as answer by ToolmakerSteve Thursday, November 19, 2009 4:41 AM
    • Edited by ToolmakerSteve Friday, November 20, 2009 1:54 AM removed my incorrect comment about IActivityTemplateFactory
    Thursday, November 19, 2009 4:40 AM