ProgressBarRenderer.ChunkSpaceThickness 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得進度列的每一個內部片段之間的間距寬度 (以像素為單位)。
public:
static property int ChunkSpaceThickness { int get(); };
public static int ChunkSpaceThickness { get; }
member this.ChunkSpaceThickness : int
Public Shared ReadOnly Property ChunkSpaceThickness As Integer
屬性值
進度列的每一個內部片段之間的間距寬度 (以像素為單位)。
例外狀況
範例
下列程式碼範例會使用 ChunkSpaceThickness 屬性來判斷每個矩形的大小,代表 方法所 DrawVerticalChunks 繪製進度列的遞增。 此程式碼範例是針對 類別提供的較大範例的 ProgressBarRenderer 一部分。
// Initialize the rectangles used to paint the states of the
// progress bar.
private:
void SetupProgressBar()
{
if (!ProgressBarRenderer::IsSupported)
{
return;
}
// Determine the size of the progress bar frame.
this->Size = System::Drawing::Size(ClientRectangle.Width,
(NumberChunks * (ProgressBarRenderer::ChunkThickness +
(2 * ProgressBarRenderer::ChunkSpaceThickness))) + 6);
// Initialize the rectangles to draw each step of the
// progress bar.
progressBarRectangles = gcnew array<Rectangle>(NumberChunks);
for (int i = 0; i < NumberChunks; i++)
{
// Use the thickness defined by the current visual style
// to calculate the height of each rectangle. The size
// adjustments ensure that the chunks do not paint over
// the frame.
int filledRectangleHeight =
((i + 1) * (ProgressBarRenderer::ChunkThickness +
(2 * ProgressBarRenderer::ChunkSpaceThickness)));
progressBarRectangles[i] = Rectangle(
ClientRectangle.X + 3,
ClientRectangle.Y + ClientRectangle.Height - 3
- filledRectangleHeight,
ClientRectangle.Width - 6,
filledRectangleHeight);
}
}
// Initialize the rectangles used to paint the states of the
// progress bar.
private void SetupProgressBar()
{
if (!ProgressBarRenderer.IsSupported)
{
return;
}
// Determine the size of the progress bar frame.
this.Size = new Size(ClientRectangle.Width,
(NumberChunks) * (ProgressBarRenderer.ChunkThickness +
(2 * ProgressBarRenderer.ChunkSpaceThickness)) + 6);
// Initialize the rectangles to draw each step of the
// progress bar.
progressBarRectangles = new Rectangle[NumberChunks];
for (int i = 0; i < NumberChunks; i++)
{
// Use the thickness defined by the current visual style
// to calculate the height of each rectangle. The size
// adjustments ensure that the chunks do not paint over
// the frame.
int filledRectangleHeight =
((i + 1) * (ProgressBarRenderer.ChunkThickness +
(2 * ProgressBarRenderer.ChunkSpaceThickness)));
progressBarRectangles[i] = new Rectangle(
ClientRectangle.X + 3,
ClientRectangle.Y + ClientRectangle.Height - 3
- filledRectangleHeight,
ClientRectangle.Width - 6,
filledRectangleHeight);
}
}
' Initialize the rectangles used to paint the states of the
' progress bar.
Private Sub SetupProgressBar()
If Not ProgressBarRenderer.IsSupported Then
Return
End If
' Determine the size of the progress bar frame.
Me.Size = New Size(ClientRectangle.Width, NumberChunks *(ProgressBarRenderer.ChunkThickness + 2 * ProgressBarRenderer.ChunkSpaceThickness) + 6)
' Initialize the rectangles to draw each step of the
' progress bar.
progressBarRectangles = New Rectangle(NumberChunks) {}
Dim i As Integer
For i = 0 To NumberChunks
' Use the thickness defined by the current visual style
' to calculate the height of each rectangle. The size
' adjustments ensure that the chunks do not paint over
' the frame.
Dim filledRectangleHeight As Integer = (i + 1) _
*(ProgressBarRenderer.ChunkThickness + 2 * ProgressBarRenderer.ChunkSpaceThickness)
progressBarRectangles(i) = New Rectangle(ClientRectangle.X + 3, _
ClientRectangle.Y + ClientRectangle.Height - 3 - filledRectangleHeight, _
ClientRectangle.Width - 6, filledRectangleHeight)
Next i
End Sub
備註
這個值是由作業系統的目前視覺化樣式所決定。
存取這個屬性之前,您應該先 IsSupported 確認屬性傳 true
回 。