日期:2014-05-17  浏览次数:20759 次

初始化Form1出现了问题,请帮忙看看这是怎么回事。(无限循环初始化)
        public Form1()
        {
            InitializeComponent();
            this.Resize += new EventHandler(Form1_Resize);
            res.firstDemo(this);
        } 
///这个是调用
        internal void firstDemo(Form1 form1)
        {
            firstDemo(form1);
        }
我的程序目的是将放大和缩小Form封装成一个类,现在出现了问题,代码在不封装的时候是好用的。。。。。。。。封装类如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace 放大和缩小界面
{
    class resize : Form
    {
        public void firstDemo(Form it)
        {
            try
            {
                int count = this.Controls.Count * 2 + 2;
                float[] factor = new float[count];
                int i = 0;
                factor[i++] = Size.Width;
                factor[i++] = Size.Height;
                foreach (Control ctrl in it.Controls)
                {
                    factor[i++] = ctrl.Location.X / (float)Size.Width;
                    factor[i++] = ctrl.Location.Y / (float)Size.Height;
                    ctrl.Tag = ctrl.Size;
                }
                Tag = factor;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
&nb