共用方式為


Ink.AddStrokesAtRectangle 方法

指定已知的 Strokes 集合,在指定矩形處插入這個 Ink 物件。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Sub AddStrokesAtRectangle ( _
    strokes As Strokes, _
    destinationRectangle As Rectangle _
)
'用途
Dim instance As Ink
Dim strokes As Strokes
Dim destinationRectangle As Rectangle

instance.AddStrokesAtRectangle(strokes, _
    destinationRectangle)
public void AddStrokesAtRectangle(
    Strokes strokes,
    Rectangle destinationRectangle
)
public:
void AddStrokesAtRectangle(
    Strokes^ strokes, 
    Rectangle destinationRectangle
)
public void AddStrokesAtRectangle(
    Strokes strokes,
    Rectangle destinationRectangle
)
public function AddStrokesAtRectangle(
    strokes : Strokes, 
    destinationRectangle : Rectangle
)

參數

備註

如果矩形座標為 {0,0,0,0},則會擲回執行階段錯誤。

來源 Strokes 集合會附加到 Ink 物件。

筆劃在插入時會從 Strokes 集合的週框方塊,縮放到矩形中。

這個方法可以用來複製單一 Ink 物件內的筆劃。來源筆劃不一定要來自其他 Ink 物件。

範例

這個 C# 範例會使用 AddStrokesAtRectangle 方法從主物件 InkCollector (panelMain) 建立筆墨的複本,複製到 InkCollector 物件 (panelThumb) 中,同時維持適當的縮放比例和外觀比例 (Aspect Ratio)。為了維持目前的縮圖面板,會在 panelMain 中加入 Stroke 事件處理常式 (panelMain_Stroke)。

private void panelMain_Stroke(object sender, Microsoft.Ink.InkCollectorStrokeEventArgs e)
{
    // Create a bounding rectangle for panelThumb in ink space coordinates
    Point thePoint = Point.Empty;
    using (Graphics g = Graphics.FromHwnd(Handle))
    {
        thePoint = new Point(panelThumb.Width, panelThumb.Height);
        panelMain.Renderer.PixelToInkSpace(g, ref thePoint);
    }
    Rectangle theRectangle = new Rectangle(0, 0, thePoint.X, thePoint.Y);   

    // Delete the old strokes in the thumbnail, and add the new strokes.
    panelThumb.Ink.DeleteStrokes();
    // The strokes are automatically scaled to the destination rectangle
    panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle);
    Refresh();
}

這個 Microsoft Visual Basic .NET 範例會使用 AddStrokesAtRectangle 方法從主物件 InkCollector (panelMain) 建立筆墨的複本,複製到 InkCollector 物件 (panelThumb) 中,同時維持適當的縮放比例和外觀比例。為了維持目前的縮圖面板,會在 panelMain 中加入 Stroke 事件處理常式 (panelMain_Stroke)。

 Private Sub panelMain_Stroke(ByVal sender As System.Object, _
    ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) Handles panelMain.Stroke

    'Create a bounding rectangle for panelThumb in ink space coordinates
    Dim g As Graphics = Graphics.FromHwnd(Handle)
    Dim thePoint As Point = New Point(panelThumb.Width, panelThumb.Height)
    panelMain.Renderer.PixelToInkSpace(g, thePoint)
    'Dispose of the Graphics object
    g.Dispose()
    Dim theRectangle As Rectangle = New Rectangle(0, 0, thePoint.X, thePoint.Y)

    'Delete the old strokes in the thumbnail, and add the new strokes.
    panelThumb.Ink.DeleteStrokes()
    'The strokes are automatically scaled to the destination rectangle
    panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle)
    Refresh()
End Sub

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

Ink 類別

Ink 成員

Microsoft.Ink 命名空間

Strokes