日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

仿Win7屏保泡泡移动

發布時間:2023/12/18 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 仿Win7屏保泡泡移动 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一個泡泡的隨機運動

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;namespace 窗體移動 {public partial class Form1 : Form{public Form1(){InitializeComponent();//加載一個窗體事件this.Load+=new EventHandler(Form1_Load);//timer的Tick事件t.Tick += new EventHandler(t_Tick);}//實例化一個Timer對象Timer t=new Timer();//定義兩個變量int b1=0,b2=0;//timer的Tick事件void t_Tick(object sender, EventArgs e){//throw new NotImplementedException();this.Left += b2;this.Top += b1;//當窗體碰撞到窗體上邊界或下邊界控制上下的變量*-1if (this.Top <= 0 || this.Bottom >= Screen.PrimaryScreen.WorkingArea.Height){b1 *= -1;}//當窗體碰撞到窗體左邊界或右邊界控制上下的變量*-1if (this.Left <= 0 || this.Right >= Screen.PrimaryScreen.WorkingArea.Width){b2 *= -1;}}//窗體加載事件private void Form1_Load(object sender, EventArgs e){//改變窗體透明度this.Opacity = 0.7;//將窗體解成一個橢圓GraphicsPath g = new GraphicsPath();g.AddEllipse(0,0,this.Width,this.Height);this.Region = new Region(g);//窗體的初始位置為(0,0)this.Location = new Point(0, 0);//生成兩個隨機數Random a = new Random();b1 = a.Next(2, 8);b2 = a.Next(2, 8);//啟動timer并設置頻率為10mst.Interval = 10;t.Start();}} }

多個泡泡的隨機運動

同一個泡泡運動原理相同,可多實例化幾個窗口,這里作者提供一個方法

void showform(Form s,int b3,int b4){s.Location = new Point(s.Location.X + b3, s.Location.Y + b4);if (s.Location.Y <= 0 || s.Location.Y >= Screen.PrimaryScreen.WorkingArea.Height-s.Height){b4 *= -1;}else if (s.Location.X <= 0 || s.Location.X >= Screen.PrimaryScreen.WorkingArea.Width-s.Width){b3 *= -1;}}

總結

以上是生活随笔為你收集整理的仿Win7屏保泡泡移动的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。