Using visual studio I have created a custom activity.
I have worked out that the class name equates to the activity name and that the folder structure is defined by the namespaces.
How do I put spaces in the activity name as you can’t have a class with a space in it?
How do I put spaces in the activity folder as you can’t have spaces in a namespace?
How do I add hover over tooltip type messages for activity parameters?
How do I create a drop-down parameter for an activity to allow the user to select an option?
For the first two I figured it’s gonna be either Underscores or Capital letters so my_custom_Activity or myCustomActivity, you will have the same result,
But still for hover I add a description in the nuget package explorer, but this doesn’t show anything while hovering in studio, where can I create a designer with metadata is it going to be in visual studio itself?
And last for the drop down should the property be of an option type to achieve this?
These are some important questions that should be answered in the forum but somehow they’re not!
For the description you want a couple of files adding to your project which I’ve given an outline of below. There is a lot of examples on some of the Microsoft Forums/Blogs if you search for ‘Custom WPF Activities’ which is essentially what UiPath Activities are.
myActivity_Designer.xaml
this is where you design the XAML layout of the activity and you need the line below at the top to link the designer.xaml, designer.xaml.cs and the MetaData.cs
myActivity_Designer.xaml.cs
this is where you add the description
public partial class myActivity_Designer
{
public myActivity_Designer()
{
InitializeComponent();
}
public static void RegisterMetadata(AttributeTableBuilder builder)
{
builder.AddCustomAttributes(
typeof(myActivity),
new DesignerAttribute(typeof(myActivity_Designer)),
new DescriptionAttribute("MY DESCRIPTION.")
);
}
}
myActivity_MetaData.cs
public sealed class myActivity_MetaData : IRegisterMetadata
{
public void Register()
{
RegisterAll();
}
public static void RegisterAll()
{
var builder = new AttributeTableBuilder();
myActivity_Designer.RegisterMetadata(builder);
// TODO: Other activities can be added here
MetadataStore.AddAttributeTable(builder.CreateTable());
}
}
You can easily update the way the activity name is displayed updating the DisplayName property of the class in its constructor:
FYI, I’ve created this Visual Studio Item Template to help with the custom activity creation and it auto-generates these methods for you so you don’t need to memorize it.