2007-01-05

C#模仿QQ截图功能

来源: CSDN 作者:往事随风 评论 0 条
 
for(int i = 1;i < 9;i )
{
if(GetHandleRect(i).Contains(p))
{
index=i;
break;
}
}
if(this.area.Contains(p))index = 0;

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)
共8页: 上一页 [1] [2] [3] [4] [5] [6] 7 [8] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:Java应用web开发备用工具  
下一篇:详细讲述Java中的克隆
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号