LinearGradientBrush.Clone 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立這個 LinearGradientBrush的確切複本。
public:
override System::Object ^ Clone();
public override object Clone ();
override this.Clone : unit -> obj
Public Overrides Function Clone () As Object
傳回
這個方法 LinearGradientBrush 建立,並轉換成 物件。
範例
下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgse
OnPaint 事件物件。 程式代碼會執行下列動作:
建立新的 LinearGradientBrush。
使用此筆刷將省略號繪製到螢幕。
複製 LinearGradientBrush (
clonedLGBrush
)。使用複製的筆刷,將橢圓形繪製到畫面正下方的第一個橢圓形。
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