Renderer.Draw 方法 (IntPtr, Strokes)
在傳入本身控制代碼的裝置內容上繪製 Strokes 集合。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
<UIPermissionAttribute(SecurityAction.Demand, Window := UIPermissionWindow.SafeTopLevelWindows)> _
<SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode := True)> _
Public Sub Draw ( _
hdc As IntPtr, _
strokes As Strokes _
)
'用途
Dim instance As Renderer
Dim hdc As IntPtr
Dim strokes As Strokes
instance.Draw(hdc, strokes)
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
public void Draw(
IntPtr hdc,
Strokes strokes
)
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Name = L"FullTrust")]
[UIPermissionAttribute(SecurityAction::Demand, Window = UIPermissionWindow::SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction::Demand, UnmanagedCode = true)]
public:
void Draw(
IntPtr hdc,
Strokes^ strokes
)
/** @attribute PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust") */
/** @attribute UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.SafeTopLevelWindows) */
/** @attribute SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true) */
public void Draw(
IntPtr hdc,
Strokes strokes
)
public function Draw(
hdc : IntPtr,
strokes : Strokes
)
參數
- hdc
型別:System.IntPtr
要在其中繪製的裝置內容控制代碼。
- strokes
型別:Microsoft.Ink.Strokes
要繪製的 Strokes 集合。
備註
注意事項: |
---|
畫筆寬度會根據您使用 SetViewTransform 方法的方式適當調整。具體來說,畫筆寬度會乘以檢視轉換之行列式的平方根 (或據以調整)。
注意事項: |
---|
如果尚未明確設定畫筆寬度,則預設為 53。您必須將畫筆寬度乘以行列式的平方根,才能得出正確的週框方塊。週框方塊的高度和寬度會依這個數目的一半,朝各方向放大。 |
例如,試想畫筆寬度為 53,行列式的平方根為 50,而且週框方塊為 (0,0,1000,1000)。依據週框方塊朝各方向調整的畫筆寬度計算方式為 (53*50)/2,右邊和底部則會加一。這樣會產生週框方塊 (-1325,-1325,2326,2326)。
Renderer 物件會強制將檢視區和視窗原點設定為 0,0。任何現有的設定都會被儲存及還原,但不會被 Renderer 使用。若要執行捲動,請使用 Renderer 物件的 GetViewTransform 和 GetObjectTransform 方法。
安全性注意事項: |
---|
如果在部分信任的情況下使用,除了 InkCollector 所需的權限之外,這個方法還需要 SecurityPermissionFlag.UnmanagedCode (英文) 權限。如需安全性問題和部分信任的詳細資訊,請參閱Security and Trust。 |
範例
在這個範例中,會在與 InkOverlay 物件本身無關的 Panel (英文) 上,顯示與 InkOverlay 物件相關聯之 Ink 物件的完整 Strokes 集合。這個動作的完成是藉由呼叫 Draw 方法,將另一個裝置內容控制代碼 (與 InkOverlay 物件相關聯的不同) 傳遞至 hdc 參數。
' Access to the Ink.Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes
' get a graphics object for another panel
Using g As Graphics = Me.panelForDraw.CreateGraphics()
' get a Renderer object. We could have used
' mInkOverlay.Renderer, this is another way
Dim R As Renderer = New Renderer()
' get the handle to the device context
Dim hdc As IntPtr = g.GetHdc()
' draw the strokes
R.Draw(hdc, allStrokes)
' release the handle to the device context
g.ReleaseHdc(hdc)
End Using
End Using
// Access to the Ink.Strokes property returns a copy of the Strokes object.
// This copy must be implicitly (via using statement) or explicitly
// disposed of in order to avoid a memory leak.
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
// get a graphics object for another panel
using (Graphics g = this.panelForDraw.CreateGraphics())
{
// get a Renderer object. We could have used
// mInkOverlay.Renderer, this is another way
Renderer R = new Renderer();
// get the handle to the device context
IntPtr hdc = g.GetHdc();
// draw the strokes
R.Draw(hdc, allStrokes);
// release the handle to the device context
g.ReleaseHdc();
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0