DrawingAttributes.ContainsPropertyData(Guid) Yöntem
Tanım
Belirtilen özellik veri tanımlayıcısının nesne içinde olup olmadığını gösteren bir değer döndürür DrawingAttributes .Returns a value that indicates whether the specified property data identifier is in the DrawingAttributes object.
public:
bool ContainsPropertyData(Guid propertyDataId);
public bool ContainsPropertyData (Guid propertyDataId);
member this.ContainsPropertyData : Guid -> bool
Public Function ContainsPropertyData (propertyDataId As Guid) As Boolean
Parametreler
- propertyDataId
- Guid
GuidNesnesini bulmak için DrawingAttributes .The Guid to locate in the DrawingAttributes object .
Döndürülenler
true
Belirtilen özellik veri tanımlayıcısı DrawingAttributes nesnese; Aksi durumda, false
.true
if the specified property data identifier is in the DrawingAttributes object; otherwise, false
.
Örnekler
Aşağıdaki örnek nesnesinden özel bir özelliğin nasıl ekleneceğini ve alınacağını gösterir DrawingAttributes .The following example demonstrates how to add and retrieve a custom property from the DrawingAttributes object. Örnek, nesnenin bir kalem mi yoksa bir vurgulayıcı mi olduğunu gösteren bir özellik ekler DrawingAttributes .The example adds a property that indicates whether the DrawingAttributes object is a pen or a highlighter. ChangeColors_Click
Olay işleyicisi, ile öğesine eklenen tüm konturları yeni bir renge değiştirir InkCanvas DrawingAttributes inkDA
.The ChangeColors_Click
event handler changes all the strokes that were put on the InkCanvas with a DrawingAttributes called inkDA
to a new color. Bu örnek, adlı bir adlandırılmış olduğunu InkCanvas inkCanvas1
ve adında iki nesne olduğunu varsayar DrawingAttributes inkDA
ve highlighterDA.
This example assumes that there is an InkCanvas named inkCanvas1
, and that there are two DrawingAttributes objects named inkDA
, and highlighterDA.
Guid purposeGuid = new Guid("12345678-9012-3456-7890-123456789012");
string penValue = "pen";
string highlighterValue = "highlighter";
// Add a property to each DrawingAttributes object to
// specify its use.
private void AssignDrawingAttributesInstrument()
{
inkDA.AddPropertyData(purposeGuid, penValue);
highlighterDA.AddPropertyData(purposeGuid, highlighterValue);
}
// Change the color of the ink that on the InkCanvas that used the pen.
void ChangeColors_Click(Object sender, RoutedEventArgs e)
{
foreach (Stroke s in inkCanvas1.Strokes)
{
if (s.DrawingAttributes.ContainsPropertyData(purposeGuid))
{
object data = s.DrawingAttributes.GetPropertyData(purposeGuid);
if ((data is string) && ((string)data == penValue))
{
s.DrawingAttributes.Color = Colors.Black;
}
}
}
}
Private purposeGuid As New Guid("12345678-9012-3456-7890-123456789012")
Private penValue As String = "pen"
Private highlighterValue As String = "highlighter"
' Add a property to each DrawingAttributes object to
' specify its use.
Private Sub AssignDrawingAttributesInstrument()
inkDA.AddPropertyData(purposeGuid, penValue)
highlighterDA.AddPropertyData(purposeGuid, highlighterValue)
End Sub
' Change the color of the ink that on the InkCanvas that used the pen.
Private Sub ChangeColors_Click(ByVal sender As [Object], _
ByVal e As RoutedEventArgs)
Dim s As Stroke
For Each s In inkCanvas1.Strokes
If s.DrawingAttributes.ContainsPropertyData(purposeGuid) Then
Dim data As Object = s.DrawingAttributes.GetPropertyData(purposeGuid)
If TypeOf data Is String AndAlso CStr(data) = penValue Then
s.DrawingAttributes.Color = Colors.Black
End If
End If
Next s
End Sub