ProgressBarRenderer.DrawVerticalChunks(Graphics, Rectangle) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會抽取一組進度條碎片,填滿垂直進度條。
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)
參數
例外狀況
範例
以下程式碼範例使用事件處理程序中的方法DrawVerticalChunksTimer.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 高度決定,返回的值則由 ChunkSpaceThickness 和 ChunkThickness。
在使用此方法之前,您應該確認屬性是否 IsSupported 返回 true。