日期:2014-05-20  浏览次数:20830 次

在picturebox中绘图时,如何将坐标系统转换为Y轴向上为正(默认向下为正)?
在picturebox中绘图时,如何将坐标系统转换为Y轴向上为正(默认向下为正)?好象要用到metrix类,但不知道具体怎么使用,请高人指点.

------解决方案--------------------
试试如下的代码:
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
TransformPointsPoint(g);
}

public void TransformPointsPoint(Graphics g)
{
int offset = 10;
Matrix myMatrix = new Matrix(1, 0, 0, -1, 0, 0);
g.Transform = myMatrix;
g.TranslateTransform(this.ClientRectangle.Left + offset, this.ClientRectangle.Bottom - offset, MatrixOrder.Append);
using (Pen pen = new Pen(this.ForeColor, 3))
{
pen.SetLineCap(LineCap.Round, LineCap.ArrowAnchor, DashCap.Triangle);
//Xdir
g.DrawLine(pen, 0, 0, this.ClientRectangle.Right - offset, 0);
//Ydir
g.DrawLine(pen, 0, 0, 0, this.ClientRectangle.Bottom - offset);
//line example
g.DrawLine(SystemPens.ControlText, 0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom);
//Point mp = PointToClient(MousePosition);
//g.DrawRectangle(SystemPens.ControlText, mp.X, mp.Y, 5, 5);
}
g.ResetTransform();
}