LinearGradientBrush.Clone 方法
创建此 LinearGradientBrush 的一个精确副本。
**命名空间:**System.Drawing.Drawing2D
**程序集:**System.Drawing(在 system.drawing.dll 中)
语法
声明
Public Overrides Function Clone As Object
用法
Dim instance As LinearGradientBrush
Dim returnValue As Object
returnValue = instance.Clone
public override Object Clone ()
public:
virtual Object^ Clone () override
public Object Clone ()
public override function Clone () : Object
返回值
该方法创建的、强制转换为对象的 LinearGradientBrush。
示例
下面的代码示例适用于 Windows 窗体,它需要 PaintEventArgse,一个 OnPaint 事件对象。代码执行下列操作:
创建一个新的 LinearGradientBrush。
使用此画笔向屏幕绘制一个椭圆。
克隆 LinearGradientBrush(clonedLGBrush)。
使用克隆后的画笔直接在屏幕的第一个椭圆下面绘制一个椭圆。
Public Sub CloneExample(ByVal e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim x As Integer = 20
Dim y As Integer = 20
Dim h As Integer = 100
Dim w As Integer = 200
Dim myRect As New Rectangle(x, y, w, h)
Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
Color.Aquamarine, 45.0F, True)
' Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, x, y, w, h)
' Clone the LinearGradientBrush.
Dim clonedLGBrush As LinearGradientBrush = _
CType(myLGBrush.Clone(), LinearGradientBrush)
' Justify the left edge of the gradient with the left edge of the
' ellipse.
clonedLGBrush.TranslateTransform(-100.0F, 0.0F)
' Draw a second ellipse to the screen using the cloned HBrush.
y = 150
e.Graphics.FillEllipse(clonedLGBrush, x, y, w, h)
End Sub
private void CloneExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
int x=20, y=20, h=100, w=200;
Rectangle myRect = new Rectangle(x, y, w, h);
LinearGradientBrush myLGBrush = new LinearGradientBrush(
myRect, Color.Blue, Color.Aquamarine, 45.0f, true);
// Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, x, y, w, h);
// Clone the LinearGradientBrush.
LinearGradientBrush clonedLGBrush =
(LinearGradientBrush)myLGBrush.Clone();
// Justify the left edge of the gradient with the
// left edge of the ellipse.
clonedLGBrush.TranslateTransform(-100.0f, 0.0f);
// Draw a second ellipse to the screen using the cloned HBrush.
y=150;
e.Graphics.FillEllipse(clonedLGBrush, x, y, w, h);
}
private:
void CloneExample( PaintEventArgs^ e )
{
// Create a LinearGradientBrush.
int x = 20,y = 20,h = 100,w = 200;
Rectangle myRect = Rectangle(x,y,w,h);
LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Aquamarine,45.0f,true );
// Draw an ellipse to the screen using the LinearGradientBrush.
e->Graphics->FillEllipse( myLGBrush, x, y, w, h );
// Clone the LinearGradientBrush.
LinearGradientBrush^ clonedLGBrush = dynamic_cast<LinearGradientBrush^>(myLGBrush->Clone());
// Justify the left edge of the gradient with the
// left edge of the ellipse.
clonedLGBrush->TranslateTransform( -100.0f, 0.0f );
// Draw a second ellipse to the screen using the cloned HBrush.
y = 150;
e->Graphics->FillEllipse( clonedLGBrush, x, y, w, h );
}
private void CloneExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
int x = 20;
int y = 20;
int h = 100;
int w = 200;
Rectangle myRect = new Rectangle(x, y, w, h);
LinearGradientBrush myLGBrush = new LinearGradientBrush(myRect,
Color.get_Blue(), Color.get_Aquamarine(), 45, true);
// Draw an ellipse to the screen using the LinearGradientBrush.
e.get_Graphics().FillEllipse(myLGBrush, x, y, w, h);
// Clone the LinearGradientBrush.
LinearGradientBrush clonedLGBrush = ((LinearGradientBrush)(
myLGBrush.Clone()));
// Justify the left edge of the gradient with the
// left edge of the ellipse.
clonedLGBrush.TranslateTransform(-100, 0);
// Draw a second ellipse to the screen using the cloned HBrush.
y = 150;
e.get_Graphics().FillEllipse(clonedLGBrush, x, y, w, h);
} //CloneExample
平台
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
LinearGradientBrush 类
LinearGradientBrush 成员
System.Drawing.Drawing2D 命名空间