共用方式為


ExtendedProperty.Data 屬性

取得或設定 ExtendedProperty 物件的資料。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Property Data As Object
'用途
Dim instance As ExtendedProperty
Dim value As Object

value = instance.Data

instance.Data = value
public Object Data { get; set; }
public:
property Object^ Data {
    Object^ get ();
    void set (Object^ value);
}
/** @property */
public Object get_Data()
/** @property */
public  void set_Data(Object value)
public function get Data () : Object
public function set Data (value : Object)

屬性值

型別:System.Object
ExtendedProperty 物件的資料。

例外狀況

例外狀況 條件
ArgumentException

Data 未設定為下列其中一種型別:

Char

Char 陣列

Byte

Byte 陣列

Int16

Int16 陣列

UInt16

UInt16 陣列

Int32

Int32 陣列

UInt32

UInt32 陣列

Int64

Int64 陣列

UInt64

UInt64 陣列

Single

Single 陣列

Double

Double 陣列

DateTime

DateTime 陣列

Boolean

Boolean 陣列

String

Decimal

Decimal 陣列

備註

此資料包含無法以其他方式在物件上設定的資訊,例如建立 Stroke 物件的時間或日期。

範例

這個範例會示範如何訂閱 CursorDown 事件和 Stroke 事件,計算使用者建立筆劃所需的時間長度。

筆劃開始時,會引發 CursorDown 事件。目前的時間會放入 Stroke 物件的 ExtendedProperties 集合。

Private Sub mInkObject_CursorDown(ByVal sender As Object, ByVal e As InkCollectorCursorDownEventArgs)
    ' add extended property indicating the time the stroke started
    ' STROKE_START_GUID is class level string via GUID generator
    e.Stroke.ExtendedProperties.Add(New Guid(STROKE_START_GUID), DateTime.Now)
End Sub
private void mInkObject_CursorDown(object sender, InkCollectorCursorDownEventArgs e)
{
    // add extended property indicating the time the stroke started
    // STROKE_START_GUID is class level string via GUID generator
    e.Stroke.ExtendedProperties.Add(new Guid(STROKE_START_GUID), DateTime.Now);
}

筆劃完成時,會引發 Stroke 事件。開始時間是擷取自 Stroke 物件的 ExtendedProperties 集合,並且用來計算經過的時間。

Private Sub mInkObject_Stroke1(ByVal sender As Object, ByVal e As InkCollectorStrokeEventArgs)
    ' check to see if extended property for start time exists
    ' Attempting to access an extended property that hasn't been created throws an exception
    ' STROKE_START_GUID is class level string via GUID generator
    If (e.Stroke.ExtendedProperties.DoesPropertyExist(New Guid(STROKE_START_GUID))) Then

        Dim startTime As DateTime = DirectCast(e.Stroke.ExtendedProperties(New Guid(STROKE_START_GUID)).Data, DateTime)
        Dim endTime As DateTime = DateTime.Now
        Dim span As TimeSpan = New TimeSpan(endTime.Ticks - startTime.Ticks)

        ' add extended property indicating the time the stroke ended
        ' STROKE_END_GUID is class level string via GUID generator
        e.Stroke.ExtendedProperties.Add(New Guid(STROKE_END_GUID), endTime)

        ' display the number of seconds in creating this stroke
        Me.statusLabelStrokeTime.Text = span.TotalSeconds.ToString()
    End If
End Sub
private void mInkObject_Stroke1(object sender, InkCollectorStrokeEventArgs e)
{
    // check to see if extended property for start time exists
    // Attempting to access an extended property that hasn't been created throws an exception
    // STROKE_START_GUID is class level string via GUID generator
    if (e.Stroke.ExtendedProperties.DoesPropertyExist(new Guid(STROKE_START_GUID)))
    {
        DateTime startTime = (DateTime)e.Stroke.ExtendedProperties[new Guid(STROKE_START_GUID)].Data;
        DateTime endTime = DateTime.Now;
        TimeSpan span = new TimeSpan(endTime.Ticks - startTime.Ticks);

        // add extended property indicating the time the stroke ended
        // STROKE_END_GUID is class level string via GUID generator
        e.Stroke.ExtendedProperties.Add(new Guid(STROKE_END_GUID), endTime);

        // display the number of seconds in creating this stroke
        this.statusLabelStrokeTime.Text = span.TotalSeconds.ToString();
    }
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

ExtendedProperty 類別

ExtendedProperty 成員

Microsoft.Ink 命名空間

DrawingAttributes.ExtendedProperties

ExtendedProperties

Stroke.ExtendedProperties