LinearGradientBrush.ResetTransform Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает свойству Transform единичное значение.
public:
void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()
Примеры
Следующий пример кода предназначен для использования с Windows Forms, и для него требуется PaintEventArgse
OnPaint объект события . Код выполняет следующие действия.
Создает новый экземпляр LinearGradientBrush.
Рисует эллипс на экране с помощью этой кисти.
MultiplyTransform Вызывает метод для преобразования LinearGradientBrush.
Рисует эллипс на экране непосредственно под первым эллипсой с помощью преобразованной кисти.
Сбрасывает преобразование.
Рисует третий эллипс на экране под первыми двумя.
Обратите внимание, что самый нижний эллипс рисуется тот же размер, что и первый, и что из-за вызова ResetTransform метода градиент был уменьшен до соответствия.
private:
void ResetTransformExample( PaintEventArgs^ e )
{
// Create a LinearGradientBrush.
Rectangle myRect = Rectangle(20,20,200,100);
LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );
// Draw an ellipse to the screen using the LinearGradientBrush.
e->Graphics->FillEllipse( myLGBrush, myRect );
// Transform the LinearGradientBrush.
array<Point>^ transformArray = {Point(20,150),Point(400,150),Point(20,200)};
Matrix^ myMatrix = gcnew Matrix( myRect,transformArray );
myLGBrush->MultiplyTransform( myMatrix, MatrixOrder::Prepend );
// Draw a second ellipse to the screen
// using the transformed brush.
e->Graphics->FillEllipse( myLGBrush, 20, 150, 380, 50 );
// Reset the brush transform.
myLGBrush->ResetTransform();
// Draw a third ellipse to the screen using the reset brush.
e->Graphics->FillEllipse( myLGBrush, 20, 250, 200, 100 );
}
private void ResetTransformExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new LinearGradientBrush(
myRect, Color.Blue, Color.Red, 0.0f, true);
// Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, myRect);
// Transform the LinearGradientBrush.
Point[] transformArray = { new Point(20, 150),
new Point(400,150), new Point(20, 200) };
Matrix myMatrix = new Matrix(myRect, transformArray);
myLGBrush.MultiplyTransform( myMatrix, MatrixOrder.Prepend);
// Draw a second ellipse to the screen
// using the transformed brush.
e.Graphics.FillEllipse(myLGBrush, 20, 150, 380, 50);
// Reset the brush transform.
myLGBrush.ResetTransform();
// Draw a third ellipse to the screen using the reset brush.
e.Graphics.FillEllipse(myLGBrush, 20, 250, 200, 100);
}
Public Sub ResetTransformExample(ByVal e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
Color.Red, 0.0F, True)
' Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, myRect)
' Transform the LinearGradientBrush.
Dim transformArray As Point() = {New Point(20, 150), _
New Point(400, 150), New Point(20, 200)}
Dim myMatrix As New Matrix(myRect, transformArray)
myLGBrush.MultiplyTransform(myMatrix, MatrixOrder.Prepend)
' Draw a second ellipse to the screen using the transformed brush.
e.Graphics.FillEllipse(myLGBrush, 20, 150, 380, 50)
' Reset the brush transform.
myLGBrush.ResetTransform()
' Draw a third ellipse to the screen using the reset brush.
e.Graphics.FillEllipse(myLGBrush, 20, 250, 200, 100)
End Sub
Применяется к
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по