2

I have read multiple tutorials/blogs/stackoverflow question about this, including the following:

and many more.

Most of them are outdated. Some suggests the Activity Designer library name should end with Design.dll, other says it should end with VisualStudio.Design.dll. Some say the library should be deployed to visual studio bin path, others say its not required.

Its all very confusing.

I can make the activity toolbox bitmaps to show properly only when using the ToolboxBitmapAttribute directly on the activity, and only if the embedded bmp icons are in the activity library, for example:

[ToolboxBitmap(typeof(MyActivity), "Resources.Bitmaps.MyActivity.bmp"]
public class MyActivity : CodeActivity
{
}

If I the move the bitmaps to the activity designer library, referencing the activity designer library in the activity library, and using the ToolboxBitmapAttribute directly on the activity (with correct embedded path and using type from the activity designer library) - it does not work.

[ToolboxBitmap(typeof(MyActivityDesigner), "Resources.Bitmaps.MyActivity.bmp"]
public class MyActivity : CodeActivity
{
}

If I use the IRegisterMetadata interface in the ActivityDesigner library, registering the ToolboxBitmapAttribute to the MyActivity type in the metadata store:

AttributeTableBuilder builder = new AttributeTableBuilder();
builder.AddCustomAttributes(typeof(MyActivity), new DesignerAttribute(typeof(MyActivityDesigner)));
builder.AddCustomAttributes(typeof(MyActivity), new ToolboxBitmapAttribute(typeof(MyActivityDesigner), "Resources.Bitmaps.MyActivity.bmp"));
MetadataStore.AddAttributeTable(builder.CreateTable());

Still no toolbox bitmap for the activity.

The Activity Designer works just fine!

So it seems that VS is loading MyActivities.Design.dll library, but ignoring the ToolboxBitmapAttribute for some reason.

I'll appreciate a hint for this one.

Community
  • 1
  • 1
Roman
  • 2,108
  • 1
  • 18
  • 20

1 Answers1

0

You might want to try ActivityDesigner's Icon property. Make sure the image is on the activity designer's project and marked as Resource on Build Action:

<sap:ActivityDesigner.Icon>
    <DrawingBrush>
        <DrawingBrush.Drawing>
            <ImageDrawing>
                <ImageDrawing.Rect>
                    <Rect Location="0,0" Size="25,25" ></Rect>
                </ImageDrawing.Rect>
                <ImageDrawing.ImageSource>
                    <BitmapImage UriSource="MyActivityIcon.png" />
                </ImageDrawing.ImageSource>
            </ImageDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</sap:ActivityDesigner.Icon>
Joao
  • 7,366
  • 4
  • 32
  • 48
  • Thanks for your answer Jota. Unfortunately, that's not the issue. As I said in my post, the ActivityDesigner itself is working flawlessly, with Icons and whatnot. The problem is with the Toolbox bitmap (the small 16X16 image of the activity in the toolbox panel in VisualStudio). – Roman Feb 15 '16 at 15:46