Exemplo n.º 1
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
            RectangleF pixRect = Location.TransformRect(pane);

            Matrix matrix = new Matrix();

            if (pixRect.Right == 0)
            {
                pixRect.Width = 1;
            }
            float angle = (float)Math.Atan((pixRect.Top - pixRect.Bottom) /
                                           (pixRect.Left - pixRect.Right));

            matrix.Rotate(angle, MatrixOrder.Prepend);

            // Move the coordinate system to local coordinates
            // of this text object (that is, at the specified
            // x,y location)
            matrix.Translate(-pixRect.Left, -pixRect.Top, MatrixOrder.Prepend);

            PointF[] pts = new PointF[4];
            pts[0] = new PointF(0, 3);
            pts[1] = new PointF(pixRect.Width, 3);
            pts[2] = new PointF(pixRect.Width, -3);
            pts[3] = new PointF(0, -3);
            matrix.TransformPoints(pts);

            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);
        }
Exemplo n.º 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
            RectangleF pixRect = Location.TransformRect(pane);

            shape  = "rect";
            coords = String.Format("{0:f0},{1:f0},{2:f0},{3:f0}",
                                   pixRect.Left, pixRect.Top, pixRect.Right, pixRect.Bottom);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="BoxObj"/>.
        /// </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
            RectangleF pixRect = Location.TransformRect(pane);

            return(pixRect.Contains(pt));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="BoxObj"/>.
        /// </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
            RectangleF pixRect = Location.TransformRect(pane);

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(pixRect);
                return(path.IsVisible(pt));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Render this 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)
        {
            if (_image != null)
            {
                // Convert the rectangle coordinates from the user coordinate system
                // to the screen coordinate system
                RectangleF tmpRect = Location.TransformRect(pane);

                if (_isScaled)
                {
                    g.DrawImage(_image, tmpRect);
                }
                else
                {
                    Region clip = g.Clip;
                    g.SetClip(tmpRect);
                    g.DrawImageUnscaled(_image, Rectangle.Round(tmpRect));
                    g.SetClip(clip, CombineMode.Replace);
                    //g.DrawImageUnscaledAndClipped( image, Rectangle.Round( tmpRect ) );
                }
            }
        }