C# Custom class MouseEvent update

  • Thread starter Thread starter CY_Chen
  • Start date Start date
C

CY_Chen

Guest
Hi all


I try to do MouseEvent for Custom class Object


Here is code

private void MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseDownPoint = e.Location;
rect = ((CustomClass)sender).Bounds;
((CustomClass)sender).Location = mouseDownPoint;
}//end if
}
private void MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isDrag = true;
rect.Location = getPointToFormRotate(new Point(e.Location.X - mouseDownPoint.X, e.Location.Y - mouseDownPoint.Y));
((CustomClass)sender).Refresh();
}//end if
}
private void MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (isDrag)
{
isDrag = false;
((CustomClass)sender).Location = e.Location;
this.Refresh();
}//end if
reset();
}//end if
}
private Point getPointToFormRotate(Point p1)
{
return PointToClient(R.PointToScreen(p1));
}


The Custom class is draw a photo with GDI


when I move object with mouse event the screen will update again


Like eye binking.


I want it update can only update only in small region(my image size)


In private void MouseMove(object sender, MouseEventArgs e)


((CustomClass)sender).Refresh();


I try to enhance this portion.


But I can't do rect.Refresh(); and ((CustomClass)rect).Refresh();




How to do this?


Only update image size region

Continue reading...
 
Back
Top