www.pudn.com > Fetion.rar > InvisibleForm.cs


namespace Imps.Client.Pc 
{ 
    using System; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Windows.Forms; 
 
    public class InvisibleForm : Form 
    { 
        private System.Drawing.Point _currentLocation; 
        private System.Drawing.Point _firstLocation; 
        private System.Drawing.Point _secondLocation; 
        private bool _selectMoving; 
        private IContainer components; 
 
        public InvisibleForm() 
        { 
            this.InitializeComponent(); 
            this._firstLocation = new System.Drawing.Point(); 
            this._secondLocation = new System.Drawing.Point(); 
            this._selectMoving = false; 
            base.WindowState = FormWindowState.Maximized; 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void InitializeComponent() 
        { 
            base.SuspendLayout(); 
            base.AutoScaleDimensions = new SizeF(6f, 13f); 
            base.AutoScaleMode = AutoScaleMode.Font; 
            base.ClientSize = new Size(0x119, 0xe2); 
            base.FormBorderStyle = FormBorderStyle.None; 
            base.KeyPreview = true; 
            base.MaximizeBox = false; 
            base.MinimizeBox = false; 
            base.Name = "InvisibleForm"; 
            base.Opacity = 0.3; 
            this.Text = "InvisibleForm"; 
            base.MouseUp += new MouseEventHandler(this.InvisibleForm_MouseUp); 
            base.MouseMove += new MouseEventHandler(this.InvisibleForm_MouseMove); 
            base.KeyDown += new KeyEventHandler(this.InvisibleForm_KeyDown); 
            base.MouseDown += new MouseEventHandler(this.InvisibleForm_MouseDown); 
            base.ResumeLayout(false); 
        } 
 
        private void InvisibleForm_KeyDown(object sender, KeyEventArgs e) 
        { 
            if (e.KeyCode == Keys.Escape) 
            { 
                base.DialogResult = DialogResult.Cancel; 
                base.Close(); 
            } 
        } 
 
        private void InvisibleForm_MouseDown(object sender, MouseEventArgs e) 
        { 
            this._selectMoving = true; 
            this._firstLocation = e.Location; 
        } 
 
        private void InvisibleForm_MouseMove(object sender, MouseEventArgs e) 
        { 
            if (this._currentLocation != e.Location) 
            { 
                this._currentLocation = e.Location; 
                if (this._selectMoving) 
                { 
                    Graphics graphics = base.CreateGraphics(); 
                    this._secondLocation = e.Location; 
                    Rectangle rect = this.Rect; 
                    Pen pen = new Pen(new SolidBrush(Color.Blue), 2f); 
                    graphics.Clear(this.BackColor); 
                    graphics.DrawRectangle(pen, rect); 
                    graphics.Dispose(); 
                } 
            } 
        } 
 
        private void InvisibleForm_MouseUp(object sender, MouseEventArgs e) 
        { 
            this._secondLocation = e.Location; 
            this._selectMoving = false; 
            base.DialogResult = DialogResult.Yes; 
            base.Close(); 
        } 
 
        public Rectangle Rect 
        { 
            get 
            { 
                return new Rectangle(this._firstLocation.X, this._firstLocation.Y, this._secondLocation.X - this._firstLocation.X, this._secondLocation.Y - this._firstLocation.Y); 
            } 
        } 
    } 
}