次の方法で共有


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 という名前の ImageInkAnalyzer、theInkAnalyzer に ImageNode を追加します。これにより、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 名前空間