资源简介
private void StopRectTimer_Tick(object sender, EventArgs e)
{
//如果鼠标在窗体上,则根据停靠位置显示整个窗体
if (this.Bounds.Contains(Cursor.Position))
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, 0);
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - this.Height);
break;
case AnchorStyles.Left:
this.Location = new Point(0, this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, this.Location.Y);
break;
}
}
else //如果鼠标离开窗体,则根据停靠位置隐藏窗体,但须留出部分窗体边缘以便鼠标选中窗体
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, (this.Height - 3) * (-1));
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - 5);
break;
case AnchorStyles.Left:
this.Location = new Point((-1) * (this.Width - 3), this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 2, this.Location.Y);
break;
}
}
}
{
//如果鼠标在窗体上,则根据停靠位置显示整个窗体
if (this.Bounds.Contains(Cursor.Position))
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, 0);
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - this.Height);
break;
case AnchorStyles.Left:
this.Location = new Point(0, this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, this.Location.Y);
break;
}
}
else //如果鼠标离开窗体,则根据停靠位置隐藏窗体,但须留出部分窗体边缘以便鼠标选中窗体
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, (this.Height - 3) * (-1));
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - 5);
break;
case AnchorStyles.Left:
this.Location = new Point((-1) * (this.Width - 3), this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 2, this.Location.Y);
break;
}
}
}
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestFloatWindow
{
public static class Class1
{
public static MainFrm frmmain = null;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2015-02-09 15:42 TestFloatWindow\TestFloatWindow\App.config
文件 32038 2015-01-30 02:17 TestFloatWindow\TestFloatWindow\bin\Debug\IMG\Q1.ico
文件 32038 2015-01-30 02:17 TestFloatWindow\TestFloatWindow\bin\Debug\IMG\Q2.ico
文件 11776 2015-02-12 11:01 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.exe
文件 187 2015-02-09 15:42 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.exe.config
文件 34304 2015-02-12 11:01 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.pdb
文件 24224 2015-02-12 11:02 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.vshost.exe
文件 187 2015-02-09 15:42 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.vshost.exe.config
文件 490 2013-06-18 20:28 TestFloatWindow\TestFloatWindow\bin\Debug\TestFloatWindow.vshost.exe.manifest
文件 252 2015-02-09 15:59 TestFloatWindow\TestFloatWindow\Class1.cs
文件 685 2015-02-09 16:01 TestFloatWindow\TestFloatWindow\Form1.cs
文件 2108 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\Form1.Designer.cs
文件 5817 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\Form1.resx
文件 5530 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\MainFrm.cs
文件 3334 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\MainFrm.Designer.cs
文件 6413 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\MainFrm.resx
文件 1453 2015-02-12 11:02 TestFloatWindow\TestFloatWindow\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7063 2015-02-09 15:57 TestFloatWindow\TestFloatWindow\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2015-02-09 15:43 TestFloatWindow\TestFloatWindow\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2015-02-09 15:43 TestFloatWindow\TestFloatWindow\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2015-02-09 15:43 TestFloatWindow\TestFloatWindow\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 1079 2015-02-12 11:02 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.csproj.FileListAbsolute.txt
文件 1037 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.csproj.GenerateResource.Cache
文件 2211 2015-02-09 15:55 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.csprojResolveAssemblyReference.cache
文件 11776 2015-02-12 11:01 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.exe
文件 180 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.Form1.resources
文件 180 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.MainFrm.resources
文件 34304 2015-02-12 11:01 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.pdb
文件 180 2015-02-09 16:00 TestFloatWindow\TestFloatWindow\obj\Debug\TestFloatWindow.Properties.Resources.resources
文件 527 2015-02-09 15:59 TestFloatWindow\TestFloatWindow\Program.cs
............此处省略21个文件信息
评论
共有 条评论