借鉴网上的winform模仿QQ窗口停靠功能稍作改动

  2015-07-11 15:24:04
1 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms; namespace 窗口停靠
{
public partial class Form1 : Form
{
string location = null;
int y;
int x;
public Form1()
{
InitializeComponent();
} /// <summary> /// 当窗体的位置改变时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_LocationChanged(object sender, EventArgs e)
{
y = this.Location.Y;
x = this.Location.X;
if (this.Top <= )
{ location = "top"; } else if (this.Left <= )
{ location = "left"; } else if (this.Right >= Screen.PrimaryScreen.Bounds.Width)
{ location = "right"; }
else
{
location = "center";
} }
private void timer2_Tick(object sender, EventArgs e)
{ //如果鼠标在窗体上,则根据停靠位置显示整个窗体 if (this.Bounds.Contains(Cursor.Position))
{ switch (location)
{ case "top":
if(this.Location.Y<)
{
y += ;
if(y>)
{
y = ;
}
this.Location = new Point(this.Location.X, y);
}
break; case "left": if(this.Location.X<)
{
x += ;
if(x>)
{
x = ;
}
this.Location = new Point(x, this.Location.Y);
}
break; case "right":
if (this.Location.X > Screen.PrimaryScreen.Bounds.Width - this.Width)
{
x -= ;
if (x < Screen.PrimaryScreen.Bounds.Width - this.Width)
{
x = Screen.PrimaryScreen.Bounds.Width - this.Width;
}
this.Location = new Point(x, this.Location.Y);
}
break; } } else //如果鼠标离开窗体,则根据停靠位置隐藏窗体,但须留出部分窗体边缘以便鼠标选中窗体
{ switch (location)
{ case "top": y = y - ;
if(y>-this.Height+)
{
this.Location = new Point(this.Location.X, y); }
else
{
this.Location = new Point(this.Location.X, -this.Height + );
}
break; case "left":
x -= ;
if(x>-this.Width+)
{
this.Location = new Point(x, this.Location.Y); }
else
{
this.Location = new Point(-this.Width + , this.Location.Y);
}
break; case "right": if(x<Screen.PrimaryScreen.Bounds.Width- )
{
x += ;
this.Location = new Point(x, this.Location.Y); }
else
{
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width + - , this.Location.Y);
}
break;
} } }
} }

改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!! 改个分类也改不了,不能发布至首页发布候选区,我不想发布啊,可是取消不了,还提示没有超过150字!!!,这只是为了凑个字数!!!!!!

上一篇:Beta阶段第九次Scrum Meeting


下一篇:Yii Query Builder insert()、update()、delete()使用