StrokeCollection.AddPropertyData(Guid, Object) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Lägger till en anpassad egenskap i StrokeCollection.
public:
void AddPropertyData(Guid propertyDataId, System::Object ^ propertyData);
public void AddPropertyData(Guid propertyDataId, object propertyData);
member this.AddPropertyData : Guid * obj -> unit
Public Sub AddPropertyData (propertyDataId As Guid, propertyData As Object)
Parametrar
- propertyData
- Object
Värdet för den anpassade egenskapen.
propertyDatamåste vara av typen Char, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64Single, , Double, DateTime, Boolean, , StringDecimaleller en matris med dessa datatyper, förutom String, som inte är tillåten.
Undantag
propertyDataId är en tom Guid.
-eller-
propertyData är inte en av de tillåtna datatyper som anges i Parameters avsnittet.
Exempel
I följande exempel visas hur du lägger till och hämtar anpassade egenskapsdata. Metoden AddTimeStamp_Click använder AddPropertyData metoden för att lägga till den aktuella tiden i StrokeCollection. Metoden GetTimeStap_Click använder GetPropertyData metoden för att hämta tidsstämpeln StrokeCollectionfrån . Det här exemplet förutsätter att det finns en InkCanvas som heter 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
Kommentarer
Med AddPropertyData metoden kan du lägga till anpassade egenskaper i en StrokeCollection. Du kan sedan inkludera extra information med en StrokeCollection.