📄 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.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
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.get_Location();
}
private void InvisibleForm_MouseMove(object sender, MouseEventArgs e)
{
if (this._currentLocation != e.get_Location())
{
this._currentLocation = e.get_Location();
if (this._selectMoving)
{
Graphics graphics = base.CreateGraphics();
this._secondLocation = e.get_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.get_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);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -