Udostępnij za pośrednictwem


DesignerGlyph.CanBeActivated Właściwość

Definicja

Pobiera wartość wskazującą, czy DesignerGlyph może skupić się na ActivityDesigner tym, z którym jest skojarzona.

public:
 virtual property bool CanBeActivated { bool get(); };
public virtual bool CanBeActivated { get; }
member this.CanBeActivated : bool
Public Overridable ReadOnly Property CanBeActivated As Boolean

Wartość właściwości

true jeśli można aktywować glif projektanta; w przeciwnym razie , false. Wartość domyślna to false.

Przykłady

W poniższym przykładzie pokazano implementację właściwości CanBeActivated. Ten przykład pochodzi z przykładowego zestawu SDK projektanta profilu śledzenia. Aby uzyskać więcej informacji, zobacz Tracking Profile Designer Sample (Przykład projektanta profilu śledzenia).

/// <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);
        }
    }
}
' This glyph shows that the activity's track point is not correctly configured
Friend NotInheritable Class ErrorActivityGlyph
    Inherits DesignerGlyph

    Shared image As Bitmap = Resources.errorIcon
    Dim errorMessage As String

    Friend Sub New(ByVal errorMessage As String)
        Me.errorMessage = errorMessage
    End Sub

    Public Overrides ReadOnly Property CanBeActivated() As Boolean
        Get
            Return True
        End Get
    End Property

    ' Display an error message when this glyph is clicked
    Protected Overrides Sub OnActivate(ByVal designer As ActivityDesigner)
        MessageBox.Show(errorMessage)
    End Sub

    Public Overrides Function GetBounds(ByVal designer As ActivityDesigner, ByVal activated As Boolean) As Rectangle
        Dim imageBounds As New Rectangle()
        If image IsNot Nothing Then
            imageBounds.Size = image.Size
            imageBounds.Location = New Point(designer.Bounds.Right - imageBounds.Size.Width / 4, designer.Bounds.Top - imageBounds.Size.Height / 2)
        End If
        Return imageBounds
    End Function


    Protected Overrides Sub OnPaint(ByVal graphics As Graphics, ByVal activated As Boolean, ByVal ambientTheme As AmbientTheme, ByVal designer As ActivityDesigner)
        image.MakeTransparent(Color.FromArgb(255, 255, 255))
        If image IsNot Nothing Then
            graphics.DrawImage(image, GetBounds(designer, activated), New Rectangle(Point.Empty, image.Size), GraphicsUnit.Pixel)
        End If
    End Sub
End Class

Dotyczy