ProgressBarRenderer.ChunkThickness Свойство

Определение

Возвращает ширину (в пикселях) отдельного внутреннего элемента индикатора выполнения.

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.

Применяется к