我GraphicsPath
用来画画Lines
,所以它就像Pen/Brush
工具一样Paint
public void OnMouseDown(object sender, MouseEventArgs e)
{
start = e.Location;
path.AddLine(e.Location, new Point(e.Location.X, e.Location.Y));
}
public void OnMouseMove(object sender, MouseEventArgs e)
{
end = e.Location;
path.AddLine(e.Location, new Point(e.Location.X, e.Location.Y));
}
public void OnMouseUp(object sender, MouseEventArgs e)
{
end = e.Location;
path.AddLine(e.Location, new Point(e.Location.X, e.Location.Y));
}
public void OnPaint(object sender, Graphics g)
{
g.DrawPath(pen, path);
}
我怎么会Relocate
呢,我试过Transform
方法,但它没有工作..
public void Relocate(MouseEventArgs e)
{
Matrix m = new Matrix();
m.Translate(start.X + e.X - end.X, start.Y + e.Y - end.Y, MatrixOrder.Append);
path.Transform(m);
}
那么我将如何以正确的方式做到这一点?移动整个绘制的形状?