private bool SolidContains(PointF location) { //Get boundary RectangleF bounds = TransformRectangle; //If inside inflate boundary if (bounds.Contains(location)) { //Check the outline offset to the path (0,0) location.X -= TransformRectangle.X; location.Y -= TransformRectangle.Y; //Can return in use error try { if (TransformPath.IsVisible(location)) { return(true); } } catch { } } return(false); }
private PointF GetIntercept(PointF location) { //Cache the location properties float x = X; float y = Y; PointF center = Center; //Create transform location moved to the path origin and check if inside path PointF transform = new PointF(location.X - x, location.Y - y); if (TransformPath.IsVisible(transform)) { return(center); } //Get the bounding rectangle intercept and move it to the origin //because all path measurements are from the origin location = Geometry.RectangleIntersection(location, center, TransformRectangle); location = new PointF(location.X - x, location.Y - y); //Get the center of the shape offset to the path origin center = new PointF(center.X - x, center.Y - y); location = Geometry.GetPathIntercept(location, center, TransformPath, Component.Instance.DefaultPen, mTransformInternalRectangle); location = Units.RoundPoint(location, 1); return(new PointF(location.X + x, location.Y + y)); }
//Performs hit testing for an element from a location //if a valid diagram provided, hit testing is performed using current transform private bool ShapeContains(PointF location) { //Inflate rectangle to include selection handles RectangleF bound = TransformRectangle; //Inflate rectangle to include grab handles IRender render = RenderFromContainer(); float handle = 6 * render.ZoomFactor; bound.Inflate(handle, handle); //If inside inflate boundary if (bound.Contains(location)) { //Return true if clicked in selection rectangle but not path rectangle if (Selected && !TransformRectangle.Contains(location)) { return(true); } //Check the outline offset to the path (0,0) location.X -= Rectangle.X; location.Y -= Rectangle.Y; if (DrawBackground) { if (TransformPath.IsVisible(location)) { return(true); } } else { //Get bounding rect float width = BorderWidth + 2; if (TransformPath.IsOutlineVisible(location, new Pen(Color.Black, width))) { return(true); } } } return(false); }