ImageNode - класс
Обновлен: Ноябрь 2007
Represents a ContextNode for a two-dimensional region where any non-ink images may exist in the application.
Пространство имен: 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
Заметки
The InkAnalyzer does not produce ImageNode objects. The application uses the CreateSubNode(ContextNodeType) method to add the ImageNode objects to the context node tree. If the state of the analyzer is persisted, these nodes can be persisted as well.
Future recognizers may use the regions defined by the ImageNode objects to determine if any ink annotates the non-ink image.
An ImageNode cannot have any children.
Примеры
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();
}
Иерархия наследования
System.Object
System.Windows.Ink.ContextNode
System.Windows.Ink.ImageNode
Потокобезопасность
Любые открытые члены этого типа, объявленные как static (Shared в Visual Basic), являются потокобезопасными. Потокобезопасность членов экземпляров не гарантируется.
Платформы
Windows Vista
Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.
Сведения о версии
.NET Framework
Поддерживается в версии: 3.0