Freigeben über


ImageNode.SetLocation-Methode

Legt die Position des Nicht-Freihandbilds im Anwendungsdokument fest.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.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
)

Parameter

  • location
    Typ: Microsoft.Ink.AnalysisRegion
    Die Position, an der sich das Nicht-Freihandbild im Anwendungsdokument befindet, wird in Freihandkoordinaten angegeben.

Hinweise

Die Position wird in Freihandkoordinaten festgelegt.

Beispiele

Im folgenden Beispiel wird dem InkAnalyzer mit dem Namen theInkAnalyzer, für das PictureBox-Steuerelement thePictureBox ein ImageNode-Objekt hinzugefügt. Konvertiert die Position des PictureBox-Steuerelements von Pixelkoordinaten in Freihandkoordinaten. Legt die Data-Eigenschaft des ImageNode-Objekts auf die Image-Eigenschaft der PictureBox fest.

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

Plattformen

Windows Vista

.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

Versionsinformationen

.NET Framework

Unterstützt in: 3.0

Siehe auch

Referenz

ImageNode-Klasse

ImageNode-Member

Microsoft.Ink-Namespace