ControlPaint.DrawReversibleLine(Point, Point, Color) 메서드

정의

화면의 지정된 범위 내에 지정된 배경색으로 복구 가능한 선을 그립니다.

public:
 static void DrawReversibleLine(System::Drawing::Point start, System::Drawing::Point end, System::Drawing::Color backColor);
public static void DrawReversibleLine (System.Drawing.Point start, System.Drawing.Point end, System.Drawing.Color backColor);
static member DrawReversibleLine : System.Drawing.Point * System.Drawing.Point * System.Drawing.Color -> unit
Public Shared Sub DrawReversibleLine (start As Point, end As Point, backColor As Color)

매개 변수

start
Point

화면 좌표로 나타낸 선의 시작 Point입니다.

end
Point

화면 좌표로 나타낸 선의 끝 Point입니다.

backColor
Color

선 뒤에 나타나는 배경의 Color입니다.

예제

다음 코드 예제에서는 사용 Control.PointToScreen 하 고 메서드를 ControlPaint.DrawReversibleLine 보여 줍니다. 예제를 실행 하는 폼에 다음 코드를 붙여넣습니다. 양식에 명명된 Button3 단추를 추가하고 모든 이벤트가 해당 이벤트 처리기에 연결되어 있는지 확인합니다.

// When the mouse hovers over Button3, two reversible lines are 
// drawn using the corner coordinates of Button3, which are first 
// converted to screen coordinates.
void Button3_MouseHover( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(0,0) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Bottom) ), SystemColors::Control );
   ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Top) ), Button3->PointToScreen( Point(Button1->ClientRectangle.Left,Button3->ClientRectangle.Bottom) ), SystemColors::Control );
}

// When the mouse moves from Button3, the reversible lines are erased by
// using the same coordinates as are used in the Button3_MouseHover method.
void Button3_MouseLeave( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(0,0) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Bottom) ), SystemColors::Control );
   ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Top) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Left,Button3->ClientRectangle.Bottom) ), SystemColors::Control );
}
// When the mouse hovers over Button3, two reversible lines are 
// drawn using the corner coordinates of Button3, which are first 
// converted to screen coordinates.
private void Button3_MouseHover(object sender, System.EventArgs e)
{
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(0, 0)), Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
    
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Top)), 
        Button3.PointToScreen(new Point(Button1.ClientRectangle.Left, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
}

// When the mouse moves from Button3, the reversible lines are erased by
// using the same coordinates as are used in the Button3_MouseHover method.
private void Button3_MouseLeave(object sender, System.EventArgs e)
{
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(0, 0)), Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
    
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Top)), 
        Button3.PointToScreen(new Point(Button3.ClientRectangle.Left,
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
}
' When the mouse hovers over Button3, two reversible lines are drawn
' using the corner coordinates of Button3, which are first 
' converted to screen coordinates.
Private Sub Button3_MouseHover(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button3.MouseHover

    ControlPaint.DrawReversibleLine(Button3.PointToScreen(New Point(0, 0)), _
    Button3.PointToScreen(New Point(Button3.ClientRectangle.Right, _
        Button3.ClientRectangle.Bottom)), SystemColors.Control)
    ControlPaint.DrawReversibleLine(Button3.PointToScreen( _
        New Point(Button3.ClientRectangle.Right, Button3.ClientRectangle.Top)), _
       Button3.PointToScreen(New Point _
            (Button1.ClientRectangle.Left, Button3.ClientRectangle.Bottom)), _
            SystemColors.Control)
End Sub

' When the mouse moves from Button3, the reversible lines are 
' erased by using the same coordinates as are used in the
' Button3_MouseHover method.
Private Sub Button3_MouseLeave(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button3.MouseLeave

    ControlPaint.DrawReversibleLine(Button3.PointToScreen(New Point(0, 0)), _
    Button3.PointToScreen(New Point(Button3.ClientRectangle.Right, _
        Button3.ClientRectangle.Bottom)), SystemColors.Control)
    ControlPaint.DrawReversibleLine(Button3.PointToScreen( _
        New Point(Button3.ClientRectangle.Right, Button3.ClientRectangle.Top)), _
       Button3.PointToScreen(New Point(Button3.ClientRectangle.Left, _
       Button3.ClientRectangle.Bottom)), SystemColors.Control)
End Sub

설명

매개 backColor 변수는 항상 배경에 표시되도록 선의 채우기 색을 계산하는 데 사용됩니다.

동일한 선을 다시 그려 이 메서드의 결과를 되돌릴 수 있습니다. 이 메서드를 사용하여 선을 그리는 것은 화면의 영역을 반전하는 것과 유사합니다. 단, 더 다양한 색에 더 나은 성능을 제공한다는 점이 다릅니다.

적용 대상

추가 정보