VisualStyleRenderer.GetPartSize Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает значение указанного свойства размера текущей части визуального стиля.
Перегрузки
| Имя. | Описание |
|---|---|
| GetPartSize(IDeviceContext, ThemeSizeType) |
Возвращает значение указанного свойства размера текущей части визуального стиля. |
| GetPartSize(IDeviceContext, Rectangle, ThemeSizeType) |
Возвращает значение указанного свойства размера текущей части визуального стиля, используя указанные границы рисования. |
GetPartSize(IDeviceContext, ThemeSizeType)
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
Возвращает значение указанного свойства размера текущей части визуального стиля.
public:
System::Drawing::Size GetPartSize(System::Drawing::IDeviceContext ^ dc, System::Windows::Forms::VisualStyles::ThemeSizeType type);
public System.Drawing.Size GetPartSize(System.Drawing.IDeviceContext dc, System.Windows.Forms.VisualStyles.ThemeSizeType type);
member this.GetPartSize : System.Drawing.IDeviceContext * System.Windows.Forms.VisualStyles.ThemeSizeType -> System.Drawing.Size
Public Function GetPartSize (dc As IDeviceContext, type As ThemeSizeType) As Size
Параметры
Эта IDeviceContext операция будет использоваться.
- type
- ThemeSizeType
Одно из ThemeSizeType значений, указывающее, какое значение размера необходимо получить для части.
Возвращаемое значение
Значение Size , содержащее размер, указанный type параметром для текущей части визуального стиля.
Исключения
dc равно null.
prop не является одним из значений ThemeSizeType .
Примеры
В следующем примере кода показано, как использовать GetPartSize(IDeviceContext, ThemeSizeType) метод в пользовательском элементе управления для получения размеров строки заголовка окна, кнопки закрытия , границ и дескриптора размера, заданного визуальным стилем. Эти размеры используются для вычисления размеров Rectangle объектов, используемых для рисования VisualStyleElement объектов, представляющих эти части окна. Этот пример кода является частью более крупного примера, предоставленного для VisualStyleRenderer обзора класса.
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private:
void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application::RenderWithVisualStyles)
{
return;
}
Graphics^ g = this->CreateGraphics();
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer->GetPartSize(g, ThemeSizeType::True);
closeButtonOffset =
renderer->GetPoint(PointProperty::Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer->GetPartSize(g,
ThemeSizeType::True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer->GetPartSize(g,
ThemeSizeType::True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer->GetPartSize(g,
ThemeSizeType::True);
}
}
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application.RenderWithVisualStyles)
{
return;
}
using (Graphics g = this.CreateGraphics())
{
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer.GetPartSize(g, ThemeSizeType.True);
closeButtonOffset =
renderer.GetPoint(PointProperty.Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer.GetPartSize(g,
ThemeSizeType.True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer.GetPartSize(g,
ThemeSizeType.True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer.GetPartSize(g,
ThemeSizeType.True);
}
}
}
' Get the sizes and offsets for the window parts as specified
' by the visual style.
Private Sub GetPartDetails()
' Do nothing further if visual styles are not enabled.
If Not Application.RenderWithVisualStyles Then
Return
End If
Using g As Graphics = Me.CreateGraphics()
' Get the size and offset of the close button.
If SetRenderer(windowElements("windowClose")) Then
closeButtonSize = _
renderer.GetPartSize(g, ThemeSizeType.True)
closeButtonOffset = _
renderer.GetPoint(PointProperty.Offset)
End If
' Get the height of the window caption.
If SetRenderer(windowElements("windowCaption")) Then
captionHeight = renderer.GetPartSize(g, _
ThemeSizeType.True).Height
End If
' Get the thickness of the left, bottom, and right
' window frame.
If SetRenderer(windowElements("windowLeft")) Then
frameThickness = renderer.GetPartSize(g, _
ThemeSizeType.True).Width
End If
' Get the size of the resizing gripper.
If SetRenderer(windowElements("statusGripper")) Then
gripperSize = renderer.GetPartSize(g, _
ThemeSizeType.True)
End If
End Using
End Sub
Комментарии
Как правило, только True значения и Minimum значения должны использоваться для type параметра этого метода.
Применяется к
GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
- Исходный код:
- VisualStyleRenderer.cs
Возвращает значение указанного свойства размера текущей части визуального стиля, используя указанные границы рисования.
public:
System::Drawing::Size GetPartSize(System::Drawing::IDeviceContext ^ dc, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::ThemeSizeType type);
public System.Drawing.Size GetPartSize(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.ThemeSizeType type);
member this.GetPartSize : System.Drawing.IDeviceContext * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.ThemeSizeType -> System.Drawing.Size
Public Function GetPartSize (dc As IDeviceContext, bounds As Rectangle, type As ThemeSizeType) As Size
Параметры
Эта IDeviceContext операция будет использоваться.
- type
- ThemeSizeType
Одно из ThemeSizeType значений, указывающее, какое значение размера необходимо получить для части.
Возвращаемое значение
Значение Size , содержащее размер, указанный type параметром для текущей части визуального стиля.
Исключения
dc равно null.
prop не является одним из значений ThemeSizeType .