Click here to Skip to main content
15,887,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have to ZOOM-IN & ZOOM-OUT  2D-graphics like (line, Rectangle, circle) which i have draw on winform. I am not used any picture box, panel. 

I crated simple program to draw circle & 
on button click try to zoom but it showing error "parameter is not valid" in method Drawing() 
@ Line- DeviceContexct.Transform = mainViewTransform;



What I have tried:

<pre>public Graphics DeviceContexct;
  public Matrix mainViewTransform = new Matrix();

    private void ScalingCircle_Paint( object sender, PaintEventArgs e )
            {
                Pen myPen = new Pen(Color.Blue, 1); 
                e.Graphics.DrawRectangle(myPen, 50, 50, 100, 100);           
                mainViewTransform.Scale(3, 2);
                DeviceContexct = e.Graphics;
            }
     private void Drawing(Graphics gr)
            {
                Pen myPen2 = new Pen(Color.Red, 1);
                DeviceContexct.Transform = mainViewTransform;
                DeviceContexct.DrawRectangle(myPen2, 50, 50, 100, 100);
            }
       private void button1_Click( object sender, EventArgs e )
            {
                Drawing(DeviceContexct);         

            }
Posted
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900