我正在使用GraphicsPath绘制Lines,所以它就像Paint中的Pen/Brush工具
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);
}那我怎么做才是对的呢?移动整个绘制的形状?
发布于 2015-08-04 02:53:04
你试过:
path可以通过Relocate()方法进行转换,以下内容就足够了:
矩阵=新矩阵( );matrix.Translate( offsetX,offsetY );//其中偏移量是新位置path.Transform(矩阵);//变换路径那么,不要忘记通过path重新绘制Invalidate()。
https://stackoverflow.com/questions/31799782
复制相似问题