ImageNode 类

表示应用程序中可存在任何非墨迹图像的二维区域的 ContextNode

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public NotInheritable Class ImageNode _
    Inherits ContextNode
用法
Dim instance As ImageNode
public sealed class ImageNode : ContextNode
public ref class ImageNode sealed : public ContextNode
public final class ImageNode extends ContextNode
public final class ImageNode extends ContextNode

备注

InkAnalyzer 不生成 ImageNode 对象。应用程序使用 CreateSubNode(ContextNodeType) 方法将 ImageNode 对象添加到上下文节点树。如果保存分析器的状态,则这些节点也可保存。

未来的识别器可能使用由 ImageNode 对象定义的区域来确定是否有任何墨迹对非墨迹图像进行批注。

ImageNode 不能有任何子级。

示例

下面的示例为名为 theImage 的 Image 将一个 ImageNode 添加到 InkAnalyzer (theInkAnalyzer) 中。该示例将 ImageNode 的位置设置为 Image 的位置,并将 Data 属性设置为 ImageSource 属性。

' 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();
}


继承层次结构

System.Object
  System.Windows.Ink.ContextNode
    System.Windows.Ink.ImageNode

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ImageNode 成员

System.Windows.Ink 命名空间

System.Windows.Ink.TextWordNode