我在picturebox1建立坐标轴,并画了一幅4个同心圆图,现在我想用button实现对图形的刷新、平移、变大、变小功能,但是不知道怎么入手,望各位高手给予帮助,在此谢过各位啦!

解决方案 »

  1.   

    去看看 WPF 或者GDI+绘图部分的文章吧,给你一个链接http://blog.csdn.net/johnsuna/archive/2008/04/20/2309520.aspx 
      

  2.   


    public partial class Form1 : Form
        {
            Graphics g;
            public Form1()
            {
                InitializeComponent();
                g = panel1.CreateGraphics();
            }        /// <summary>
            /// 移动
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {            
                g.TranslateTransform(50, 0);
                panel1.Invalidate();
             }        /// <summary>
            /// 刷新画圆
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void panel1_Paint(object sender, PaintEventArgs e)
            {
                g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40)));       
            }        /// <summary>
            /// 变大
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button3_Click(object sender, EventArgs e)
            {
                g.ScaleTransform(2, 2);
                panel1.Invalidate();
            }        /// <summary>
            /// 变小
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button4_Click(object sender, EventArgs e)
            {
                g.ScaleTransform((float)0.5, (float)0.5);
                panel1.Invalidate();
            }
        }
      

  3.   


    [code=C#]
    public partial class Form1 : Form
        {
            Graphics g;
            public Form1()
            {
                InitializeComponent();
                g = panel1.CreateGraphics();
            }        /// <summary>
            /// 移动
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {            
                g.TranslateTransform(50, 0);
                panel1.Invalidate();
             }        /// <summary>
            /// 刷新画圆
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void panel1_Paint(object sender, PaintEventArgs e)
            {
                g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 10), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(10, 110), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 10), new Size(40, 40)));            g.DrawEllipse(new Pen(Brushes.Blue), new Rectangle(new Point(160, 110), new Size(40, 40)));       
            }        /// <summary>
            /// 变大
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button3_Click(object sender, EventArgs e)
            {
                g.ScaleTransform(2, 2);
                panel1.Invalidate();
            }        /// <summary>
            /// 变小
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button4_Click(object sender, EventArgs e)
            {
                g.ScaleTransform((float)0.5, (float)0.5);
                panel1.Invalidate();
            }
        }[/code]
      

  4.   

    Press the button and refresh the picture box. 
      

  5.   

    Press the button and refresh the picture box. 
      

  6.   

    http://download.csdn.net/source/961479 给你个例子,看看能不能帮到你!
      

  7.   

    http://zzk.cnblogs.com/s?w=c%23+%e7%94%bb%e5%9b%be
      

  8.   

    http://download.csdn.net/source/775720
    可以下载这个看看
      

  9.   

    这个CSDN上有的  自己搜一下.
      

  10.   

    使用.net的GDI+画图会比较死板,交互性不够强,建议LZ采用winapi接口画图,会得到更好的效果,会更灵活,交互性会更强