StrokeCollection.GetPropertyData(Guid) Metodo

Definizione

Restituisce il valore della proprietà personalizzata associata all'oggetto specificato Guid.

public:
 System::Object ^ GetPropertyData(Guid propertyDataId);
public object GetPropertyData(Guid propertyDataId);
member this.GetPropertyData : Guid -> obj
Public Function GetPropertyData (propertyDataId As Guid) As Object

Parametri

propertyDataId
Guid

Oggetto Guid associato alla proprietà personalizzata da ottenere.

Valori restituiti

Valore della proprietà personalizzata associata all'oggetto specificato Guid.

Eccezioni

propertyDataId non è associato a una proprietà personalizzata di StrokeCollection.

Esempio

Nell'esempio seguente viene illustrato come aggiungere e ottenere dati delle proprietà personalizzate. Il AddTimeStamp_Click metodo usa il AddPropertyData metodo per aggiungere l'ora corrente a StrokeCollection. Il GetTimeStap_Click metodo usa il GetPropertyData metodo per recuperare il timestamp da StrokeCollection. In questo esempio si presuppone che sia presente un InkCanvas oggetto denominato inkCanvas1.

Guid timestamp = new Guid("12345678-9012-3456-7890-123456789012");

// Add a timestamp to the StrokeCollection.
private void AddTimestamp_Click(object sender, RoutedEventArgs e)
{

    inkCanvas1.Strokes.AddPropertyData(timestamp, DateTime.Now);
}

// Get the timestamp of the StrokeCollection.
private void GetTimestamp_Click(object sender, RoutedEventArgs e)
{

    if (inkCanvas1.Strokes.ContainsPropertyData(timestamp))
    {
        object date = inkCanvas1.Strokes.GetPropertyData(timestamp);

        if (date is DateTime)
        {
            MessageBox.Show("This StrokeCollection's timestamp is " +
                ((DateTime)date).ToString());
        }
    }
    else
    {
        MessageBox.Show(
            "The StrokeCollection does not have a timestamp.");
    }
}
Private timestamp As New Guid("12345678-9012-3456-7890-123456789012")

' Add a timestamp to the StrokeCollection.
Private Sub AddTimestamp_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    inkCanvas1.Strokes.AddPropertyData(timestamp, DateTime.Now)

End Sub

' Get the timestamp of the StrokeCollection.
Private Sub GetTimestamp_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    If inkCanvas1.Strokes.ContainsPropertyData(timestamp) Then

        Dim savedDate As Object = inkCanvas1.Strokes.GetPropertyData(timestamp)

        If TypeOf savedDate Is DateTime Then
            MessageBox.Show("This StrokeCollection's timestamp is " & _
                CType(savedDate, DateTime).ToString())
        End If
    Else
        MessageBox.Show("The StrokeCollection does not have a timestamp.")
    End If

End Sub

Commenti

I AddPropertyData metodi e GetPropertyData consentono di aggiungere proprietà personalizzate a un oggetto StrokeCollection. È quindi possibile includere informazioni aggiuntive con un oggetto StrokeCollection.

Si applica a