【发布时间】:2015-08-04 02:35:27
【问题描述】:
我使用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);
}
那么我该如何以正确的方式做到这一点?移动整个绘制的形状?
【问题讨论】:
标签: c# winforms transform graphicspath