Export (0) Print
Expand All

DesignerGlyph.CanBeActivated Property

Gets a value indicating whether the DesignerGlyph can gain focus on the ActivityDesigner with which it is associated.

Namespace:  System.Workflow.ComponentModel.Design
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

public virtual bool CanBeActivated { get; }

Property Value

Type: System.Boolean
true if the designer glyph can be activated; otherwise, false. The default is false.

The following example demonstrates an implementation of the CanBeActivated property. This example is from the Tracking Profile Designer SDK sample. For more information, see Tracking Profile Designer Sample.

/// <summary> 
/// This glyph shows that the activity's track point is not correctly configured 
/// </summary> 
internal sealed class ErrorActivityGlyph : DesignerGlyph
{
    static Bitmap image = Resources.error;
    string errorMessage;

    internal ErrorActivityGlyph(string errorMessage)
    {
        this.errorMessage = errorMessage;
    }

    public override bool CanBeActivated
    {
        get
        {
            return true;
        }
    }

    /// <summary> 
    /// Display an error message when this glyph is clicked 
    /// </summary> 
    /// <param name="designer"></param>
    protected override void OnActivate(ActivityDesigner designer)
    {
        MessageBox.Show(errorMessage);
    }

    public override Rectangle GetBounds(ActivityDesigner designer, bool activated)
    {
        Rectangle imageBounds = new Rectangle();
        if (image != null)
        {
            imageBounds.Size = image.Size;
            imageBounds.Location = new Point(designer.Bounds.Right - imageBounds.Size.Width / 4, designer.Bounds.Top - imageBounds.Size.Height / 2);

        }
        return imageBounds;
    }

    protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
    {
        image.MakeTransparent(Color.FromArgb(255, 255, 255));
        if (image != null)
        {
            graphics.DrawImage(image, GetBounds(designer, activated), new Rectangle(Point.Empty, image.Size), GraphicsUnit.Pixel);
        }
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0
Show:
© 2015 Microsoft