LinearGradientBrush.Clone Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an exact copy of this LinearGradientBrush.
public:
override System::Object ^ Clone();
public override object Clone ();
override this.Clone : unit -> obj
Public Overrides Function Clone () As Object
Returns
The LinearGradientBrush this method creates, cast as an object.
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, an OnPaint event object. The code performs the following actions:
Creates a new LinearGradientBrush.
Draws an ellipse to the screen using this brush.
Clones the LinearGradientBrush (
clonedLGBrush
).Draws an ellipse to the screen directly below the first ellipse, using the cloned brush.
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, 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);
}
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
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기