一個(gè)簡(jiǎn)單的C#窗口抖動(dòng)效果實(shí)例
作者:楊俊uu
本文介紹了制作一個(gè)簡(jiǎn)單的C#窗口抖動(dòng)效果的實(shí)例,希望大家可以試試。
做一個(gè)簡(jiǎn)單的C#窗口抖動(dòng),仿QQ窗口抖動(dòng)效果!
首先,在窗口中添加一個(gè)按鈕:
C#窗口抖動(dòng)圖
在按鈕中輸入一下代碼:
即:
- int recordx = this.Left;
- int recordy = this.Top;
- Random random = new Random();
- for (int i = 0; i < 150; i++)
- {
- int x = random.Next(rand);
- int y = random.Next(rand);
- if (x % 2 == 0)
- {
- this.Left = this.Left + x;
- }
- else
- {
- this.Left = this.Left - x;
- }
- if (y % 2 == 0)
- {
- this.Top = this.Top + y;
- }
- else
- {
- this.Top = this.Top - y;
- }
- this.Left = recordx;
- this.Top = recordy;
- }
這樣,一個(gè)簡(jiǎn)單的C#窗口抖動(dòng)效果就實(shí)現(xiàn)了!
【編輯推薦】
責(zé)任編輯:book05
來(lái)源:
新浪博客