110,566
社区成员
发帖
与我相关
我的任务
分享
//这是一个半透明蓝色的刷子,用这个刷子来刷矩形
Brush brush = new SolidBrush(Color.FromArgb(128, Color.Blue));
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace BrowserPlugins
{
public partial class FormCatcher : Form
{
public FormCatcher()
{
InitializeComponent();
}
public int x = 0;
public int y = 0;
public Rectangle r;
private void FormCatcher_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
Rectangle rect = new Rectangle(0, 0, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1);
g.DrawRectangle(Pens.Red, rect);
}
}
private void FormCatcher_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.x = e.X;
this.y = e.Y;
r = this.Bounds;
}
}
private void FormCatcher_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x;
int dy = e.Y - y;
this.Location = new Point(this.Location.X + dx, this.Location.Y + dy);
}
}
private void FormCatcher_DoubleClick(object sender, EventArgs e)
{
Bitmap bmpCatched = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(bmpCatched);
g.CopyFromScreen(this.Location, new Point(0, 0), this.ClientRectangle.Size);
Clipboard.SetImage(bmpCatched);
MessageBox.Show("截图已经复制到剪切板!","info", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
#region ReSize
private void FormCatcher_Resize(object sender, EventArgs e)
{
btn0.SetBounds(0,0,8,8);
btn1.SetBounds((this.Width-8)/2,0,8,8 );
btn2.SetBounds(this .Width -8,0,8,8);
btn3.SetBounds(0,(this .Height -8)/2,8,8);
btn4.SetBounds(this .Width -8,(this.Height -8)/2,8,8);
btn5.SetBounds(0,this.Height -8,8,8);
btn6.SetBounds((this .Width -8)/2,this .Height -8,8,8);
btn7.SetBounds(this .Width -8,this .Height -8,8,8);
}
int x0, y0;
private void btn0_MouseDown(object sender, MouseEventArgs e)
{
x0 = e.X; y0 = e.Y;
}
private void btn0_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x0; int dy = e.Y - y0;
this.SetBounds(this.Location.X + dx, this.Location.Y + dy, this.Width - dx, this.Height - dy);
}
}
int x1, y1;
private void btn1_MouseDown(object sender, MouseEventArgs e)
{
x1 = e.X; y1 = e.Y;
}
private void btn1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x1; int dy = e.Y - y1;
this.SetBounds(this .Location .X,this .Location .Y +dy,this.Width ,this.Height -dy);
}
}
int x2, y2;
private void btn2_MouseDown(object sender, MouseEventArgs e)
{
x2 = e.X; y2 = e.Y;
}
private void btn2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x2; int dy = e.Y - y2;
this.SetBounds(this .Location .X ,this .Location .Y+dy ,this .Width +dx,this .Height -dy);
}
}
int x3, y3;
private void btn3_MouseDown(object sender, MouseEventArgs e)
{
x3 = e.X; y3 = e.Y;
}
private void btn3_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x3; int dy = e.Y - y3;
this.SetBounds(this .Location .X+dx ,this .Location .Y,this .Width -dx,this .Height );
}
}
int x4, y4;
private void btn4_MouseDown(object sender, MouseEventArgs e)
{
x4 = e.X; y4 = e.Y;
}
private void btn4_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x4; int dy = e.Y - y4;
this.SetBounds(this .Location .X,this .Location .Y ,this .Width+dx,this .Height );
}
}
int x5, y5;
private void btn5_MouseDown(object sender, MouseEventArgs e)
{
x5 = e.X; y5 = e.Y;
}
private void btn5_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x5; int dy = e.Y - y5;
this.SetBounds(this .Location .X +dx,this .Location .Y ,this.Width -dx,this .Height +dy);
}
}
int x6, y6;
private void btn6_MouseDown(object sender, MouseEventArgs e)
{
x6 = e.X; y6 = e.Y;
}
private void btn6_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x6; int dy = e.Y - y6;
this.SetBounds(this .Location .X ,this .Location .Y ,this .Width,this .Height +dy);
}
}
int x7, y7;
private void btn7_MouseDown(object sender, MouseEventArgs e)
{
x7 = e.X; y7 = e.Y;
}
private void btn7_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int dx = e.X - x7; int dy = e.Y - y7;
this.SetBounds(this .Location .X ,this.Location .Y ,this .Width +dx,this .Height +dy);
}
}
#endregion
}
}