Best Way To Convert From Screen Coords To My Own
-
Hi I have a simple WinForm I've created. With the following code: ////////////////////////////////////////////////////////////// public void DrawXYAxes(Graphics g) { g.DrawLine(axisPen, xIndent, yIndent + 200, xIndent + 400, yIndent + 200); g.DrawLine(axisPen, xIndent + 200, yIndent, xIndent + 200, yIndent + 400); } This will then draw X Y Axes on the form. Let's say the screen coordinates at the drawn origin are "200, 200". What's the most efficient way to get "200, 200" to display "0, 0"? So now when I move the cursor around the Form it will have both positive and negative axis coortinates? ps--I know how to display the screen coordinates as text on the screen, I just can't seem to get the system to be correct.... Thanks very much......
-
Hi I have a simple WinForm I've created. With the following code: ////////////////////////////////////////////////////////////// public void DrawXYAxes(Graphics g) { g.DrawLine(axisPen, xIndent, yIndent + 200, xIndent + 400, yIndent + 200); g.DrawLine(axisPen, xIndent + 200, yIndent, xIndent + 200, yIndent + 400); } This will then draw X Y Axes on the form. Let's say the screen coordinates at the drawn origin are "200, 200". What's the most efficient way to get "200, 200" to display "0, 0"? So now when I move the cursor around the Form it will have both positive and negative axis coortinates? ps--I know how to display the screen coordinates as text on the screen, I just can't seem to get the system to be correct.... Thanks very much......
I think that you may want to investigate
Graphics.TranslateTransform()
. If you translate the Graphics object by 200 left and 200 down, you'll have what you need, methinks. To see this in action, you can check out my recently published article Y(et)A(nother)TabControl in which I perform these kinds of transformations to translate the origin all over my control. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty -
I think that you may want to investigate
Graphics.TranslateTransform()
. If you translate the Graphics object by 200 left and 200 down, you'll have what you need, methinks. To see this in action, you can check out my recently published article Y(et)A(nother)TabControl in which I perform these kinds of transformations to translate the origin all over my control. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty