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, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, DateTime, Boolean, String, Decimal 형식이거나 이러한 데이터 형식의 배열이어야 합니다. 그러나 String 형식의 배열은 허용되지 않습니다.
예외
propertyData이(가) null인 경우
propertyDataId가 빈 Guid인 경우
또는
propertyData가 Parameters 섹션에 나열된 허용되는 데이터 형식 중 하나가 아닌 경우
예제
다음 예제에서는 추가 하 고에서 사용자 지정 속성을 검색 하는 방법의 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 개체입니다. 사용자 고유의 스트로크를 렌더링 하 고 추가 정보를 제공 하는 경우에 유용 합니다.