DrawingAttributes.GetPropertyData(Guid) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정한 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
매개 변수
반환
지정한 Guid와 연결된 사용자 지정 속성의 값입니다.
예외
propertyDataId가 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
설명
사용 합니다 GetPropertyData 에 추가한 사용자 지정 속성에 액세스 하는 메서드를 DrawingAttributes 개체입니다. GetPropertyData 값 설정 되지 않은 경우 기본 제공 속성의 기본값을 반환 합니다.