locked
Overriding designer of standard activity RRS feed

  • Question

  • Hello!
    Suppose, I need to put custom text on activity block on designer surface. Lets say it will be DelayActivity.
    When you drag it into surface, text in block says "delayActivity1".

    I use next code to get access to designer of activities:
                    Dim ComponentChangeService As IComponentChangeService = CType(GetService(GetType(IComponentChangeService)), IComponentChangeService)
                    AddHandler ComponentChangeService.ComponentAdded, AddressOf OnComponentEvent


        Private Sub OnComponentEvent(ByVal sender As Object, ByVal e As ComponentEventArgs)
            If (e.Component.Site IsNot Nothing) Then
                Dim DesignerHost As IDesignerHost = TryCast(designSurface.GetService(GetType(IDesignerHost)), IDesignerHost)
                If DesignerHost IsNot Nothing Then
                    Dim ComponentDesigner As IDesigner = TryCast(DesignerHost.GetDesigner(e.Component), IDesigner)
                    If ComponentDesigner IsNot Nothing Then
                        If TypeOf ComponentDesigner.Component Is DelayActivity Then

                        ElseIf TypeOf ComponentDesigner.Component Is ParallelActivity Then

                        ElseIf TypeOf ComponentDesigner.Component Is SequenceActivity Then

                        ElseIf TypeOf ComponentDesigner.Component Is SuspendActivity Then

                        ElseIf TypeOf ComponentDesigner.Component Is TerminateActivity Then

                        End If
                    End If
                End If
            End If
        End Sub


    When I look at ComponentDesigner in watch window I see class System.Workflow.Activities.DelayDesigner , BUT I CANNOT reference it in code! :(
    What is more, when I try to cast ComponentDesigner to base class ActvityDesigner and modify property Text I get a message that property has protected setter.

    How then I can set this property ??
    Monday, December 7, 2009 2:48 PM

Answers

  • In WF 3, the designer is tightly coupled to the activity. You cannot customize just the designer for an out of the box activity. So that's why you cannot set those things. You'll have to write your own activity and designer.
    In WF4, we've decouple these things and not only can you write custom activities and designers, you can also change the designer of any activity we ship in the box.


    Senior Lead Program Manager, Windows Workflow Foundation http://blogs.msdn.com/kavitak
    Monday, December 14, 2009 8:36 PM
    Moderator

All replies

  • HI,
    ->"When I look at ComponentDesigner in watch window I see class System.Workflow.Activities.DelayDesigner , BUT I CANNOT reference it in code!"
    System.Workflow.Activities.DelayDesigner is a internal sealed class. we can not either reference it in our code or create a class inherit from it.

    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support
    Monday, December 14, 2009 1:22 AM
    Moderator
  • In WF 3, the designer is tightly coupled to the activity. You cannot customize just the designer for an out of the box activity. So that's why you cannot set those things. You'll have to write your own activity and designer.
    In WF4, we've decouple these things and not only can you write custom activities and designers, you can also change the designer of any activity we ship in the box.


    Senior Lead Program Manager, Windows Workflow Foundation http://blogs.msdn.com/kavitak
    Monday, December 14, 2009 8:36 PM
    Moderator