DesignerGlyph.OnActivate Method (ActivityDesigner)

 

Indicates to the glyph that an action has been performed which has activated the glyph.

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

protected virtual void OnActivate(
	ActivityDesigner designer
)

Parameters

designer
Type: System.Workflow.ComponentModel.Design.ActivityDesigner

The ActivityDesigner on which the glyph is drawn.

The following example demonstrates an implementation of the OnActivate method. 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
Available since 3.0
Return to top
Show: