//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);
        }
Exemple #2
0
        //Takes the port and validates its location against the shape's path
        public bool ValidatePortLocation(Port port, PointF location)
        {
            //Check for switch changes
            if (!port.AllowRotate)
            {
                PortOrientation orientation = Geometry.GetOrientation(location, Center, Bounds);
                if (port.Orientation != orientation)
                {
                    return(false);
                }
            }

            //Offset location to local co-ordinates and check outline
            location.X -= Bounds.X;
            location.Y -= Bounds.Y;

            return(TransformPath.IsOutlineVisible(location, new Pen(Color.Black, 5)));
        }