ImageNode.Data Property
Gets and sets application defined data for the ImageNode object.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.dll)
Syntax
'Declaration
Public Property Data As Object
'Usage
Dim instance As ImageNode
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);
}
public function get Data () : Object
public function set Data (value : Object)
Property Value
Type: System.Object
The application-defined data for the ImageNode object.
Remarks
Use this property to add your own data to the ImageNode object.
Examples
The following example adds an ImageNode to an InkAnalyzer, theInkAnalyzer, for an Image named theImage. It sets the location of the ImageNode to the location of the Image and the Data property to the Source property of the Image.
' Add image node
Dim pictureNode As ImageNode = _
CType(theInkAnalyzer.RootNode.CreateSubNode(ContextNodeType.Image), _
ImageNode)
' Set the location of the image node
Dim imageTop As Double = InkCanvas.GetTop(theImage)
Dim imageLeft As Double = InkCanvas.GetLeft(theImage)
Dim imageBounds As New Rect(imageLeft, imageTop, theImage.Width, theImage.Height)
pictureNode.SetLocation(New AnalysisRegion(imageBounds))
' Serialize the image to a byte array and set ImageNode.Data to the array.
' theImage.Source is a BitmapImage.
Dim bmp As New BmpBitmapEncoder()
bmp.Frames.Add(BitmapFrame.Create(CType(theImage.Source, BitmapImage)))
Dim stream As New System.IO.MemoryStream()
Try
bmp.Save(stream)
pictureNode.Data = stream.ToArray()
Finally
stream.Dispose()
End Try
// Add image node
ImageNode pictureNode = (ImageNode)
theInkAnalyzer.RootNode.CreateSubNode(ContextNodeType.Image);
// Set the location of the image node
double imageTop = InkCanvas.GetTop(theImage);
double imageLeft = InkCanvas.GetLeft(theImage);
Rect imageBounds = new Rect(imageLeft, imageTop, theImage.Width, theImage.Height);
pictureNode.SetLocation(new AnalysisRegion(imageBounds));
// Serialize the image to a byte array and set ImageNode.Data to the array.
// theImage.Source is a BitmapImage.
BmpBitmapEncoder bmp = new BmpBitmapEncoder();
bmp.Frames.Add(BitmapFrame.Create((BitmapImage)theImage.Source));
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
bmp.Save(stream);
pictureNode.Data = stream.ToArray();
}
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0