Using System;
Using System. Collections. Generic;
Using System. Drawing;
Using System. Windows. Forms;
Using System. ComponentModel;
Using System. Data;
Namespace WinHide
{
Public partial class MainForm: Form
{
Public MainForm ()
{
InitializeComponent ();
}
# Region form hidden part
Void Timer1Tick (object sender, EventArgs e)
{
If (this. Bounds. Contains (Cursor. Position ))
{
Switch (this. StopAnhor)
{
Case AnchorStyles. Top:
This. Location = new Point (this. Location. X, 0 );
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. StopAnhor)
{
Case AnchorStyles. Top:
This. Location = new Point (this. Location. X, (this. Height-4) * (-1 ));
Break;
Case AnchorStyles. Left:
This. Location = new Point (this. Width-4) * (-1), this. Location. Y );
Break;
Case AnchorStyles. Right:
This. Location = new Point (Screen. PrimaryScreen. Bounds. Width-4, this. Location. Y );
Break;
}
}
}
Internal AnchorStyles StopAnhor = AnchorStyles. None;
Private void mStopAnhor ()
{
If (this. Top <= 0)
{
StopAnhor = AnchorStyles. Top;
}
Else if (this. Left <= 0)
{
StopAnhor = AnchorStyles. Left;
}
Else if (this. Right> = Screen. PrimaryScreen. Bounds. Width)
{
StopAnhor = AnchorStyles. Right;
}
Else
{
StopAnhor = AnchorStyles. None;
}
}
Void MainFormLocationChanged (object sender, EventArgs e)
{
This. mStopAnhor ();
}
# Endregion
}