ImageNode.SetLocation-Methode
Legt die Position des Nicht-Freihandbilds im Anwendungsdokument fest.
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
)
Parameter
- location
Typ: System.Windows.Ink.AnalysisRegion
Hinweise
Die Position wird in Freihandkoordinaten festgelegt.
Beispiele
Im folgenden Beispiel wird dem InkAnalyzertheInkAnalyzer für ein Image mit dem Namen theImage ein ImageNode hinzugefügt. Legt die Position der ImageNode auf die Position des Image und die Data-Eigenschaft auf die Source-Eigenschaft des Image fest.
' 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();
}
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