ProgressBarRenderer.ChunkThickness 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取进度栏的单个内部格的宽度(以像素为单位)。
public:
static property int ChunkThickness { int get(); };
public static int ChunkThickness { get; }
static member ChunkThickness : int
Public Shared ReadOnly Property ChunkThickness As Integer
属性值
进度栏单个内部格的宽度(以像素为单位)。
例外
示例
下面的代码示例使用 ChunkThickness 属性来确定表示 方法绘制 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
。