Esempio n. 1
0
        private void btn_test_Click(object sender, EventArgs e)
        {
            // #todo 输入检查,数字1~10only
            int culture; //4 china1,Egypt2, Babylon3, India4
            int wealth;  //1~10
            int density; //1~10
            int tech;    //1~10

            if (rbtn_Babylon.Checked == true)
            {
                culture = 3;
            }
            else if (rbtn_China.Checked == true)
            {
                culture = 1;
            }
            else if (rbtn_Egypt.Checked == true)
            {
                culture = 2;
            }
            else
            {
                culture = 4;
            }
            wealth = Convert.ToInt16(tbx_Wealth.Text);
            density = Convert.ToInt16(tbx_Density.Text);
            tech = Convert.ToInt16(tbx_Tech.Text);

            House house1 = new House(culture, wealth, density, tech);
            house1.input_processing();

            Graphics g = this.CreateGraphics();  //创建grahics对象实例
            //定义矩形区域
            Rectangle rect = new Rectangle(50, 350-house1.Wall_height , house1.Wall_weight, house1.Wall_height);
            //定义画刷对象
            LinearGradientBrush lBrush = new LinearGradientBrush(rect, house1.Color, house1.Color, LinearGradientMode.BackwardDiagonal);
            //填充矩形
            g.FillRectangle(lBrush, rect);
        }