DrawingAttributes.ContainsPropertyData(Guid) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 속성 데이터 식별자가 개체에 DrawingAttributes 있는지 여부를 나타내는 값을 반환합니다.
public:
bool ContainsPropertyData(Guid propertyDataId);
public bool ContainsPropertyData(Guid propertyDataId);
member this.ContainsPropertyData : Guid -> bool
Public Function ContainsPropertyData (propertyDataId As Guid) As Boolean
매개 변수
- propertyDataId
- Guid
Guid 개체에서 찾을 위치입니다DrawingAttributes.
반품
예제
다음 예제에서는 개체에서 DrawingAttributes 사용자 지정 속성을 추가하고 검색하는 방법을 보여 줍니다. 다음은 개체가 펜인지 형광펜인지 여부를 DrawingAttributes 나타내는 속성을 추가하는 예제입니다.
ChangeColors_Click 이벤트 처리기는 호출 InkCanvas 된 상태로 적용된 모든 스트로크를 DrawingAttributes 새 색으로 inkDA 변경합니다. 이 예제에서는 명명된 InkCanvas 개체 inkCanvas1가 있고 두 개의 DrawingAttributes 개체가 있다고 inkDA가정합니다 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