心中有你

博客园 首页 新随笔 联系 订阅 管理

最近项目中要用到图像的显示和简单的处理,于是就把这些功能作成了一个控件。放到园子中望大家批评指正。

 完整源码下载

初步完成的功能:浏览图像,缩放,截图,图像缩略定位。

操作:双击打开图像,滚轮缩放,单击中键截图。

 初步完成的效果如下:

1.控件代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace UnicomControl
{
public partial class ImgEditBox : UserControl
{
public ImgEditBox()
{
InitializeComponent();
}
#region 私有域
private Image image = null;//要绘的图形
private float rate=-1;//图形放大比率
private Rectangle imageRect = Rectangle.Empty;//绘图矩形
private Point orginPoint = Point.Empty;//移动图片时移动前鼠标位置
private bool isMouseDown = false;//是否按下了鼠标左键,用来移动图片
private PointArea pointArea = PointArea.NULL;
private ImageSelectBox currentSelctBox = new ImageSelectBox(new Rectangle(100, 100, 100, 100));

//与缩略图有关的域
Color small_boxFillColor = Color.FromArgb(100, 0, 255, 0);
Color small_boxColor = Color.FromArgb(255, 0, 255, 0);
Color small_viewRectColor = Color.Yellow;
Rectangle small_imgRect = new Rectangle();
Rectangle small_viewRect = new Rectangle();
int small_boxSize = 150;

#endregion

#region 属性
public ImageSelectBox CurrentSelctBox
{
get { return this.currentSelctBox; }
}
public Image Image
{
get { return this.image; }
set
{
if(this.image!=null)
{
this.image.Dispose();
}
this.image = value;
if (image == null)
return;
//调整图形放大率使其充满 高或者宽
if(this.image.Width <= image.Width&&this.image.Height<=this.Height)//小图像不放大
{
this.Rate = 1;
}
else
{
if ((float)this.Width / this.Height > (float)image.Width / image.Height)
{
this.Rate = (float)this.Height / image.Height;
}
else
this.Rate = (float)this.Width / image.Width;
}

}
}
public float Rate
{
get { return rate; }
set{
float drate = value - rate;
this.rate = value;
if (rate == -1)
return;
if (Image==null)
return;
int w = (int)(image.Width * rate);
int h = (int)(image.Height * rate);
this.imageRect.Width = w;
this.imageRect.Height = h;
this.imageRect.X = (this.Width - this.imageRect.Width) / 2;
this.imageRect.Y = (this.Height - this.imageRect.Height) / 2;

//MiddleImage();
UpdateSelectBoxWindowRect();
}
}
#endregion
#region 内部处理函数
////当图象长,宽均小于窗口时,居中图像
//private void RateChange(float drate)
//{
////设置绘制图形的矩形

////测试代码

//}
//更新选框的windowrect位置
private void UpdateSelectBoxWindowRect()
{
Rectangle rect = new Rectangle();
rect.Location = this.ViewPointOfImage(this.currentSelctBox.ImageRect.Location);
rect.Width = (int)(this.currentSelctBox.ImageRect.Width * rate);
rect.Height = (int)(this.currentSelctBox.ImageRect.Height * rate);
this.currentSelctBox.WindowRect = rect;
}
//更新选框的imageRect位置
private void UpdateSelectBoxImageRect()
{
Rectangle rect = new Rectangle();
rect.Location = this.ImagePoint(this.currentSelctBox.WindowRect.Location);
rect.Width = (int)(this.currentSelctBox.WindowRect.Width / rate);
rect.Height = (int)(this.currentSelctBox.WindowRect.Height / rate);
this.currentSelctBox.ImageRect = rect;
}
private void MiddleImage()
{
if (Image == null)
return;
int w = (int)(image.Width * rate);
int h = (int)(image.Height * rate);
if (this.imageRect.Width <= this.Width)
{
imageRect.X = this.Width / 2 - w / 2;
}
if (this.imageRect.Height <= this.Height)
{
imageRect.Y = this.Height / 2 - h / 2;
}
}
//当鼠标放置到当前选框上时修改鼠标现状
private void SetCursor(Point p)
{
PointArea pa = this.currentSelctBox.GetMouseArea(p);
switch(pa)
{
case PointArea.Left:
case PointArea.Right:
this.Cursor = Cursors.SizeWE; break;
case PointArea.Top:
case PointArea.Bottom:
this.Cursor = Cursors.SizeNS; break;
case PointArea.TopLeft:
case PointArea.BottomRight:
this.Cursor = Cursors.SizeNWSE; break;
case PointArea.TopRight:
case PointArea.BottomLeft:
this.Cursor = Cursors.SizeNESW; break;
case PointArea.Inner: this.Cursor = Cursors.SizeAll; break;
case PointArea.NULL: this.Cursor = Cursors.Default; break;

}
}

//将控件上一点转换为对应图像上的点的绝对值
public Point ImagePoint(Point point)
{
if (this.Image == null)
return Point.Empty;
Point imgPoint=new Point();
imgPoint.X = (int)((point.X - imageRect.Left) / this.rate);
imgPoint.Y = (int)((point.Y - imageRect.Top) / this.rate);

if (point.X < this.imageRect.Left) imgPoint.X = 0;

if (point.Y < this.imageRect.Top) imgPoint.Y = 0;

if (point.X > this.imageRect.Right) imgPoint.X = this.image.Width;
if (point.Y > this.imageRect.Bottom) imgPoint.Y = this.image.Height;
return imgPoint;
}
//将图像上的点转换为对应的绝对值控件上一点
public Point ViewPointOfImage(Point point)
{
if (this.Image == null)
return Point.Empty;
if (point.X < 0 || point.X > Image.Width || point.Y < 0 || point.Y > Image.Height)
return Point.Empty;
Point viewPoint = new Point();
viewPoint.X = (int)(point.X * Rate + imageRect.Left);
viewPoint.Y = (int)(point.Y * Rate + imageRect.Top);
return viewPoint;
}

//更新是否显示滚动条
//public void DisplayScrollBars()
//{
////Very Important: Reset any previous scrollbar values to 0.
// hScrollBar1.Value = 0;
// vScrollBar1.Value = 0;

////If the image is wider than the picture box, show a horizontal scrollbar.
// if (this.imageRect.Width > this.Width)
// {
// hScrollBar1.Visible = true;
// }
// else
// {
// hScrollBar1.Visible = false;
// }

////If the image is taller than the picture box, show a vertical scrollbar.
// if (this.imageRect.Height > this.Height)
// {
// vScrollBar1.Visible = true;
// }
// else
// {
// vScrollBar1.Visible = false;
// }
//}
//设置滚动条的值
//public void SetScrollBarValues()
//{
// if (this.hScrollBar1.Visible)
// {
// this.hScrollBar1.Minimum = -(this.imageRect.Width - this.Width) / 2;
// this.hScrollBar1.SmallChange = this.imageRect.Width / 20;
// this.hScrollBar1.LargeChange = this.imageRect.Width / 10;

// this.hScrollBar1.Maximum = (this.imageRect.Width - this.Width)/2; //step 1
////计算滚动条的值
// int offset = this.Width / 2 - (this.imageRect.Right + this.imageRect.Left) / 2;
// if(offset>=this.hScrollBar1.Minimum&&offset<=this.hScrollBar1.Maximum)
// this.hScrollBar1.Value = offset;
// else
// {
// if (offset < this.hScrollBar1.Minimum)
// this.hScrollBar1.Value = this.hScrollBar1.Minimum;
// else
// this.hScrollBar1.Value = this.hScrollBar1.Maximum;
// }
// if (this.vScrollBar1.Visible) //step 2
// {
// this.hScrollBar1.Maximum += this.vScrollBar1.Width;
// }

// this.hScrollBar1.Maximum += this.hScrollBar1.LargeChange; //step 3
// }

////Configure the vertical scrollbar
////---------------------------------------------
// if (this.vScrollBar1.Visible)
// {
// this.vScrollBar1.Minimum = -(this.imageRect.Height - this.Height) / 2;
// this.vScrollBar1.SmallChange = this.imageRect.Height / 20;
// this.vScrollBar1.LargeChange = this.imageRect.Height / 10;

// this.vScrollBar1.Maximum = (this.imageRect.Height - this.Height)/2; //step 1
////计算滚动条的值
// int offset=this.Height/2-(this.imageRect.Bottom+this.imageRect.Top)/2;
// if(offset>=this.vScrollBar1.Minimum&&offset<=this.vScrollBar1.Maximum)
// this.vScrollBar1.Value=offset;
// else
// {
// if (offset < this.vScrollBar1.Minimum)
// this.vScrollBar1.Value = this.vScrollBar1.Minimum;
// else
// this.vScrollBar1.Value = this.vScrollBar1.Maximum;
// }

// if (this.hScrollBar1.Visible) //step 2
// {
// this.vScrollBar1.Maximum += this.hScrollBar1.Height;
// }

// this.vScrollBar1.Maximum += this.vScrollBar1.LargeChange; //step 3
// }
//}

//绘制缩略索引部分
private void PaintSmallRegion(Graphics graphcs)
{
if (this.imageRect.Width < this.Width && this.imageRect.Height <= this.Height)
{
return;
}


float small_rate;//图像与窗口的比例,用来确定缩略图上small_imgRect与small_viewRect的比例


Rectangle backRect = new Rectangle(this.Width - small_boxSize-5, this.Height - small_boxSize-5, small_boxSize+1, small_boxSize+1);
GraphicsPath path = CreateRoundedRectanglePath(backRect, 5);
graphcs.FillPath(new SolidBrush(small_boxFillColor), path);
graphcs.DrawPath(new Pen(small_boxColor), path);
//绘制小图像部分
if(this.image.Width>this.image.Height)
{
small_imgRect.Width = small_boxSize;
small_imgRect.Height =(int)( (float)small_boxSize * image.Height / image.Width);

small_rate = (float)this.imageRect.Width /this.ClientRectangle.Width;
small_viewRect.Width = (int)(small_boxSize / small_rate);
small_viewRect.Height = (int)((float)small_viewRect.Width * this.ClientRectangle.Height / this.ClientRectangle.Width);
}
else
{
small_imgRect.Height = small_boxSize;
small_imgRect.Width = (int)((float)small_boxSize * image.Width / image.Height);
small_rate = (float)this.imageRect.Height /this.ClientRectangle.Height;
small_viewRect.Height = (int)(small_boxSize / small_rate);
small_viewRect.Width = (int)((float)small_viewRect.Height * this.ClientRectangle.Width / this.ClientRectangle.Height);
}
small_imgRect.X = (small_boxSize - small_imgRect.Width) / 2+backRect.X+1;
small_imgRect.Y = (small_boxSize - small_imgRect.Height) / 2+backRect.Y+1;
graphcs.DrawImage(image, small_imgRect);

//绘制索引框部分
if(!this.isMouseDown)//当鼠标按下时不将缩略图框放置到中心。
{
small_viewRect.X = (int)(small_imgRect.X + (small_imgRect.Width - small_viewRect.Width) / 2.0f);
small_viewRect.Y = (int)(small_imgRect.Y + (small_imgRect.Height - small_viewRect.Height) / 2.0f);
}

//当图像长、宽只有个个超出屏幕时。
if (small_viewRect.Width>small_imgRect.Width&&small_viewRect.Height<=small_imgRect.Height)
{
small_viewRect.Width = small_imgRect.Width;
small_viewRect.X = small_imgRect.X;
}
if (small_viewRect.Height>small_imgRect.Height&&small_viewRect.Width<=small_imgRect.Width)
{
small_viewRect.Height = small_imgRect.Height;
small_viewRect.Y = small_imgRect.Y;
}
graphcs.DrawRectangle(new Pen(small_viewRectColor), small_viewRect);

//绘制遮罩
GraphicsPath maskPath = new GraphicsPath();
maskPath.AddRectangle(this.small_imgRect);
maskPath.AddRectangle(this.small_viewRect);
graphcs.FillPath(new SolidBrush(Color.FromArgb(150,0,0,0)), maskPath);
}
//圆角矩形路径函数
private GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
{
GraphicsPath roundedRect = new GraphicsPath();
roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
roundedRect.CloseFigure();
return roundedRect;
}
//根据光标在缩略图上的位置来移动图像
private void MoveImageBySmallView(Point mouserPoint)
{
//移动缩略图中的small_viewRect
if (this.small_imgRect.Contains(mouserPoint))
{
int small_dx = mouserPoint.X - (this.small_viewRect.Left + this.small_viewRect.Right) / 2;
int small_dy = mouserPoint.Y - (this.small_viewRect.Top + this.small_viewRect.Bottom) / 2;
if (small_dx > this.small_imgRect.Right - this.small_viewRect.Right)
small_dx = this.small_imgRect.Right - this.small_viewRect.Right;
if (small_dx < this.small_imgRect.Left - this.small_viewRect.Left)
small_dx = this.small_imgRect.Left - this.small_viewRect.Left;
if (small_dy < this.small_imgRect.Top - this.small_viewRect.Top)
small_dy = this.small_imgRect.Top - this.small_viewRect.Top;
if (small_dy > this.small_imgRect.Bottom - this.small_viewRect.Bottom)
small_dy = this.small_imgRect.Bottom - this.small_viewRect.Bottom;
this.small_viewRect.Offset(small_dx, small_dy);
int dx = -(int)((float)small_dx * this.imageRect.Width/this.small_imgRect.Width);
int dy = -(int)((float)small_dy * this.imageRect.Height/this.small_imgRect.Height);
this.imageRect.Offset(dx, dy);
UpdateSelectBoxWindowRect();//更新选框
this.Refresh();
}
}

#endregion

#region 事件处理
private void ImgEditBox_Paint(object sender, PaintEventArgs e)
{
if (this.image == null)
{
return;
}
Graphics gs = e.Graphics;
gs.DrawImage(image, this.imageRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
this.currentSelctBox.Paint(gs);
PaintSmallRegion(gs);
//显示滚动条
//DisplayScrollBars();
//SetScrollBarValues();
}
private void ImgEditBox_Resize(object sender, EventArgs e)
{
if (this.image == null)
return;
if (this.image.Width <= image.Width && this.image.Height <= this.Height)//小图像不放大
{
this.Rate = 1;
}
else
{
if ((float)this.Width / this.Height > (float)image.Width / image.Height)
{
this.Rate = (float)this.Height / image.Height;
}
else
this.Rate = (float)this.Width / image.Width;
}
MiddleImage();
UpdateSelectBoxWindowRect();
this.Refresh();
}

//private void ScrollBar1_Scroll(object sender, ScrollEventArgs e)
//{
// if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
// {
// this.imageRect.Offset( e.OldValue-e.NewValue,0);
// }
// else //e.ScrollOrientation == ScrollOrientation.VerticalScroll
// {
// this.imageRect.Offset(0, e.OldValue - e.NewValue);
// }
// UpdateSelectBoxWindowRect();
// this.Refresh();
//}
private void ImgEditBox_DoubleClick(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
{
return; //...do nothing.
}

//Otherwise display the image in the picture box.
if (this.Image != null)
this.Image.Dispose();
this.Image = Image.FromFile(openFileDialog1.FileName);

//And see if the image needs scrollbars and refresh the image.
//this.DisplayScrollBars();
//this.SetScrollBarValues();
this.Refresh();

}

private void ImgEditBox_MouseDown(object sender, MouseEventArgs e)
{
this.orginPoint = e.Location;
this.isMouseDown = true;
this.pointArea = this.currentSelctBox.GetMouseArea(e.Location);
MoveImageBySmallView(e.Location);
}

private void ImgEditBox_MouseMove(object sender, MouseEventArgs e)
{
SetCursor(e.Location);
int dx = e.X - orginPoint.X;
int dy = e.Y - orginPoint.Y;
if (isMouseDown == true &&this.pointArea==PointArea.NULL)
{
//设置滚动条
if (this.vScrollBar1.Visible == true)
{
if (this.imageRect.Top > 0 && dy > 0 || this.imageRect.Bottom < this.Bottom && dy < 0)
{
this.Refresh();
return;//移出范围了
}
this.imageRect.Offset(0, dy);
}
if (this.hScrollBar1.Visible == true)
{
if (this.imageRect.Left > 0 && dx > 0 || this.imageRect.Right < this.Right && dx < 0)
{
this.Refresh();
return;
}
this.imageRect.Offset(dx, 0);

}
UpdateSelectBoxWindowRect();
this.Refresh();
}
//控制当前选框的大小
if(isMouseDown==true&&this.pointArea!=PointArea.NULL)
{
Rectangle rect = this.currentSelctBox.WindowRect;
if(this.pointArea==PointArea.Left)
{
rect.X += dx;
rect.Width -= dx;
}
if(this.pointArea==PointArea.Right)
rect.Width += dx;
if (this.pointArea == PointArea.Top)
{
rect.Y += dy;
rect.Height -= dy;
}
if (this.pointArea == PointArea.Bottom)
rect.Height += dy;

if (this.pointArea == PointArea.TopLeft)
{
rect.X += dx;
rect.Width -= dx;
rect.Y += dy;
rect.Height -= dy;
}
if (this.pointArea == PointArea.TopRight)
{
rect.Y += dy;
rect.Height -= dy;
rect.Width += dx;
}
if (this.pointArea == PointArea.BottomLeft)
{
rect.Height += dy;
rect.X += dx;
rect.Width -= dx;
}
if (this.pointArea == PointArea.BottomRight)
{
rect.Height += dy;
rect.Width += dx;
}
if(this.pointArea==PointArea.Inner)
{
rect.X += dx;
rect.Y += dy;
}
this.currentSelctBox.WindowRect = rect;
this.UpdateSelectBoxImageRect();//更新图imageRect大小
this.Refresh();
}
//移动缩略图
if (isMouseDown)
{
MoveImageBySmallView(e.Location);
}

this.orginPoint = e.Location;

}

//private void ImgEditBox_KeyDown(object sender, KeyEventArgs e)
//{
// if (e.KeyCode == Keys.Space)
// {
// this.Cursor = Cursors.Hand;
// }
//}

//private void ImgEditBox_KeyUp(object sender, KeyEventArgs e)
//{
// this.Cursor = Cursors.Default;
//}

private void ImgEditBox_MouseUp(object sender, MouseEventArgs e)
{
this.isMouseDown = false;
this.pointArea = PointArea.NULL;
}
#endregion
}
}

2.控件中用到的图像选择框代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Diagnostics;
namespace UnicomControl
{
//图像上的选取类
//光标在那个控制区
public enum PointArea
{
NULL = 0, Inner = 1, Top, Right, Bottom, Left, TopLeft, TopRight, BottomLeft, BottomRight
}

public class ImageSelectBox
{
#region 私有字段
private Rectangle imageRect=Rectangle.Empty;//该选区对应在图像上的矩形
private Rectangle windowRect=Rectangle.Empty;//该选区对应的窗口上的矩形
private bool isCurrentSelectBox = true;//是不是当前正在操作的选框
private Color contrlPointColor=Color.Red;
private int ctr_width = 5;//控制点大小

//八个控制点
public Rectangle Ctr_topLeft { get; set; }
public Rectangle Ctr_topRight { get; set; }
public Rectangle Ctr_bottomLeft { get; set; }
public Rectangle Ctr_bottomRight { get; set; }
public Rectangle Ctr_left { get; set; }
public Rectangle Ctr_top { get; set; }
public Rectangle Ctr_right { get; set; }
public Rectangle Ctr_bottom { get; set; }
#endregion
#region 属性
public Color ContrlPointColor
{
get { return this.contrlPointColor; }
set { this.contrlPointColor = value; }
}
public bool IsCurrentSelectBox
{
get { return this.isCurrentSelectBox; }
set { this.isCurrentSelectBox = value; }
}

public Rectangle ImageRect
{
get { return this.imageRect; }
set { this.imageRect = value; }
}

public Rectangle WindowRect
{
get { return this.windowRect; }
set
{
this.windowRect = value;
//设置并绘制控制点
this.Ctr_topLeft = new Rectangle(windowRect.Left, windowRect.Top, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_topRight = new Rectangle(windowRect.Right - 2 * this.ctr_width, windowRect.Top, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_bottomLeft = new Rectangle(windowRect.Left, windowRect.Bottom - 2 * this.ctr_width, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_bottomRight = new Rectangle(windowRect.Right - 2 * this.ctr_width, windowRect.Bottom - 2 * this.ctr_width, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_left = new Rectangle(windowRect.Left, windowRect.Top + (windowRect.Height) / 2 - this.ctr_width, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_top = new Rectangle(windowRect.Left + (windowRect.Width) / 2 - this.ctr_width, windowRect.Top, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_right = new Rectangle(windowRect.Right - 2 * this.ctr_width, windowRect.Top + (windowRect.Height) / 2 - this.ctr_width, this.ctr_width * 2, this.ctr_width * 2);
this.Ctr_bottom = new Rectangle(windowRect.Left + (windowRect.Width) / 2 - this.ctr_width, windowRect.Bottom - 2 * this.ctr_width, this.ctr_width * 2, this.ctr_width * 2);
}
}

#endregion

public ImageSelectBox(){}

public ImageSelectBox(Rectangle imageRect)
{
this.imageRect = imageRect;
}

public void Paint(Graphics grpcs)//在其父窗口的Paint事件中调用,完成对选框的绘制
{
Pen linePen = new Pen(Color.Red,1);
grpcs.DrawRectangle(linePen, windowRect);
//
if(this.isCurrentSelectBox==true)
{
SolidBrush brush = new SolidBrush(this.contrlPointColor);
grpcs.FillRectangle(brush, this.Ctr_topLeft);
grpcs.FillRectangle(brush, this.Ctr_topRight);
grpcs.FillRectangle(brush, this.Ctr_bottomLeft);
grpcs.FillRectangle(brush, this.Ctr_bottomRight);
grpcs.FillRectangle(brush, this.Ctr_left);
grpcs.FillRectangle(brush, this.Ctr_top);
grpcs.FillRectangle(brush, this.Ctr_right);
grpcs.FillRectangle(brush, this.Ctr_bottom);

}
}
public PointArea GetMouseArea(Point p)
{
if (this.Ctr_topLeft.Contains(p))
{
return PointArea.TopLeft;
}
else if (this.Ctr_topRight.Contains(p))
return PointArea.TopRight;
else if (this.Ctr_top.Contains(p))
return PointArea.Top;
else if (this.Ctr_right.Contains(p))
return PointArea.Right;

else if (this.Ctr_bottomRight.Contains(p))
return PointArea.BottomRight;
else if (this.Ctr_bottomLeft.Contains(p))
return PointArea.BottomLeft;
else if (this.Ctr_bottom.Contains(p))
return PointArea.Bottom;
else if (this.Ctr_left.Contains(p))
return PointArea.Left;

else if (windowRect.Contains(p))
return PointArea.Inner;
else
return PointArea.NULL;

}



}
}



 

posted on 2011-10-25 12:06  心中有你  阅读(951)  评论(3编辑  收藏  举报