Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ControlPaint.DrawReversibleLine Method

Draws a reversible line on the screen within the specified starting and ending points and with the specified background color.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[UIPermissionAttribute(SecurityAction.LinkDemand, Window = UIPermissionWindow.AllWindows)]
public static void DrawReversibleLine(
	Point start,
	Point end,
	Color backColor
)

Parameters

start
Type: System.Drawing.Point

The starting Point of the line, in screen coordinates.

end
Type: System.Drawing.Point

The ending Point of the line, in screen coordinates.

backColor
Type: System.Drawing.Color

The Color of the background behind the line.

The backColor parameter is used to calculate the fill color of the line so that it is always visible against the background.

The results of this method can be reversed by drawing the same line again. Drawing a line using this method is similar to inverting a region of the screen, except that it provides better performance for a wider variety of colors.

The following code example demonstrates using the ControlPaint.DrawReversibleLine and Control.PointToScreen methods. To run the example, paste the following code in a form. Add a button named Button3 to the form and ensure all events are connected to their event handlers.

	// 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);
	}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.