ImageNode.Data 属性
获取或设置 ImageNode 对象的应用程序定义的数据。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Property Data As Object
用法
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);
}
/** @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
ImageNode 对象的应用程序定义的数据。
备注
使用此属性可将您自己的数据添加到 ImageNode 对象。
示例
下面的示例将一个 ImageNode 对象添加到 PictureBox 控件 thePictureBox 的 InkAnalyzer (theInkAnalyzer)。它将 PictureBox 控件的位置从像素坐标转换为墨迹坐标。另外,还将 ImageNode 对象的 Data 属性设置为 PictureBox 的 Image 属性。
' Add image node
Dim pictureNode As ImageNode = _
theInkAnalyzer.RootNode.CreateSubNode(Microsoft.Ink.ContextNodeType.Image)
' Convert pixel coordinates to pixel coordinates
Dim pictureTopLeft As Point = thePictureBox.Location
Dim pictureBottomRight As New Point(thePictureBox.Right, thePictureBox.Bottom)
Dim panelGraphics As Graphics = theNotesPanel.CreateGraphics()
theInkCollector.Renderer.PixelToInkSpace(panelGraphics, pictureTopLeft)
theInkCollector.Renderer.PixelToInkSpace(panelGraphics, pictureBottomRight)
panelGraphics.Dispose()
' Set the location of the image node
pictureNode.SetLocation(New AnalysisRegion(New Rectangle(pictureTopLeft.X, _
pictureTopLeft.Y, pictureBottomRight.X - pictureTopLeft.X, _
pictureBottomRight.Y - pictureTopLeft.Y)))
' Serialize the image to a byte array and set ImageNode.Data to the array.
Using stream As System.IO.MemoryStream = New System.IO.MemoryStream()
thePictureBox.Image.Save(stream, thePictureBox.Image.RawFormat)
pictureNode.Data = stream.ToArray()
End Using
// Add image node
ImageNode pictureNode = (ImageNode)
theInkAnalyzer.RootNode.CreateSubNode(Microsoft.Ink.ContextNodeType.Image);
// Convert pixel coordinates to pixel coordinates
Point pictureTopLeft = thePictureBox.Location;
Point pictureBottomRight = new Point(thePictureBox.Right,
thePictureBox.Bottom);
Graphics panelGraphics = theNotesPanel.CreateGraphics();
theInkCollector.Renderer.PixelToInkSpace(panelGraphics, ref pictureTopLeft);
theInkCollector.Renderer.PixelToInkSpace(panelGraphics, ref pictureBottomRight);
panelGraphics.Dispose();
// Set the location of the image node
pictureNode.SetLocation(new AnalysisRegion(new Rectangle(pictureTopLeft.X,
pictureTopLeft.Y, pictureBottomRight.X - pictureTopLeft.X,
pictureBottomRight.Y - pictureTopLeft.Y)));
// Serialize the image to a byte array and set ImageNode.Data to the array.
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
thePictureBox.Image.Save(stream, thePictureBox.Image.RawFormat);
pictureNode.Data = stream.ToArray();
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0