public override void OnMouseMove(MouseEventArgs mouseEvent) { double x = mouseEvent.X; double y = mouseEvent.Y; ParentToChildTransform.inverse_transform(ref x, ref y); m_poly.OnMouseMove(new MouseEventArgs(mouseEvent, x, y)); }
/* * public override bool InRect(double x, double y) * { * return false; * } */ public override void OnMouseDown(MouseEventArgs mouseEvent) { double x = mouseEvent.X; double y = mouseEvent.Y; ParentToChildTransform.inverse_transform(ref x, ref y); m_poly.OnMouseDown(new MouseEventArgs(mouseEvent, x, y)); Invalidate(); base.OnMouseDown(mouseEvent); }
public override void OnMouseMove(MouseEventArgs mouseEvent) { double x = mouseEvent.X; double y = mouseEvent.Y; ParentToChildTransform.inverse_transform(ref x, ref y); m_poly.OnMouseMove(new MouseEventArgs(mouseEvent, x, y)); Invalidate(); BoundsRelativeToParent = m_poly.BoundsRelativeToParent; Invalidate(); base.OnMouseMove(mouseEvent); }
public override void OnMouseDown(MouseEventArgs mouseEvent) { bool ret = false; m_node = -1; m_edge = -1; double x = mouseEvent.X; double y = mouseEvent.Y; ParentToChildTransform.inverse_transform(ref x, ref y); for (int i = 0; i < m_num_points; i++) { if (Math.Sqrt((x - GetXN(i)) * (x - GetXN(i)) + (y - GetYN(i)) * (y - GetYN(i))) < m_point_radius) { m_dx = x - GetXN(i); m_dy = y - GetYN(i); m_node = (int)(i); ret = true; break; } } if (!ret) { for (int i = 0; i < m_num_points; i++) { if (check_edge(i, x, y)) { m_dx = x; m_dy = y; m_edge = (int)(i); ret = true; break; } } } if (!ret) { if (point_in_polygon(x, y)) { m_dx = x; m_dy = y; m_node = (int)(m_num_points); ret = true; } } Invalidate(); base.OnMouseDown(mouseEvent); }
public override void OnMouseMove(MouseEventArgs mouseEvent) { bool handled = false; double dx; double dy; double x = mouseEvent.X; double y = mouseEvent.Y; ParentToChildTransform.inverse_transform(ref x, ref y); if (m_node == (int)(m_num_points)) { dx = x - m_dx; dy = y - m_dy; for (int i = 0; i < m_num_points; i++) { SetXN(i, GetXN(i) + dx); SetYN(i, GetYN(i) + dy); } m_dx = x; m_dy = y; handled = true; } else { if (m_edge >= 0) { int n1 = (int)m_edge; int n2 = (n1 + m_num_points - 1) % m_num_points; dx = x - m_dx; dy = y - m_dy; SetXN(n1, GetXN(n1) + dx); SetYN(n1, GetYN(n1) + dy); SetXN(n2, GetXN(n2) + dx); SetYN(n2, GetYN(n2) + dy); m_dx = x; m_dy = y; handled = true; } else { if (m_node >= 0) { SetXN((int)m_node, x - m_dx); SetYN((int)m_node, y - m_dy); handled = true; } } } // TODO: set bounds correctly and invalidate if (handled) { if (Changed != null) { Changed(this, null); } RecalculateBounds(); } base.OnMouseMove(mouseEvent); }