Graphics.TranslateClip 方法
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
按水平方向和垂直方向的指定量转换此 Graphics 的剪辑区域。
TranslateClip(Int32, Int32) |
按水平方向和垂直方向的指定量转换此 Graphics 的剪辑区域。 |
TranslateClip(Single, Single) |
按水平方向和垂直方向的指定量转换此 Graphics 的剪辑区域。 |
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
按水平方向和垂直方向的指定量转换此 Graphics 的剪辑区域。
public:
void TranslateClip(int dx, int dy);
C#
public void TranslateClip (int dx, int dy);
member this.TranslateClip : int * int -> unit
Public Sub TranslateClip (dx As Integer, dy As Integer)
参数
- dx
- Int32
翻译的 x 坐标。
- dy
- Int32
翻译的 y 坐标。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
为剪裁区域创建一个矩形。
将剪辑区域设置为矩形。
按矢量(50,50)转换剪辑区域。
用纯黑色画笔填充大矩形。
结果是已转换的小型黑色矩形。
public:
void TranslateClipInt( PaintEventArgs^ e )
{
// Create rectangle for clipping region.
Rectangle clipRect = Rectangle(0,0,100,100);
// Set clipping region of graphics to rectangle.
e->Graphics->SetClip( clipRect );
// Translate clipping region.
int dx = 50;
int dy = 50;
e->Graphics->TranslateClip( dx, dy );
// Fill rectangle to demonstrate translated clip region.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
}
C#
private void TranslateClipInt(PaintEventArgs e)
{
// Create rectangle for clipping region.
Rectangle clipRect = new Rectangle(0, 0, 100, 100);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Translate clipping region.
int dx = 50;
int dy = 50;
e.Graphics.TranslateClip(dx, dy);
// Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub TranslateClipInt(ByVal e As PaintEventArgs)
' Create rectangle for clipping region.
Dim clipRect As New Rectangle(0, 0, 100, 100)
' Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect)
' Translate clipping region.
Dim dx As Integer = 50
Dim dy As Integer = 50
e.Graphics.TranslateClip(dx, dy)
' Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
End Sub
适用于
.NET 9 和其他版本
产品 | 版本 |
---|---|
.NET | 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
按水平方向和垂直方向的指定量转换此 Graphics 的剪辑区域。
public:
void TranslateClip(float dx, float dy);
C#
public void TranslateClip (float dx, float dy);
member this.TranslateClip : single * single -> unit
Public Sub TranslateClip (dx As Single, dy As Single)
参数
- dx
- Single
翻译的 x 坐标。
- dy
- Single
翻译的 y 坐标。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
为剪裁区域创建一个矩形。
将剪辑区域设置为矩形。
按矢量(50.0F、50.0F)转换剪辑区域。
用纯黑色画笔填充大矩形。
结果是已转换的小型黑色矩形。
public:
void TranslateClipFloat( PaintEventArgs^ e )
{
// Create rectangle for clipping region.
RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);
// Set clipping region of graphics to rectangle.
e->Graphics->SetClip( clipRect );
// Translate clipping region.
float dx = 50.0F;
float dy = 50.0F;
e->Graphics->TranslateClip( dx, dy );
// Fill rectangle to demonstrate translated clip region.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
}
C#
private void TranslateClipFloat(PaintEventArgs e)
{
// Create rectangle for clipping region.
RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Translate clipping region.
float dx = 50.0F;
float dy = 50.0F;
e.Graphics.TranslateClip(dx, dy);
// Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub TranslateClipFloat(ByVal e As PaintEventArgs)
' Create rectangle for clipping region.
Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)
' Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect)
' Translate clipping region.
Dim dx As Single = 50.0F
Dim dy As Single = 50.0F
e.Graphics.TranslateClip(dx, dy)
' Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
End Sub
适用于
.NET 9 和其他版本
产品 | 版本 |
---|---|
.NET | 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |