SystemPens 클래스
.NET Framework 3.5
업데이트: 2007년 11월
SystemPens 클래스의 각 속성은 Windows 표시 요소의 색인 1픽셀 너비의 Pen입니다.
어셈블리: System.Drawing(System.Drawing.dll)
다음 코드 예제에서는 이들 형식에 대해 정의된 오버로드된 연산자 중 몇 가지를 사용하여 포인트와 크기를 만듭니다. 이 예제에서는 SystemPens 클래스를 사용하는 방법도 보여 줍니다.
이 예제는 Windows Forms과 함께 사용해야 합니다. subtractButton이라는 Button이 포함된 폼을 만든 다음 폼에 코드를 붙여넣은 후 폼의 Paint 이벤트 처리 메서드에서 CreatePointsAndSizes 메서드를 호출하고 e를 PaintEventArgs로 전달합니다.
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 void CreatePointsAndSizes(PaintEventArgs e)
{
// Create the starting point.
Point startPoint = new Point(subtractButton.get_Size());
// Use the addition operator to get the end point.
Point endPoint = Point.op_Addition(startPoint, new Size(140, 150));
// Draw a line between the points.
e.get_Graphics().DrawLine(SystemPens.get_Highlight(), startPoint,
endPoint);
// Convert the starting point to a size and compare it to the
// subtractButton size.
Size buttonSize = new Size(startPoint);
if (buttonSize.Equals(subtractButton.get_Size())) {
// If the sizes are equal, tell the user.
e.get_Graphics().DrawString("The sizes are equal.",
new Font(this.get_Font(), FontStyle.Italic),
Brushes.get_Indigo(), 10, 65);
}
} //CreatePointsAndSizes
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.