Size.Subtract(Size, Size) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
static System::Drawing::Size Subtract(System::Drawing::Size sz1, System::Drawing::Size sz2);
public static System.Drawing.Size Subtract (System.Drawing.Size sz1, System.Drawing.Size sz2);
static member Subtract : System.Drawing.Size * System.Drawing.Size -> System.Drawing.Size
Public Shared Function Subtract (sz1 As Size, sz2 As Size) As Size
参数
返回
一个 Size 结构,它是该减法运算的结果。
示例
下面的代码示例演示如何使用 Subtract 方法。 若要运行此示例,请将其粘贴到 Windows 窗体中。 处理窗体的 Paint 事件,并从Paint事件处理方法调用 SubtractSizes
方法,作为 e
PaintEventArgs传递。
private void SubtractSizes(PaintEventArgs e)
{
Size size1 = new Size(100, 100);
Size size2 = new Size(50, 50);
e.Graphics.DrawRectangle(Pens.Black, new Rectangle(new Point(10, 10), size1));
size1 = Size.Subtract(size1, size2);
e.Graphics.DrawRectangle(Pens.Red, new Rectangle(new Point(10, 10), size1));
}
Private Sub SubtractSizes(ByVal e As PaintEventArgs)
Dim size1 As New Size(100, 100)
Dim size2 As New Size(50, 50)
e.Graphics.DrawRectangle(Pens.Black, _
New Rectangle(New Point(10, 10), size1))
size1 = System.Drawing.Size.Subtract(size1, size2)
e.Graphics.DrawRectangle(Pens.Red, _
New Rectangle(New Point(10, 10), size1))
End Sub