ImageNode.SetLocation 方法

设置非墨迹图像在应用程序文档上的位置。

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

语法

声明
Public Sub SetLocation ( _
    location As AnalysisRegion _
)
用法
Dim instance As ImageNode
Dim location As AnalysisRegion

instance.SetLocation(location)
public void SetLocation(
    AnalysisRegion location
)
public:
void SetLocation(
    AnalysisRegion^ location
)
public void SetLocation(
    AnalysisRegion location
)
public function SetLocation(
    location : AnalysisRegion
)

参数

备注

位置以墨迹坐标设置。

示例

下面的示例为名为 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();
}


平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ImageNode 类

ImageNode 成员

System.Windows.Ink 命名空间