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.Threading;
namespace QQ抖动窗口
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//窗体定位与大小
this.Size = new Size(800,800);
this.Left = Screen.PrimaryScreen.WorkingArea.Width/2-this.Width/2;
this.Top = Screen.PrimaryScreen.WorkingArea.Height/2-this.Height/2;
this.Text = "聊天记录";
//设置文本窗体是否只读
textBox1.ReadOnly = true;
//使用回车键发送消息
this.AcceptButton = button1;
//设置文本显示的字体
textBox1.Font = new Font("宋体",20);
textBox2.Font = new Font("宋体",15);
}
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
//给坐标点赋值
int a = this.Left;
int b = this.Top;
//窗体抖动定位
this.Location = new Point(a - 10, b);
Thread.Sleep(10);
this.Location = new Point(a - 10, b - 10);
Thread.Sleep(10);
this.Location = new Point(a, b - 10);
Thread.Sleep(10);
this.Location = new Point(a + 10, b - 10);
Thread.Sleep(10);
this.Location = new Point(a + 10, b);
Thread.Sleep(10);
this.Location = new Point(a + 10, b + 10);
Thread.Sleep(10);
this.Location = new Point(a, b + 10);
Thread.Sleep(10);
this.Location = new Point(a - 10, b + 10);
Thread.Sleep(10);
this.Location = new Point(a - 10, b);
Thread.Sleep(10);
this.Location = new Point(a, b);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text!="")
{
textBox1.Text = textBox1.Text + DateTime.Now + "\r\n" + textBox2.Text + "\r\n";
textBox2.Text = "";
}
}
}
}