首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

在picturebox中绘图时,怎么将坐标系统转换为Y轴向上为正(默认向下为正)

2012-01-07 
在picturebox中绘图时,如何将坐标系统转换为Y轴向上为正(默认向下为正)?在picturebox中绘图时,如何将坐标

在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();
}

热点排行