ControlPaint.DrawReversibleLine(Point, Point, Color) Méthode

Définition

Dessine une ligne réversible à l'écran entre les points de départ et de fin spécifiés et avec la couleur d'arrière-plan spécifiée.

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)

Paramètres

start
Point

Point de départ de la ligne, en coordonnées d'écran.

end
Point

Point de fin de la ligne, en coordonnées d'écran.

backColor
Color

Color de l'arrière-plan de la ligne.

Exemples

L’exemple de code suivant illustre l’utilisation des méthodes et Control.PointToScreen des ControlPaint.DrawReversibleLine méthodes. Pour exécuter l’exemple, collez le code suivant dans un formulaire. Ajoutez un bouton nommé Button3 au formulaire et vérifiez que tous les événements sont connectés à leurs gestionnaires d’événements.

// 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

Remarques

Le backColor paramètre est utilisé pour calculer la couleur de remplissage de la ligne afin qu’il soit toujours visible sur l’arrière-plan.

Les résultats de cette méthode peuvent être inversés en dessinant à nouveau la même ligne. Dessiner une ligne à l’aide de cette méthode est similaire à l’inverse d’une région de l’écran, sauf qu’elle offre de meilleures performances pour une plus grande variété de couleurs.

S’applique à

Voir aussi