一個簡單的C#窗口抖動效果實例
作者:楊俊uu
本文介紹了制作一個簡單的C#窗口抖動效果的實例,希望大家可以試試。
做一個簡單的C#窗口抖動,仿QQ窗口抖動效果!
首先,在窗口中添加一個按鈕:
C#窗口抖動圖
在按鈕中輸入一下代碼:
即:
- 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;
- }
這樣,一個簡單的C#窗口抖動效果就實現了!
【編輯推薦】
責任編輯:book05
來源:
新浪博客