using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
//想用GraphicsPath必须先引用//
using System.IO;
namespace 第二周作业
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.Red;
//他的背景颜色是红色//
this.FormBorderStyle = FormBorderStyle.None;
//他的边框是无边框 的//
this.Size = new Size(200, 200);
//他的大小是宽200,高200的//
this.Location = new Point(0, 0);
//他的初始位置是(0,0)//
this.Opacity = 0.6;
//他的不透明度为百分之60//
GraphicsPath path = new GraphicsPath();
//创建一个GraphicsPath类型,实例化//
path.AddEllipse(0, 0, this.Width, this.Height);
//因为path是创建属于的class,并且有自己的输入方法//
this.Region = new Region(path);
//关联一个窗口,region属于GraphicsPath//
timer1.Start();
//启用计时器timer1//
}
int x = 8;
//定义一个变量x=//
int y = 5;
//定义一个变量y=5//
private void timer1_Tick(object sender, EventArgs e)
{
this.Left += x;
//他的宽度每经过0.1毫秒增加x//
this.Top += y;
//他的高度每经过0.1毫秒增加y**
if (this.Top+this.Height >=Screen.PrimaryScreen.Bounds .Height ||Top <=0)
//如果满足他上边到主屏幕的距离加上他自生的高度大于等于屏幕的高度或者他的高度小于等于主屏幕的高度时//
{
y = -y;
//y就等于负y
Form1 f1 = new Form1();
//new一个新的窗体//
this.BackColor = Color.Blue;
//新的窗体背景颜色为蓝色//
f1.Show();
//窗体进行显示//
}
if (this.Left +this.Width >=Screen.PrimaryScreen.Bounds .Width ||Left <= 0)
//如果满足他左边到主屏幕的距离加上他自生的宽度大于等于屏幕的宽度或者他的宽度小于等于主屏幕的宽度时//
{
x = -x;
//x等于负x//
}
}
}
}
难点;
学会并理解定义和使用变量