SystemPens 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
SystemPens 类的每个属性都是一个Pen,它是Windows显示元素的颜色,宽度为 1 像素。
public ref class SystemPens abstract sealed
public ref class SystemPens sealed
public static class SystemPens
public sealed class SystemPens
type SystemPens = class
Public Class SystemPens
Public NotInheritable Class SystemPens
- 继承
-
SystemPens
示例
下面的代码示例使用为这些类型定义的多个重载运算符创建点和大小。 它还演示如何使用该 SystemPens 类。
此示例旨在与 Windows 窗体一起使用。 创建包含命名的ButtonsubtractButton窗体。 将代码粘贴到窗体中,并从窗体的事件CreatePointsAndSizes处理方法中调用Paint该方法,并作为传递方式e传递PaintEventArgs。
void CreatePointsAndSizes( PaintEventArgs^ e )
{
// Create the starting point.
Point startPoint = Point(subtractButton->Size);
// Use the addition operator to get the end point.
Point endPoint = startPoint + System::Drawing::Size( 140, 150 );
// Draw a line between the points.
e->Graphics->DrawLine( SystemPens::Highlight, startPoint, endPoint );
// Convert the starting point to a size and compare it to the
// subtractButton size.
System::Drawing::Size buttonSize = (System::Drawing::Size)startPoint;
if ( buttonSize == subtractButton->Size )
{
e->Graphics->DrawString( "The sizes are equal.", gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), Brushes::Indigo, 10.0F, 65.0F );
}
}
private void CreatePointsAndSizes(PaintEventArgs e)
{
// Create the starting point.
Point startPoint = new Point(subtractButton.Size);
// Use the addition operator to get the end point.
Point endPoint = startPoint + new Size(140, 150);
// Draw a line between the points.
e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint);
// Convert the starting point to a size and compare it to the
// subtractButton size.
Size buttonSize = (Size)startPoint;
if (buttonSize == subtractButton.Size)
// If the sizes are equal, tell the user.
{
e.Graphics.DrawString("The sizes are equal.",
new Font(this.Font, FontStyle.Italic),
Brushes.Indigo, 10.0F, 65.0F);
}
}
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)
' Create the starting point.
Dim startPoint As New Point(subtractButton.Size)
' Use the addition operator to get the end point.
Dim endPoint As Point = Point.op_Addition(startPoint, _
New Size(140, 150))
' Draw a line between the points.
e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)
' Convert the starting point to a size and compare it to the
' subtractButton size.
Dim buttonSize As Size = Point.op_Explicit(startPoint)
If (Size.op_Equality(buttonSize, subtractButton.Size)) Then
' If the sizes are equal, tell the user.
e.Graphics.DrawString("The sizes are equal.", _
New Font(Me.Font, FontStyle.Italic), _
Brushes.Indigo, 10.0F, 65.0F)
End If
End Sub
注解
注释
在 .NET 6 及更高版本中,包含此类型的 System.Drawing.Common 包 仅支持在 Windows 操作系统上运行。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 仅在 Windows 上支持的 System.Drawing.Common。
属性
| 名称 | 说明 |
|---|---|
| ActiveBorder |
Pen获取活动窗口边框的颜色。 |
| ActiveCaption |
获取一个 Pen 是活动窗口标题栏背景的颜色。 |
| ActiveCaptionText |
Pen获取活动窗口标题栏中文本的颜色。 |
| AppWorkspace |
Pen获取应用程序工作区的颜色。 |
| ButtonFace |
获取一个 Pen 是三维元素的人脸颜色。 |
| ButtonHighlight |
获取一个 Pen 是三维元素的突出显示颜色。 |
| ButtonShadow |
获取一个 Pen 是三维元素的阴影颜色。 |
| Control |
获取一个 Pen 是三维元素的人脸颜色。 |
| ControlDark |
获取一个 Pen 是三维元素的阴影颜色。 |
| ControlDarkDark |
获取一个 Pen 是三维元素的深影颜色。 |
| ControlLight |
获取一个 Pen 是三维元素的浅色。 |
| ControlLightLight |
获取一个 Pen 是三维元素的突出显示颜色。 |
| ControlText |
获取一个 Pen 是三维元素中文本的颜色。 |
| Desktop |
获取一个 Pen 是 Windows 桌面的颜色。 |
| GradientActiveCaption |
Pen获取活动窗口标题栏的颜色渐变中最浅的颜色。 |
| GradientInactiveCaption |
Pen获取非活动窗口标题栏的颜色渐变中最浅的颜色。 |
| GrayText |
获取一个 Pen 是灰色文本的颜色。 |
| Highlight |
获取一个 Pen 是选定项背景的颜色。 |
| HighlightText |
获取一个 Pen ,它是选定项的文本的颜色。 |
| HotTrack |
Pen获取用于指定热跟踪项的颜色。 |
| InactiveBorder |
获取一个 Pen 是非活动窗口边框的颜色。 |
| InactiveCaption |
获取一个 Pen 是非活动窗口标题标题的颜色。 |
| InactiveCaptionText |
获取一个 Pen 是非活动窗口标题栏中文本的颜色。 |
| Info |
获取一个 Pen 是工具提示背景的颜色。 |
| InfoText |
获取一个 Pen 是工具提示文本的颜色。 |
| Menu |
获取一个 Pen 是菜单背景的颜色。 |
| MenuBar |
获取一个 Pen 是菜单栏背景的颜色。 |
| MenuHighlight |
获取一个 Pen 颜色,该颜色用于在菜单显示为平面菜单时突出显示菜单项。 |
| MenuText |
获取一个 Pen 是菜单文本的颜色。 |
| ScrollBar |
获取一个 Pen 是滚动条背景的颜色。 |
| Window |
获取一个 Pen 是窗口工作区中背景的颜色。 |
| WindowFrame |
Pen获取窗口框架的颜色。 |
| WindowText |
获取一个 Pen ,它是窗口工作区中文本的颜色。 |
方法
| 名称 | 说明 |
|---|---|
| FromSystemColor(Color) |