return index;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
if(this.Capture)
{
this.MoveHandleTo(new Point(e.X,e.Y));
this.Invalidate();
}
else
{
this.index = this.GetSelectedHandle(new Point(e.X,e.Y));
this.SetCursor();
}
}
private void MoveHandleTo(Point point)
{
int left = area.Left;
int top = area.Top;
int right = area.Right;
int bottom = area.Bottom;
switch ( index )
{
case 0:
area.X =point.X - this.pot.X;
area.Y = point.Y - pot.Y;
this.pot = point;
return;
case 1:
left = point.X;
top = point.Y;
break;
case 2:
top = point.Y;
break;
case 3:
right = point.X;
top = point.Y;
break;
case 4:
right = point.X;
break;
case 5:
right = point.X;
bottom = point.Y;
break;
case 6:
bottom = point.Y;
break;
case 7:
left = point.X;
bottom = point.Y;
break;
case 8:
left = point.X;
break;
}
this.pot = point;
area.X = left;
area.Y = top;
area.Width = right - left;
area.Height = bottom - top;
}
private void MouseCaptureForm_DoubleClick(object sender, System.EventArgs e)
{
//修正截取图片过界提示内存不足BUG
int left = area.Left;
int right = area.Right;
int top = area.Top;
int bottom = area.Bottom;
if(left < Screen.PrimaryScreen.Bounds.Left)
{left = Screen.PrimaryScreen.Bounds.Left; }
if(right > Screen.PrimaryScreen.Bounds.Right )
{right = Screen.PrimaryScreen.Bounds.Right;}
if(top < Screen.PrimaryScreen.Bounds.Top)
{top = Screen.PrimaryScreen.Bounds.Top;}
if(bottom > Screen.PrimaryScreen.Bounds.Bottom)
{bottom = Screen.PrimaryScreen.Bounds.Bottom;}
area.X = left;
area.Y = top;
area.Width = right - left;
area.Height = bottom - top;
//截取选择区域图片
Bitmap bm = new Bitmap(this.BackgroundImage);
this.img = bm.Clone(this.area,System.Drawing.Imaging.PixelFormat.Format16bppArgb1555);
CaptureScreenForm.image = img;
CaptureScreenForm.ActiveForm.Invalidate();
this.Close();
}
private void MouseCaptureForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyData == Keys.Escape && System.Windows.Forms.Button.MouseButtons == MouseButtons.Left)
评论加载中…
![]() |