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;
namespace 窗口
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
this.Left = 0;
this.Top = 0;
Timer timer = new Timer();
timer.Interval = 10;
timer.Start();
timer.Tick += Timer_Tick;
}
int x = 3;
int y = 3;
private void Timer_Tick(object sender, EventArgs e)
{
this.Left += x;
this.Top += y;
if (this.Left+this.Width>=Screen.PrimaryScreen.WorkingArea.Width)
{
if (x>0&&y>0)
{
x = -3;
y = 3;
}
if (x>0&&y<0)
{
x = -3;
y = -3;
}
}
if (this.Top+this.Height>=Screen.PrimaryScreen.WorkingArea.Height )
{
if (x>0&&x>0)
{
x = 3;
y = -3;
}
if (x<0&&y>0)
{
x = -3;
y = -3;
}
}
if (this.Left<=0)
{
if (x<0&&y>0)
{
x = 3;
y = 3;
}
if (x<0&&y<0)
{
x = 3;
y = -3;
}
}
if (this.Top<=0)
{
if (x>0&&y<0)
{
x = 3;
y = 3;
}
if (x<0&&y<0)
{
x = -3;
y = 3;
}
}
}
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-62881.html