DrawingAttributes.AddPropertyData(Guid, Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
개체에 사용자 지정 속성을 DrawingAttributes 추가합니다.
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)
매개 변수
- propertyData
- Object
사용자 지정 속성의 값입니다.
propertyData는 이러한 데이터 형식의 배열Char, , ByteInt16, UInt16, Int32, UInt32Int64, UInt64SingleDoubleDateTimeBooleanStringDecimal 또는 이러한 데이터 형식의 배열이어야 하지만 형식String의 배열일 수는 없습니다.
예외
propertyData은 null입니다.
예제
다음 예제에서는 개체에서 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
설명
이 AddPropertyData 메서드를 사용하면 개체에 사용자 지정 속성을 추가할 수 있습니다 DrawingAttributes . 이 기능은 고유한 스트로크를 렌더링하고 추가 정보를 제공하려는 경우에 유용합니다.