|
Using System;
Using System. Drawing;
Using System. Collections;
Using System. ComponentModel;
Using System. Windows. Forms;
Using System. Data;
Namespace WindowsApplication12
{
/// <Summary>
/// Summary description for Form1.
/// </Summary>
Public class Form1: System. Windows. Forms. Form
{
Private int tmpx = 0;
Private int tmpy = 0;
Private System. Windows. Forms. PictureBox pictureBox1;
/// <Summary>
/// Required designer variable.
/// </Summary>
Private System. ComponentModel. Container components = null;
System. Drawing. Rectangle [] ScreensRect;
Public Form1 ()
{
//
// Required for Windows Form Designer support
//
InitializeComponent ();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <Summary>
/// Clean up any resources being used.
/// </Summary>
Protected override void Dispose (bool disposing)
{
If (disposing)
{
If (components! = Null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing );
}
# Region Windows Form Designer generated code
/// <Summary>
/// Required method for Designer support-do not modify
/// The contents of this method with the code editor.
/// </Summary>
Private void InitializeComponent ()
{
This. pictureBox1 = new System. Windows. Forms. PictureBox ();
This. SuspendLayout ();
//
// PictureBox1
//
This. pictureBox1.BackColor = System. Drawing. SystemColors. HotTrack;
This. pictureBox1.Location = new System. Drawing. Point (120, 88 );
This. pictureBox1.Name = "pictureBox1 ";
This. pictureBox1.Size = new System. Drawing. Size (248,176 );
This. pictureBox1.TabIndex = 0;
This. pictureBox1.TabStop = false;
//
// Form1
//
This. AutoScaleBaseSize = new System. Drawing. Size (5, 13 );
This. ClientSize = new System. Drawing. Size (504,357 );
This. Controls. Add (this. pictureBox1 );
This. Name = "Form1 ";
This. Text = "Form1 ";
This. MouseDown + = new System. Windows. Forms. MouseEventHandler (this. Form1_MouseDown );
This. Load + = new System. EventHandler (this. form#load );
This. MouseUp + = new System. Windows. Forms. MouseEventHandler (this. Form1_MouseUp );
This. ResumeLayout (false );
}
# Endregion
/// <Summary>
/// The main entry point for the application.
/// </Summary>
[STAThread]
Static void Main ()
{
Application. Run (new Form1 ());
}
Private void form=mousedown (object sender, System. Windows. Forms. MouseEventArgs e)
{
This. tmpx = e. X;
This. tmpy = e. Y;
This. MouseMove + = new System. Windows. Forms. MouseEventHandler (this. form1_MouseMove );
}
Private void form=mouseup (object sender, System. Windows. Forms. MouseEventArgs e)
{
This. MouseMove-= new System. Windows. Forms. MouseEventHandler (this. form1_MouseMove );
System. Drawing. Rectangle pictureBox1Rect = Screen. GetWorkingArea (pictureBox1 );
For (int I = 0; I <ScreensRect. Length; I ++)
{
If (ScreensRect [I]. X = pictureBox1Rect. X & ScreensRect [I]. Y = pictureBox1Rect. Y)
This. Location = new Point (ScreensRect [I]. X, pictureBox1Rect. Y );
}
// MessageBox. Show ("WorkingArea:" + re. ToString ());
}
Private void form=mousemove (object sender, MouseEventArgs e)
{
This. Location = new System. Drawing. Point (this. Location. X + e. X-this. tmpx, this. Location. Y + e. Y-this. tmpy );
}
Private void Form1_Load (object sender, System. EventArgs e)
{
Screen [] s = Screen. AllScreens;
ScreensRect = new Rectangle [s. Length];
For (int I = 0; I <s. Length; I ++)
{
ScreensRect [I] = s [I]. WorkingArea;
}
}
}
}
|