ImageNode.SetLocation 方法
设置非墨迹图像在应用程序文档上的位置。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.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
)
参数
- location
类型:Microsoft.Ink.AnalysisRegion
非墨迹图像在应用程序文档上的位置(采用墨迹坐标)。
备注
位置以墨迹坐标设置。
示例
下面的示例将一个 ImageNode 对象添加到 PictureBox 控件 thePictureBox 的 InkAnalyzer (theInkAnalyzer)。它将 PictureBox 控件的位置从像素坐标转换为墨迹坐标。另外,还将 ImageNode 对象的 Data 属性设置为 PictureBox 的 Image 属性。
' 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();
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0