The Problem Solver

Tell me and I will forget
Show me and I will remember
Involve me and I will understand
- Confucius -

Google Ads

This Blog

Syndication

Search

Tags

News





  • View Maurice De Beijer's profile on LinkedIn

Community

Email Notifications

Explore

Archives

Changing the ActivityDesignerTheme on an activity

Using an ActivityDesignerTheme is a quick way to customize the appearance of an activity in the workflow designer. But there is a gotcha Sad Because once you applied the theme and have a workflow with the custom activity open in the designer no matter what you do changes will not be applied.

I am not sure why this is but I suppose the designer caches the color scheme and doesn't see any changes made to it.

Take the following activity:

using System;
using System.ComponentModel;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Drawing.Drawing2D;

namespace WorkflowConsoleApplication4
{
    [Designer(typeof(MyActivity1ActivityDesigner))]
    public partial class MyActivity: Activity
    {
    }


    [ActivityDesignerTheme(typeof(MyActivity1ActivityDesignerTheme))]
    public class MyActivity1ActivityDesigner: ActivityDesigner
    {
    }

    public class MyActivity1ActivityDesignerTheme : ActivityDesignerTheme
    {
        /// <summary>
        /// Initializes a new instance of the MyActivity1ActivityDesignerTheme class.
        /// </summary>
        public MyActivity1ActivityDesignerTheme(WorkflowTheme theme)
            : base(theme)
        {
            BackColorStart = Color.LightBlue;
            BackColorEnd = Color.Blue;
            BackgroundStyle = LinearGradientMode.ForwardDiagonal;
        }
    }
}

Which look like this in the designer

image

Clearly the background has a blue gradient. Now if I change the theme code to the following:

public class MyActivity1ActivityDesignerTheme : ActivityDesignerTheme
{
    /// <summary>
    /// Initializes a new instance of the MyActivity1ActivityDesignerTheme class.
    /// </summary>
    public MyActivity1ActivityDesignerTheme(WorkflowTheme theme)
        : base(theme)
    {
        BackColorStart = Color.LightCyan;
        BackColorEnd = Color.Cyan;
        BackgroundStyle = LinearGradientMode.ForwardDiagonal;
    }
}

You might expect the activity to change its look to:

image

Unfortunately this doesn't happen Sad

Now you can quit Visual Studio and restart it after which the new style will take affect but there is a quicker way. Right click the activity and select "Select Custom Theme..."

image

When the dialog shows just click OK and the designer reads the theme again Smile

 

image

Enjoy!

www.TheProblemSolver.nl
http://wiki.WindowsWorkflowFoundation.eu

Published Tue, Jun 10 2008 15:34 by Maurice
Filed under: , , , ,

Comments

# re: Changing the ActivityDesignerTheme on an activity@ Wednesday, July 02, 2008 10:43 AM

Thanks for the tip - that issue was bugging me!

by PeteM