110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Aptech.UI;
using System.IO;
using MyWindowExecutablePrograms.Function;
using System.Drawing.Imaging;
using System.Data.SqlClient;
public class FormAutoDock
{
public static void SideHideOrShow(Form DockableForm, ref int DockFormHeight, Timer _dockTimer)
{
if (DockableForm.WindowState != FormWindowState.Minimized)
{
_dockTimer.Interval = 100;
if (Cursor.Position.X > DockableForm.Left - 1 && Cursor.Position.X < DockableForm.Right && Cursor.Position.Y > DockableForm.Top - 1 && Cursor.Position.Y < DockableForm.Bottom)
{
if (DockableForm.Top <= 0 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width)
{
DockableForm.Top = 0;
}
else if (DockableForm.Left <= 0)
{
DockableForm.Left = 0;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width;
}
else
{
if (DockFormHeight > 0)
{
DockableForm.Height = DockFormHeight;
DockFormHeight = 0;
}
}
}
else
{
if (DockFormHeight < 1)
{
DockFormHeight = DockableForm.Height;
}
if (DockableForm.Top <= 4 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width)
{
DockableForm.Top = 3 - DockableForm.Height;
if (DockableForm.Left <= 4)
{
DockableForm.Left = -5;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width + 5;
}
}
else if (DockableForm.Left <= 4)
{
DockableForm.Left = 3 - DockableForm.Width;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - 3;
}
_dockTimer.Interval = 100;
}
}
}
}
FormAutoDock.SideHideOrShow(this, ref height, timer1);