Freigeben über


ControlPaint.DrawReversibleLine-Methode

Zeichnet eine umkehrbare Linie auf dem Bildschirm zwischen den angegebenen Start- und Endpunkten und mit der angegebenen Hintergrundfarbe.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Shared Sub DrawReversibleLine ( _
    start As Point, _
    end As Point, _
    backColor As Color _
)
'Usage
Dim start As Point
Dim end As Point
Dim backColor As Color

ControlPaint.DrawReversibleLine(start, end, backColor)
public static void DrawReversibleLine (
    Point start,
    Point end,
    Color backColor
)
public:
static void DrawReversibleLine (
    Point start, 
    Point end, 
    Color backColor
)
public static void DrawReversibleLine (
    Point start, 
    Point end, 
    Color backColor
)
public static function DrawReversibleLine (
    start : Point, 
    end : Point, 
    backColor : Color
)

Parameter

  • start
    Der Start-Point der Linie in Bildschirmkoordinaten.
  • end
    Der End-Point der Linie in Bildschirmkoordinaten.
  • backColor
    Die Color des Hintergrunds hinter der Linie.

Hinweise

Mit dem backColor-Parameter wird die Füllfarbe der Linie berechnet, sodass diese sich immer vom Hintergrund abhebt.

Die Ergebnisse dieser Methode sind umkehrbar, indem die gleiche Linie erneut gezeichnet wird. Das Zeichnen einer Linie mit dieser Methode ähnelt dem Umkehren eines Bildschirmbereichs, gewährleistet jedoch eine bessere Leistung bei einer größeren Anzahl von Farben.

Beispiel

Im folgenden Codebeispiel wird die Verwendung der ControlPaint.DrawReversibleLine-Methode und der Control.PointToScreen-Methode veranschaulicht. Fügen Sie zum Ausführen des Beispiels den folgenden Code in ein Formular ein. Fügen Sie dem Formular eine Schaltfläche mit dem Namen Button3 hinzu, und stellen Sie sicher, dass alle Ereignisse mit den entsprechenden Ereignishandlern verbunden sind.

' 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
// 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.
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.get_ClientRectangle().
        get_Right(), button3.get_ClientRectangle().get_Bottom())), 
        SystemColors.get_Control());

    ControlPaint.DrawReversibleLine(button3.PointToScreen(
        new Point(button3.get_ClientRectangle().get_Right(),
        button3.get_ClientRectangle().get_Top())), 
        button3.PointToScreen(new Point(
        button1.get_ClientRectangle().get_Left(), 
        button3.get_ClientRectangle().get_Bottom())), 
        SystemColors.get_Control());
} //button3_MouseHover

// 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.get_ClientRectangle().get_Right(),
        button3.get_ClientRectangle().get_Bottom())), 
        SystemColors.get_Control());

    ControlPaint.DrawReversibleLine(button3.PointToScreen(
        new Point(button3.get_ClientRectangle().get_Right(), 
        button3.get_ClientRectangle().get_Top())), 
        button3.PointToScreen(new Point(
        button3.get_ClientRectangle().get_Left(), 
        button3.get_ClientRectangle().get_Bottom())), 
        SystemColors.get_Control());
} //button3_MouseLeave

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ControlPaint-Klasse
ControlPaint-Member
System.Windows.Forms-Namespace
FrameStyle