PointFromPointF() public static method

public static PointFromPointF ( PointF pointf ) : Point
pointf System.Drawing.PointF
return Point
Esempio n. 1
0
        // Hit test against highlighted handles, return the location of the best one, or (Nan, Nan) if none.
        public PointF HitTestHandles(PointF locationTest, bool testBeziers)
        {
            return(new PointF(float.NaN, float.NaN));

#if false
            float  bestDistance = float.MaxValue;
            PointF bestPoint    = new PointF(float.NaN, float.NaN);

            if (currentHighlights == null)
            {
                return(bestPoint);
            }

            RectangleF hitBounds;

            // Compute the hit bounds rectangle. A point must be within this rectangle
            // to be considered. This is equivalent to making sure the actual handle square is clicked on
            Point     locationPixel = Util.PointFromPointF(WorldToPixel(locationTest));
            Rectangle rectPixel     = new Rectangle(locationPixel.X - HandleRadius, locationPixel.Y - HandleRadius, HandleDiameter, HandleDiameter);
            hitBounds = PixelToWorld(rectPixel);

            // Determine the closest point of those handles that were clicked on.
            for (int i = 0; i < currentHighlights.handles.Length; ++i)
            {
                PointF pt = currentHighlight.handles[i];

                // Don't check bezier handles unless requested to.
                if (!testBeziers && currentHighlight.handleKinds[i] == PointKind.BezierControl)
                {
                    continue;
                }

                if (hitBounds.Contains(pt))
                {
                    float distance = Util.DistanceF(pt, locationTest);
                    if (distance < bestDistance)
                    {
                        bestDistance = distance;
                        bestPoint    = pt;
                    }
                }
            }

            return(bestPoint);
#endif
        }
Esempio n. 2
0
        void DrawHighlights(Graphics g, Rectangle visRect, IMapViewerHighlight[] highlights)
        {
            if (highlights == null)
            {
                return;
            }

            // Set the rendering origin so the hatch brushes draw correctly and don't scroll weirdly.
            PointF origin = WorldToPixel(new PointF(0, 0));

            g.RenderingOrigin = Util.PointFromPointF(origin);
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;

            foreach (IMapViewerHighlight h in highlights)
            {
                h.DrawHighlight(g, xformWorldToPixel);
            }
        }