ImageNode.SetLocation Method

Sets the location of the non-ink image on the application document.

Namespace: System.Windows.Ink
Assembly: IAWinFX (in iawinfx.dll)

Syntax

'Declaration
Public Sub SetLocation ( _
    location As AnalysisRegion _
)
'Usage
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
)
Not applicable.

Parameters

  • location

Remarks

The location is set in ink coordinates.

Example

The following example adds an ImageNode to an InkAnalyzer, theInkAnalyzer, for an Image, 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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

ImageNode Class
ImageNode Members
System.Windows.Ink Namespace