Casual opportunity to find that the Graphics object Transform property has a patent question, listening to friends saying that the image properties of PictureBox also have similar problems.
First look at the following code:
Private void form1_paint (object sender, system.windows e) {matrix matrix = new matrix (1, 0, 0, -1, 0); Matrix.Translate (ClientRectangle.width / 2, -clientRectangle. HEIGHT / 2); E.Graphics.Transform = Matrix;
E.Graphics.Transform.Rset (); // <<<<< --------------------------------- ----- Note Rectangle DestRect = New Rectangle (10, 10, 50, 50); E.Graphics.FillRectangle (New Solidbrush (Color.Fromargb (128, 0)), DESTRECT); / / Gray rectangle
Matrix.reset (); E.Graphics.Transform = Matrix; // can also use E.Graphics.RsetTransform (); E.Graphics.FillRectangle (New Solidbrush (Color.Fromargb (128, 255, 0)), DESTRECT ); // red rectangular} operation results are shown
This shows that graphics.transform.reset () does not work at all. By stating that Transform is a property of Graphics, which is Matrix, so there should be a private variable to store the actual value of Transform in Transform, which should have a definition of similar code:
internal class MyGraphics {private MyMatrix varTransform; public MyMatrix myTransform {get {return varTransform;} set {if (varp = value!) varTransform = value;}}} internal class MyMatrix {public int i = 10; public void Reset () { I = 13;}} I use the following code to test:
private void button1_Click (object sender, System.EventArgs e) {MyGraphics g = new MyGraphics (); MyMatrix matrix = new MyMatrix (); g.myTransform = matrix; Debug.Write (g.myTransform.i); g.myTransform. Reset (); debug.write (g.mytransform.i);} The results indicate that RESET is able to modify the private variable of MyGraphics Vartransform, then what is the relationship between Graphics and Transform?