Hi Freddo,
It is possible to add an image programmatically to an image shape. First, you need to mark the ImageShape property "HasDoubleDerived" as true and regenerate the code by Transforming the Shape.tt template. Then, add a new custom class (say MyShapeName.cs) to your project and make it derive from MyShapeNameBase.cs (in the generated Shape.cs). Then override the Image getter in the derived class and return any System.Drawing.Image object from this method that will be used as an Image for your shape.
E.g. code snippet will look similar to this:
namespace Microsoft.Language16Shapes { public partial class ConditionShape : ConditionShapeBase { /// <summary> /// Provide the specific Image for this Shape class /// </summary> protected override global::System.Drawing.Image Image { get {
//Here you can give any implementation that will select the right image based on your requirements. global::System.Resources.ResourceManager resourceManager = global::Microsoft.Language16.Language16DomainModel.SingletonResourceManager; return DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("PortParentExplorerImage")); } } } }
Hope this helps,
Bhavin B
DSL Tools - SDET |