예제 #1
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="TextObj"/>.  This method takes into account rotation and alignment
        /// parameters of the text, as specified in the <see cref="FontSpec"/>.
        /// </summary>
        /// <param name="pt">The screen point, in pixels</param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <returns>true if the point lies in the bounding box, false otherwise</returns>
        override public bool PointInBox(PointF pt, PaneBase pane, Graphics g, float scaleFactor)
        {
            if (!base.PointInBox(pt, pane, g, scaleFactor))
            {
                return(false);
            }

            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = Location.Transform(pane);

            return(_fontSpec.PointInBox(pt, g, _text, pix.X, pix.Y,
                                        Location.AlignH, Location.AlignV, scaleFactor, this.LayoutArea));
        }
예제 #2
0
        /// <summary>
        /// Determines the shape type and Coords values for this GraphObj
        /// </summary>
        override public void GetCoords(PaneBase pane, Graphics g, float scaleFactor,
                                       out string shape, out string coords)
        {
            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = Location.Transform(pane);

            PointF[] pts = _fontSpec.GetBox(g, _text, pix.X, pix.Y, Location.AlignH,
                                            Location.AlignV, scaleFactor, new SizeF());

            shape  = "poly";
            coords = String.Format("{0:f0},{1:f0},{2:f0},{3:f0},{4:f0},{5:f0},{6:f0},{7:f0},",
                                   pts[0].X, pts[0].Y, pts[1].X, pts[1].Y,
                                   pts[2].X, pts[2].Y, pts[3].X, pts[3].Y);
        }
예제 #3
0
        /// <summary>
        /// Render this <see cref="TextObj"/> object to the specified <see cref="Graphics"/> device
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        override public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = Location.Transform(pane);

            // Draw the text on the screen, including any frame and background
            // fill elements
            if (pix.X > -100000 && pix.X < 100000 && pix.Y > -100000 && pix.Y < 100000)
            {
                //if ( this.layoutSize.IsEmpty )
                //	this.FontSpec.Draw( g, pane.IsPenWidthScaled, this.text, pix.X, pix.Y,
                //		this.location.AlignH, this.location.AlignV, scaleFactor );
                //else
                this.FontSpec.Draw(g, pane, _text, pix.X, pix.Y,
                                   Location.AlignH, Location.AlignV, scaleFactor, _layoutArea);
            }
        }
예제 #4
0
        internal GraphicsPath MakePath(PaneBase pane)
        {
            GraphicsPath path   = new GraphicsPath();
            bool         first  = true;
            PointF       lastPt = new PointF();

            foreach (PointD pt in _points)
            {
                // Convert the coordinates from the user coordinate system
                // to the screen coordinate system
                // Offset the points by the location value
                PointF pixPt = Location.Transform(pane, pt.X + Location.X, pt.Y + Location.Y,
                                                  Location.CoordinateFrame);

                if (Math.Abs(pixPt.X) < 100000 &&
                    Math.Abs(pixPt.Y) < 100000)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        path.AddLine(lastPt, pixPt);
                    }

                    lastPt = pixPt;
                }
            }

            if (_isClosedFigure)
            {
                path.CloseFigure();
            }

            return(path);
        }