窗口或者控件的默认坐标原点是左上角(x轴向右为正,y轴向下为正)
我现在想实现坐标原点放到左下角((x轴向右为正,y轴向上为正),
在这个坐标的基础上在Form上画一个圆,如何实现?谢谢!另外什么是 world coodinate(世界坐标),page coodinate(页面坐标),device coodinate(设备坐标),page coodinate是不是就是指的form(或者panel)上的坐标系统

解决方案 »

  1.   

    Sample code as follows:
    Graphics g = this.CreateGraphics();
    PointF Pcenter=new PointF( this.ClientSize.Width/2,
    this.ClientSize.Height/2);
    g.TranslateTransform( Pcenter.X, Pcenter.Y );
    g.RotateTransform( -90 );//Top-left point translate to bottom-left point
    g.TranslateTransform( -Pcenter.X, -Pcenter.Y );
    g.DrawRectangle( new Pen( Color.Red ), 20,20, 100,100 );//Draw image here
    g.ResetTransform();
      

  2.   

    问题一:如何自定义坐标系统!实现原点在左下角,x轴向右为正,y轴向上为正;问题二:如果设定g.PageUnit的单位是inch的话,如果2个点的坐标(10,20),(30,30),单位为英寸
            请问如何在form上把这两点之间的线段画出来
      

  3.   

    useing matrix
    Matrix myMatrix = new Matrix(1, 0, 0, -1, 0, 0);
    e.Graphics.Transform = myMatrix;
    e.Graphics.TranslateTransform( 0,300, System.Drawing.Drawing2D.MatrixOrder.Append );
    GraphicsPath myGraphicsPath = new GraphicsPath();
    Rectangle myRectangle = new Rectangle(0, 0, 60, 60);
    Rectangle rect1 = new Rectangle( 0,0 ,30 , 200);
    GraphicsPath gp2 = new GraphicsPath();
    gp2.AddRectangle( rect1 );
    myGraphicsPath.AddRectangle(myRectangle);
    System.Drawing.Brush mySolidBrush1 = System.Drawing.Brushes.Red ;
    e.Graphics.FillPath( mySolidBrush1, myGraphicsPath);
    e.Graphics.FillPath( Brushes.Blue , gp2 );
      

  4.   

    useing matrix
    Matrix myMatrix = new Matrix(1, 0, 0, -1, 0, 0);
    e.Graphics.Transform = myMatrix;
    e.Graphics.TranslateTransform( 0,300, System.Drawing.Drawing2D.MatrixOrder.Append );这个是可以转换坐标,但是绘制处理的字符串怎么倒过来了,有那位朋友知道怎么解决?
      

  5.   

    protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
                Graphics g = e.Graphics;
                g.PageScale = 25.4f / 96;
                g.PageUnit = GraphicsUnit.Millimeter;
                Matrix matrix = new Matrix(1, 0, 0, -1, 0, 0);
                g.Transform = matrix;
                g.TranslateTransform(0, this.Height,  System.Drawing.Drawing2D.MatrixOrder.Append);
                 
                g.DrawLine(Pens.Red, 0, 0, 100, 100);
                g.DrawString("ABCDEFG", new Font("Verdana", 20, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.White, 0, 0);        }
            protected override void OnMouseDown(MouseEventArgs e)
            {
                base.OnMouseDown(e);
                MessageBox.Show(e.X.ToString() + "--" + e.Y.ToString());
            }对话框显示的还是以左上角为原点的坐标系,和我想象的不一样! 着急!