实验内容一、完成功能如D0501.exe所示。说明:设置窗体的大小privatevoidbutton3_Click(objectsender,EventArgse){this.Size=newSize(int.Parse(textBox1.Text),int.Parse(textBox2.Text));FormBorderStyle=FormBorderStyle.FixedToolWindow;}二、完成功能如D0502.exe所示。在窗体单元文件中增加类namespaceD0502{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}SubForm1SubForm=newSubForm1();//创建类SubForm1的对象}publicpartialclassSubForm1:Form//定义类SubForm1{publicSubForm1(){this.MinimizeBox=false;//最小化不可用}}}三、完成功能如D0503.exe所示。(1)在解决方案资源管理器,右击项目名称,选择【添加】-》【windows窗体】(2)新窗体添加到该windows应用程序中,设计窗体Form2(3)在窗体Form2的代码区publicpartialclassForm2:Form{boolisCustomStyle=false;publicForm2()//构造函数{InitializeComponent();this.StartPosition=FormStartPosition.CenterScreen;}publicForm2(intscreenX,intscreenY)//构造函数重载{InitializeComponent();this.StartPosition=FormStartPosition.Manual;Pointp=newPoint(screenX,screenY);Location=p;}publicForm2(boolisCStyle)//构造函数重载{this.isCustomStyle=isCStyle;InitializeComponent();if(isCStyle){this.FormBorderStyle=FormBorderStyle.None;this.BackColor=Color.AliceBlue;}this.StartPosition=FormStartPosition.CenterScreen;}privatevoidbutton1_Click(objectsender,EventArgse){Close();}privatevoidForm2_Paint(objectsender,PaintEventArgse){if(isCustomStyle){System.Drawing.Drawing2D.GraphicsPathformShape=newSystem.Drawing.Drawing2D.GraphicsPath();formShape.AddEllipse(0,0,Width,Height);Region=newRegion(formShape);}}}(4)窗体Form1的按钮处理事件privatevoidbutton1_Click(objectsender,EventArgse){intx=0,y=0;int.TryParse(textBox1.Text,outx);int.TryParse(textBox2.Text,outy);Form2fm=newForm2(x,y);fm.Show();}privatevoidbutton2_Click(objectsender,EventArgse){Form2fm=newForm2();fm.Show();}privatevoidbutton3_Click(objectsender,EventArgse){Form2fm=newForm2(true);fm.Show();}四、完成功能如D0504.exe所示。注意:窗体上是4个Lable控件和1个Button控件(1)在窗体类中增加随机对象,代码如下:privateRandomrandomNumber=newRandom();(2)增加方法,调用Random的方法Next模拟一次投骰子并且装载与产生值相对应的图片,代码如下:publicvoidDisplayDie(LabeldieLabel){intface=randomNumber.Next(1,7);dieLabel.Image=Image.FromFile(Directory.GetCurrentDirectory()+\\die+face+.gif);}说明:Directory方法GetCurrentDirectory返回程序执行所在的文件夹路径。这个路径是项目目录中的bin\Debug目录。骰子图片必须在这个文件夹中。(3)按钮的单击事件,每单击一次按钮就显示出4个图片表示投骰子得到的4个新值,代码如下:privatevoidbutton1_Click(objectsender,EventArgse){DisplayDie(label1);DisplayDie(label2);DisplayDie(label3);DisplayDie(label4);}在调试程序的时候,如果出现“当前上下文中不存在名称“Directory”,请添加命名空间usingSystem.IO;