Member 11278731 Ответов: 0

Увеличение и уменьшение масштаба 2D-графики C#


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;



Что я уже пробовал:

<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);         

            }

0 Ответов