C#实现气泡旋转(winform框架)

mac2025-03-27  11

private void Form1_Load(object sender, EventArgs e) { this.BackColor = Color.Green; this.FormBorderStyle = FormBorderStyle.None; // 消除边框 this.Location = new Point(); // 窗体位置 label1.Text = "点点啊"; label1.ForeColor = Color.FromArgb(255, 255, 255); // 字体颜色 label1.Font = new Font("楷体",20); label1.Left = this.Width / 2 - label1.Width / 2; // 字体居中 } private void timer1_Tick(object sender, EventArgs e) { // 向左移动 this.Left += 2; // Screen.PrimaryScreen.Bounds.Width 显示屏幕宽度 if (this.Left+this.Width>=Screen.PrimaryScreen.Bounds.Width ) { timer1.Stop();// 关闭定时器 timer2.Enabled=true;// 开启定时器 } } private void timer2_Tick(object sender, EventArgs e) { // 向下移动 this.Top += 2; //Screen.PrimaryScreen.WorkingArea屏幕工作区 if (this.Top + this.Height >= Screen.PrimaryScreen.WorkingArea.Height) { //timer2.Enabled = false; timer2.Stop(); timer3.Enabled = true; } } private void timer3_Tick(object sender, EventArgs e) { // 向右移动 this.Left -= 2; if (this.Left <= 0) { // timer3.Enabled = false; timer3.Stop(); timer4.Enabled = true; } } private void timer4_Tick(object sender, EventArgs e) { // 向上移动 this.Top -= 2; if (this.Top <= 0) { timer4.Enabled = false; } }
最新回复(0)