개인 코드 라이브러리의 데스크톱 가장자리 자동 접착

17650 단어 코드

  
    
using System.Windows.Forms;
using System;
namespace **
{

public partial class *** : form
{
/* 【 】:
* No.1: Move 。
* No.2: MouseEnter 。
* No.3:MouseLeave 。 “deactivated” + [ ]leave 。
* “**” namespace。
*/

int intBianYuanXiangSu = 7 ; // 。 , , 。

/// <summary>
///
/// </summary>
/// <param name="intJingDu"> , 10 。 </param>
/// <param name="LeftRight"> </param>
private void myMethod_AutoAbsorb( int intJingDu , bool LeftAndRight)
{

// 10 . 10 。
if ( intJingDu <= 10 )
intJingDu
= 10 ;

// ! ! , 。
if ( Left != SystemInformation.WorkingArea.Width - this .Size.Width && Left != 0 && Top != 0 )
{


// " " , 。
if ( Location.Y <= intJingDu && Location.Y > - this .Size.Height + intBianYuanXiangSu )
Top
= 0 ;

if ( LeftAndRight == true )
{
// " " , 。
if ( this .Location.X <= intJingDu && Location.X > - Size.Width + intBianYuanXiangSu )
Left
= 0 ;

// “ ” , 。WorkingArea 。
if ( Location.X >= ( SystemInformation.WorkingArea.Width - this .Size.Width - intJingDu )
&& Left < SystemInformation.WorkingArea.Width - intBianYuanXiangSu )
Left
= SystemInformation.WorkingArea.Width - Size.Width;
}
}
}


private void myMethod_AutoAbsorb_MouseEnter()
{

if ( Top == - this .Size.Height + intBianYuanXiangSu ) //
this .Top = 0 ;

if ( Left == - this .Size.Width + intBianYuanXiangSu ) //
this .Left = 0 ;

if ( Left == SystemInformation.WorkingArea.Width - intBianYuanXiangSu ) //
this .Left = SystemInformation.WorkingArea.Width - this .Size.Width;


}

// deactivated + leave 。 。
private void myMethod_AutoAbsorb_MouseLeave()
{

// , 。
if ( ! ( ( Control.MousePosition.X >= Left && Control.MousePosition.X <= Left + Width ) &&
( Control.MousePosition.Y
>= Top && Control.MousePosition.Y <= Top + Height ) ) )
{
if ( Top == 0 ) //
Top = - Size.Height + intBianYuanXiangSu;

if ( Left == 0 ) //
Left = - Size.Width + intBianYuanXiangSu;

if ( Left == SystemInformation.WorkingArea.Width - Size.Width ) //
Left = SystemInformation.WorkingArea.Width - intBianYuanXiangSu;

}


}
}
}

좋은 웹페이지 즐겨찾기