Share via


ProgressBarRenderer.DrawVerticalChunks(Graphics, Rectangle) 方法

定義

繪製填入垂直進度列的一組進度列片段。

public:
 static void DrawVerticalChunks(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds);
public static void DrawVerticalChunks (System.Drawing.Graphics g, System.Drawing.Rectangle bounds);
static member DrawVerticalChunks : System.Drawing.Graphics * System.Drawing.Rectangle -> unit
Public Shared Sub DrawVerticalChunks (g As Graphics, bounds As Rectangle)

參數

g
Graphics

繪製進度列所用的 Graphics

bounds
Rectangle

Rectangle,指定要由進度列片段填入的範圍。

例外狀況

作業系統不支援視覺化樣式。

-或-

使用者已停用作業系統中的視覺化樣式。

-或-

視覺化樣式不適用於應用程式視窗的工作區。

範例

下列程式碼範例會 DrawVerticalChunks 使用事件處理常式中的 Timer.Tick 方法,繪製進度列的每個遞增。 此程式碼範例是針對 類別提供的較大範例的 ProgressBarRenderer 一部分。

    // Handle the timer tick; draw each progressively larger rectangle.
private:
    void progressTimer_Tick(Object^ myObject, EventArgs^ e)
    {
        if (ticks < NumberChunks)
        {
            Graphics^ g = this->CreateGraphics();
            ProgressBarRenderer::DrawVerticalChunks(g,
                progressBarRectangles[ticks]);
            ticks++;
        }
        else
        {
            progressTimer->Enabled = false;
        }
    }
// Handle the timer tick; draw each progressively larger rectangle.
private void progressTimer_Tick(Object myObject, EventArgs e)
{
    if (ticks < NumberChunks)
    {
        using (Graphics g = this.CreateGraphics())
        {
            ProgressBarRenderer.DrawVerticalChunks(g,
                progressBarRectangles[ticks]);
            ticks++;
        }
    }
    else
    {
        progressTimer.Enabled = false;
    }
}
' Handle the timer tick; draw each progressively larger rectangle.
Private Sub progressTimer_Tick(ByVal myObject As [Object], ByVal e As EventArgs) 
    If ticks < NumberChunks Then
        Dim g As Graphics = Me.CreateGraphics()
        Try
            ProgressBarRenderer.DrawVerticalChunks(g, progressBarRectangles(ticks))
            ticks += 1
        Finally
            g.Dispose()
        End Try
    Else
        progressTimer.Enabled = False
    End If

End Sub

備註

這個方法所繪製的每個進度列片段都會跨越 參數的 bounds 寬度。 繪製的進度列片段數目取決於 的高度 bounds ,以及 和 ChunkThicknessChunkSpaceThickness 傳回的值。

使用此方法之前,您應該先 IsSupported 確認 屬性會傳 true 回 。

適用於