예제 #1
0
        public virtual void Rewind()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            int i;
            int j;

            iterator.NextMarker(out i, out j);
            iterator.NextMarker(out i, out j);

            iterator.Rewind();
            iterator.NextMarker(out i, out j);

            Assert.AreEqual(0, i);
            Assert.AreEqual(3, j);
        }
예제 #2
0
        public virtual void NextMarker_Int32_Int32()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            int start;
            int end;
            int count = iterator.NextMarker(out start, out end);

            Assert.AreEqual(4, count);
            Assert.AreEqual(0, start);
            Assert.AreEqual(3, end);

            count = iterator.NextMarker(out start, out end);
            Assert.AreEqual(4, count);
            Assert.AreEqual(4, start);
            Assert.AreEqual(7, end);

            count = iterator.NextMarker(out start, out end);
            Assert.AreEqual(4, count);
            Assert.AreEqual(8, start);
            Assert.AreEqual(11, end);

            count = iterator.NextMarker(out start, out end);
            Assert.AreEqual(2, count);
            Assert.AreEqual(12, start);
            Assert.AreEqual(13, end);

            // FIXME - should return all 0'z?

            /*
             * count = iterator.NextMarker (out start, out end);
             * Assert.AreEqual (0, count);
             * Assert.AreEqual (12, start);
             * Assert.AreEqual (13, end);
             */
        }
예제 #3
0
        /// <summary>
        /// Insert new map area items into the collection.
        /// </summary>
        /// <param name="index">Index to insert at.</param>
        /// <param name="toolTip">Tool tip.</param>
        /// <param name="url">Jump URL.</param>
        /// <param name="attributes">Other area attributes.</param>
        /// <param name="postBackValue">The post back value associated with this item.</param>
        /// <param name="path">Area coordinates as graphics path.</param>
        /// <param name="absCoordinates">Absolute coordinates in the graphics path.</param>
        /// <param name="graph">Chart graphics object.</param>
        internal void InsertPath(
            int index,
            string toolTip,
            string url,
            string attributes,
            string postBackValue,
            GraphicsPath path,
            bool absCoordinates,
            ChartGraphics graph)
        {
            // If there is more then one graphical path split them and create
            // image maps for every graphical path separately.
            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            // There is more then one path.
            if (iterator.SubpathCount > 1)
            {
                GraphicsPath subPath = new GraphicsPath();
                while (iterator.NextMarker(subPath) > 0)
                {
                    InsertSubpath(index, toolTip, url, attributes, postBackValue, subPath, absCoordinates, graph);
                    subPath.Reset();
                }
            }
            // There is only one path
            else
            {
                InsertSubpath(index, toolTip, url, attributes, postBackValue, path, absCoordinates, graph);
            }
        }
 public void NextMarker_Path_ReturnsExpected()
 {
     using (GraphicsPath gp = new GraphicsPath(_twoPoints, new byte[] { 0, 1 }))
         using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
         {
             Assert.Equal(2, gpi.NextMarker(gp));
         }
 }
예제 #5
0
 public void NextMarker_Null()
 {
     using (GraphicsPath gp = new GraphicsPath()) {
         gp.AddLines(pts_2f);
         using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp)) {
             Assert.AreEqual(0, gpi.NextMarker(null));
         }
     }
 }
 public void NextMarker_EmptyPath_ReturnsExpected()
 {
     using (GraphicsPath gp = new GraphicsPath())
         using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
         {
             gp.AddLines(_twoPoints);
             Assert.Equal(0, gpi.NextMarker(gp));
         }
 }
        private GraphicsPath GetPathForIndex(int index)
        {
            var path = new GraphicsPath();
            GraphicsPathIterator iterator = new GraphicsPathIterator(_OriginalPath);

            iterator.Rewind();
            for (int i = 0; i <= index; i++)
            {
                iterator.NextMarker(path);
            }
            return(path);
        }
        public void Rewind_Success()
        {
            using (GraphicsPath gp = new GraphicsPath())
                using (GraphicsPath inner = new GraphicsPath())
                {
                    gp.AddLine(0, 1, 2, 3);
                    gp.SetMarkers();
                    gp.StartFigure();
                    gp.AddLine(20, 21, 22, 23);
                    gp.AddBezier(5, 6, 7, 8, 9, 10, 11, 12);

                    using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
                    {
                        Assert.Equal(2, gpi.SubpathCount);
                        Assert.Equal(2, gpi.NextMarker(gp));
                        Assert.Equal(6, gpi.NextMarker(gp));
                        Assert.Equal(0, gpi.NextMarker(gp));
                        gpi.Rewind();
                        Assert.Equal(8, gpi.NextMarker(gp));
                        Assert.Equal(0, gpi.NextMarker(gp));
                    }
                }
        }
예제 #9
0
        /// <summary>
        /// Gets the key associated with the region at the given point.
        /// </summary>
        /// <param name="point">The Point to look for a region.</param>
        /// <returns>The object tag if point is within a region, otherwise null.</returns>
        public object GetRegionTag(Point point)
        {
            GraphicsPath         pathTemp     = new GraphicsPath();
            GraphicsPathIterator pathIterator = new GraphicsPathIterator(paths);

            pathIterator.Rewind();

            for (int i = 0; i < pathIterator.SubpathCount; i++)
            {
                pathIterator.NextMarker(pathTemp);
                if (pathTemp.IsVisible(point))
                {
                    return(pathTags[i]);
                }
            }

            return(null); // not found
        }
예제 #10
0
        public void Insert(int index, string toolTip, string href, string attr, GraphicsPath path, bool absCoordinates, MapGraphics graph)
        {
            GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(path);

            if (graphicsPathIterator.SubpathCount > 1)
            {
                GraphicsPath graphicsPath = new GraphicsPath();
                while (graphicsPathIterator.NextMarker(graphicsPath) > 0)
                {
                    this.InsertSubpath(index, toolTip, href, attr, graphicsPath, absCoordinates, graph);
                    graphicsPath.Reset();
                }
            }
            else
            {
                this.InsertSubpath(index, toolTip, href, attr, path, absCoordinates, graph);
            }
        }
예제 #11
0
        private int getActiveIndexAtPoint(Point point, out GraphicsPath origpath)
        {
            var path = new GraphicsPath();

            origpath = new GraphicsPath();
            GraphicsPathIterator iterator     = new GraphicsPathIterator(_ScaledPath);
            GraphicsPathIterator iteratororig = new GraphicsPathIterator(_OriginalPath);

            iterator.Rewind();
            iteratororig.Rewind();
            for (int current = 0; current < iterator.SubpathCount; current++)
            {
                iterator.NextMarker(path);
                iteratororig.NextMarker(origpath);
                if (path.IsVisible(point, _Graphics))
                {
                    return(current);
                }
            }
            return(-1);
        }
예제 #12
0
        // </snippet3>


        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPathIterator.NextMarker(System.Drawing.Drawing2D.GraphicsPath)
        // <snippet4>
        public void NextMarkerExample2(PaintEventArgs e)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up primitives to add to myPath.
            Point[] myPoints = { new Point(20,  20), new Point(120, 120),
                                 new Point(20, 120), new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,
            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;

            PointF[] myPathPoints = myPath.PathPoints;
            byte[]   myPathTypes  = myPath.PathTypes;

            // Set up variables for listing all the values of the path's
            // points to the screen.
            int        i;
            float      j       = 20;
            Font       myFont  = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the values for all of path points and types to
            // the left side of the screen.
            for (i = 0; i < myPathPointCount; i++)
            {
                e.Graphics.DrawString(myPathPoints[i].X.ToString() +
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(), myFont, myBrush,
                                      20, j);

                j += 20;
            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                                                  GraphicsPathIterator(myPath);

            // Rewind the iterator.
            myPathIterator.Rewind();

            // Create a GraphicsPath to receive a section of myPath.
            GraphicsPath myPathSection = new GraphicsPath();

            // Retrieve and list the number of points contained in

            // the first marker to the right side of the screen.
            int markerPoints;

            markerPoints = myPathIterator.NextMarker(myPathSection);
            e.Graphics.DrawString("Marker: 1" + "  Num Points: " +
                                  markerPoints.ToString(), myFont, myBrush, 200, 20);
        }
예제 #13
0
        // </snippet4>


        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPathIterator.NextMarker(System.Int32@,System.Int32@)
        // <snippet5>
        private void NextMarkerExample(PaintEventArgs e)
        {
            // Create the GraphicsPath.
            GraphicsPath myPath = new GraphicsPath();

            Point[] myPoints = { new Point(20,  20), new Point(120, 120),
                                 new Point(20, 120), new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,

            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;

            PointF[] myPathPoints = myPath.PathPoints;
            byte[]   myPathTypes  = myPath.PathTypes;

            // Set up variables for drawing the array

            // of points to the screen.
            int        i;
            float      j       = 20;
            Font       myFont  = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // Draw the set of path points and types to the screen.
            for (i = 0; i < myPathPointCount; i++)
            {
                e.Graphics.DrawString(myPathPoints[i].X.ToString() +
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j += 20;
            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                                                  GraphicsPathIterator(myPath);
            int myStartIndex;
            int myEndIndex;

            // Rewind the Iterator.
            myPathIterator.Rewind();

            // Draw the Markers and their start and end points

            // to the screen.
            j = 20;
            for (i = 0; i < 3; i++)
            {
                myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
                e.Graphics.DrawString("Marker " + i.ToString() +
                                      ":  Start: " + myStartIndex.ToString() +
                                      "  End: " + myEndIndex.ToString(),
                                      myFont,
                                      myBrush,
                                      200,
                                      j);
                j += 20;
            }

            // Draw the total number of points to the screen.
            j += 20;
            int myPathTotalPoints = myPathIterator.Count;

            e.Graphics.DrawString("Total Points = " +
                                  myPathTotalPoints.ToString(),
                                  myFont,
                                  myBrush,
                                  200,
                                  j);
        }
예제 #14
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        ///


        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPathIterator.CopyData(System.Drawing.PointF[]@,System.Byte[]@,System.Int32,System.Int32)
        // <snippet1>
        public void CopyDataExample(PaintEventArgs e)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up a points array.
            Point[] myPoints =
            {
                new Point(20,   20),
                new Point(120, 120),
                new Point(20,  120),
                new Point(20, 20)
            };

            // Create a rectangle.
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add the points, rectangle, and an ellipse to the path.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path, and arrays of
            // the  points and types.
            int myPathPointCount = myPath.PointCount;

            PointF[] myPathPoints = myPath.PathPoints;
            byte[]   myPathTypes  = myPath.PathTypes;

            // Set up variables for listing the array of points on the left
            // side of the screen.
            int        i;
            float      j       = 20;
            Font       myFont  = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the set of points and types and types to the left side
            // of the screen.
            for (i = 0; i < myPathPointCount; i++)
            {
                e.Graphics.DrawString(myPathPoints[i].X.ToString() +
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j += 20;
            }

            // Create a GraphicsPathIterator for myPath and rewind it.
            GraphicsPathIterator myPathIterator =
                new GraphicsPathIterator(myPath);

            myPathIterator.Rewind();

            // Set up the arrays to receive the copied data.
            PointF[] points = new PointF[myPathIterator.Count];
            byte[]   types  = new byte[myPathIterator.Count];
            int      myStartIndex;
            int      myEndIndex;

            // Increment the starting index to the second marker in the
            // path.
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);

            // Copy all the points and types from the starting index to the
            // ending index to the points array and the types array
            // respectively.
            int numPointsCopied = myPathIterator.CopyData(
                ref points,
                ref types,
                myStartIndex,
                myEndIndex);

            // List the copied points to the right side of the screen.
            j = 20;
            int copiedStartIndex = 0;

            for (i = 0; i < numPointsCopied; i++)
            {
                copiedStartIndex = myStartIndex + i;
                e.Graphics.DrawString(
                    "Point: " + copiedStartIndex.ToString() +
                    ", Value: " + points[i].ToString() +
                    ", Type: " + types[i].ToString(),
                    myFont,
                    myBrush,
                    200,
                    j);
                j += 20;
            }
        }
예제 #15
0
        public void NextSubpath_NextMarker()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(10, 10, 50, 50);              // figure #1
            path.AddLine(50, 50, 80, 80);
            path.AddLine(90, 90, 100, 100);
            path.SetMarkers();              // marker #1
            path.AddLine(150, 150, 180, 180);
            path.SetMarkers();              // marker #2
            path.StartFigure();             // figure #2
            path.SetMarkers();              // marker #3 is actually marker #2
            path.AddRectangle(new Rectangle(200, 200, 200, 200));
            path.SetMarkers();              // marker #4
            path.AddLine(150, 150, 180, 180);
            path.StartFigure();             // figure #3
            path.AddBezier(400, 400, 500, 500, 600, 600, 700, 700);
            path.AddBezier(450, 450, 550, 550, 650, 650, 750, 750);

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            int  start;
            int  end;
            bool isClosed;
            int  count = iterator.NextMarker(out start, out end);            // marker #1

            Assert.AreEqual(5, count);
            Assert.AreEqual(0, start);
            Assert.AreEqual(4, end);

            count = iterator.NextSubpath(out start, out end, out isClosed);            // figure #1
            Assert.AreEqual(7, count);
            Assert.AreEqual(0, start);
            Assert.AreEqual(6, end);
            Assert.AreEqual(false, isClosed);

            count = iterator.NextMarker(out start, out end);             // marker #2 (and #3)
            Assert.AreEqual(2, count);
            Assert.AreEqual(5, start);
            Assert.AreEqual(6, end);

            count = iterator.NextSubpath(out start, out end, out isClosed);            // figure #2
            Assert.AreEqual(4, count);
            Assert.AreEqual(7, start);
            Assert.AreEqual(10, end);
            Assert.AreEqual(true, isClosed);

            count = iterator.NextSubpath(out start, out end, out isClosed);            // figure #3
            Assert.AreEqual(2, count);
            Assert.AreEqual(11, start);
            Assert.AreEqual(12, end);
            Assert.AreEqual(false, isClosed);

            count = iterator.NextMarker(out start, out end);             // marker #5 (end)
            Assert.AreEqual(4, count);
            Assert.AreEqual(7, start);
            Assert.AreEqual(10, end);

            count = iterator.NextMarker(out start, out end);             // marker #5 (end)
            Assert.AreEqual(10, count);
            Assert.AreEqual(11, start);
            Assert.AreEqual(20, end);

            // we dont want to be bug compliant with .net

            /*
             * count = iterator.NextMarker (out start,out end); // no more markers
             * Assert.AreEqual (0, count);
             * Assert.AreEqual (11, start);
             * Assert.AreEqual (20, end);
             */

            count = iterator.NextSubpath(out start, out end, out isClosed);            // figure #4
            Assert.AreEqual(8, count);
            Assert.AreEqual(13, start);
            Assert.AreEqual(20, end);
            Assert.AreEqual(false, isClosed);

            // we dont want to be bug compliant with .net

            /*
             * count = iterator.NextMarker (out start,out end); // no more markers
             * Assert.AreEqual (0, count);
             * Assert.AreEqual (13, start);
             * Assert.AreEqual (20, end);
             */

            count = iterator.NextSubpath(out start, out end, out isClosed);            // no more figures
            Assert.AreEqual(0, count);
            Assert.AreEqual(0, start);
            Assert.AreEqual(0, end);
            Assert.AreEqual(true, isClosed);

            count = iterator.NextMarker(out start, out end);             // no more markers
            Assert.AreEqual(0, count);
            Assert.AreEqual(0, start);
            Assert.AreEqual(0, end);
        }
예제 #16
0
        //public override void Draw(Graphics g, ToControlPositionDelegate angleOf)
        //{
        //    if (!IsVisible) return;

        //    SizeF labelSize = g.MeasureString(Label, LabelFont);
        //    float shift = (float)(0.5 * Math.Max(Math.Abs(labelSize.Width * COS(Rotation)), Math.Abs(labelSize.Height * SIN(Rotation))));
        //    PointF displayCenter = angleOf(Distance, Angle, shift);

        //    RectangleF rect = new RectangleF(displayCenter.X - labelSize.Width / 2f, displayCenter.Y - labelSize.Height / 2f, labelSize.Width, labelSize.Height);

        //    if (Rotation == 0)
        //    {
        //        if (IsFilled)
        //            g.FillRectangle(TheBrush, rect);

        //        if (IsBordered)
        //            g.DrawRectangle(ThePen, new Rectangle((int)(rect.X), (int)rect.Y, (int)rect.Width, (int)rect.Height));

        //        g.DrawString(Label, LabelFont, FontBrush, rect);
        //    }
        //    else
        //    {
        //        GraphicsPath path = new GraphicsPath();

        //        if (IsFilled || IsBordered)
        //        {
        //            path.AddRectangle(rect);
        //            path.SetMarkers();
        //        }

        //        path.AddString(Label, LabelFont.FontFamily, (int)LabelFont.Style, 26, rect, StringFormat.GenericDefault);

        //        Matrix translateMatrix = new Matrix();
        //        float rotation = Container.IsXReversed ? Rotation : 180 + Rotation;
        //        translateMatrix.RotateAt((Container.IsClockwise ? Angle : -Angle) + rotation, displayCenter);

        //        path.Transform(translateMatrix);

        //        if (!IsBordered && !IsFilled)
        //        {
        //            g.FillPath(FontBrush, path);
        //        }
        //        else
        //        {
        //            // Create a GraphicsPathIterator for handPath.
        //            GraphicsPathIterator pathIterator = new
        //                GraphicsPathIterator(path);

        //            // Rewind the iterator.
        //            pathIterator.Rewind();

        //            // Create the GraphicsPath section.
        //            GraphicsPath pathSection = new GraphicsPath();

        //            // to the screen.
        //            int subpathPoints = pathIterator.NextMarker(pathSection);

        //            drawPath(g, pathSection);

        //            subpathPoints = pathIterator.NextMarker(pathSection);

        //            g.FillPath(FontBrush, pathSection);
        //        }
        //    }

        //}

        public override void Draw(Graphics g, ToPhysicalAngleDelegate angleOf)
        {
            if (!IsVisible)
            {
                return;
            }

            SizeF labelSize = g.MeasureString(Label, LabelFont);

            //float shift = (float)(0.5 * Math.Max(Math.Abs(labelSize.Width * COS(Rotation)), Math.Abs(labelSize.Height * SIN(Rotation))));

            float actualDistance = Distance * Container.UnitSize;
            float actualAngle    = angleOf(Angle);

            float      x    = (float)Math.Round(actualDistance * COS(actualAngle), 4);
            float      y    = (float)Math.Round(actualDistance * SIN(actualAngle), 4);
            RectangleF rect = new RectangleF(x, y, labelSize.Width, labelSize.Height);

            if (Rotation == 0)
            {
                rect.X -= labelSize.Width / 2f;
                rect.Y -= labelSize.Height / 2f;
                if (IsFilled)
                {
                    g.FillRectangle(TheBrush, rect);
                }

                if (IsBordered)
                {
                    g.DrawRectangle(ThePen, new Rectangle((int)(rect.X), (int)rect.Y, (int)rect.Width, (int)rect.Height));
                }

                g.DrawString(Label, LabelFont, FontBrush, rect);
            }
            else
            {
                rect.X -= labelSize.Width / 2f;
                rect.Y -= labelSize.Height / 2f;

                //float cos = COS(actualAngle);
                //float sin = SIN(actualAngle);
                //rect.X -= (cos >= 0 ? cos : -cos) * labelSize.Width / 2f;
                //rect.Y -= (sin >= 0 ? sin : -sin) * labelSize.Height / 2f;

                float rotation = actualAngle - Rotation;

                GraphicsPath path = new GraphicsPath();

                if (IsFilled || IsBordered)
                {
                    path.AddRectangle(rect);
                    path.SetMarkers();
                }

                path.AddString(Label, LabelFont.FontFamily, (int)LabelFont.Style, LabelFont.Size, rect, StringFormat.GenericDefault);

                Matrix translateMatrix = new Matrix();

                translateMatrix.RotateAt(rotation, new PointF(x, y));

                path.Transform(translateMatrix);

                if (!IsBordered && !IsFilled)
                {
                    g.FillPath(FontBrush, path);
                }
                else
                {
                    // Create a GraphicsPathIterator for handPath.
                    GraphicsPathIterator pathIterator = new
                                                        GraphicsPathIterator(path);

                    // Rewind the iterator.
                    pathIterator.Rewind();

                    // Create the GraphicsPath section.
                    GraphicsPath pathSection = new GraphicsPath();

                    // to the screen.
                    int subpathPoints = pathIterator.NextMarker(pathSection);

                    drawPath(g, pathSection);

                    subpathPoints = pathIterator.NextMarker(pathSection);

                    g.FillPath(FontBrush, pathSection);
                }
            }


            /*/
             * SizeF labelSize = g.MeasureString(Label, LabelFont);
             * float shift = (float)(0.5 * Math.Max(Math.Abs(labelSize.Width * COS(Rotation)), Math.Abs(labelSize.Height * SIN(Rotation))));
             *
             * float actualDistance = Distance * Container.UnitSize + shift;
             * float actualAngle = angleOf(Angle);
             * float x = (float)Math.Round(actualDistance * COS(actualAngle), 4);
             * float y = (float)Math.Round(actualDistance * SIN(actualAngle), 4);
             * PointF displayCenter = new PointF(x, y);
             *
             * RectangleF rect = new RectangleF(displayCenter.X - labelSize.Width / 2f, displayCenter.Y - labelSize.Height / 2f, labelSize.Width, labelSize.Height);
             *
             * if (Rotation == 0)
             * {
             *  if (IsFilled)
             *      g.FillRectangle(TheBrush, rect);
             *
             *  if (IsBordered)
             *      g.DrawRectangle(ThePen, new Rectangle((int)(rect.X), (int)rect.Y, (int)rect.Width, (int)rect.Height));
             *
             *  g.DrawString(Label, LabelFont, FontBrush, rect);
             * }
             * else
             * {
             *  GraphicsPath path = new GraphicsPath();
             *
             *  if (IsFilled || IsBordered)
             *  {
             *      path.AddRectangle(rect);
             *      path.SetMarkers();
             *  }
             *
             *  path.AddString(Label, LabelFont.FontFamily, (int)LabelFont.Style, 26, rect, StringFormat.GenericDefault);
             *
             *  Matrix translateMatrix = new Matrix();
             *
             *  //float rotation = Container.IsXReversed ? Rotation : 180 + Rotation;
             *  //translateMatrix.RotateAt((Container.IsClockwise ? Angle : -Angle) + rotation, displayCenter);
             *  float rotation = actualAngle + Rotation;
             *  translateMatrix.RotateAt(rotation, displayCenter);
             *
             *  path.Transform(translateMatrix);
             *
             *  if (!IsBordered && !IsFilled)
             *  {
             *      g.FillPath(FontBrush, path);
             *  }
             *  else
             *  {
             *      // Create a GraphicsPathIterator for handPath.
             *      GraphicsPathIterator pathIterator = new
             *          GraphicsPathIterator(path);
             *
             *      // Rewind the iterator.
             *      pathIterator.Rewind();
             *
             *      // Create the GraphicsPath section.
             *      GraphicsPath pathSection = new GraphicsPath();
             *
             *      // to the screen.
             *      int subpathPoints = pathIterator.NextMarker(pathSection);
             *
             *      drawPath(g, pathSection);
             *
             *      subpathPoints = pathIterator.NextMarker(pathSection);
             *
             *      g.FillPath(FontBrush, pathSection);
             *  }
             * }
             * //*/
        }
예제 #17
0
        internal void CheckHotRegions(int x, int y, ChartElementType requestedElement, bool ignoreTransparent, out string series, out int point, out ChartElementType type, out object obj, out object subObj)
        {
            obj    = null;
            subObj = null;
            point  = 0;
            series = "";
            type   = ChartElementType.Nothing;
            RectangleF rectangleF        = new RectangleF(x - 1, y - 1, 2f, 2f);
            float      x2                = common.graph.GetRelativePoint(new PointF(x, y)).X;
            float      y2                = common.graph.GetRelativePoint(new PointF(x, y)).Y;
            RectangleF relativeRectangle = common.graph.GetRelativeRectangle(rectangleF);
            bool       flag              = false;
            int        num               = regionList.Count - 1;
            HotRegion  hotRegion;

            while (true)
            {
                if (num < 0)
                {
                    return;
                }
                hotRegion = (HotRegion)regionList[num];
                float      x3;
                float      y3;
                RectangleF rect;
                if (hotRegion.RelativeCoordinates)
                {
                    x3   = x2;
                    y3   = y2;
                    rect = relativeRectangle;
                }
                else
                {
                    x3   = x;
                    y3   = y;
                    rect = rectangleF;
                }
                if (requestedElement == ChartElementType.Nothing || requestedElement == hotRegion.Type)
                {
                    flag = false;
                    if (hotRegion.SeriesName.Length > 0 && (common == null || common.Chart.Series.GetIndex(hotRegion.SeriesName) < 0 || hotRegion.PointIndex >= common.Chart.Series[hotRegion.SeriesName].Points.Count))
                    {
                        if (!common.Chart.IsDesignMode())
                        {
                            goto IL_0290;
                        }
                        if (common.Chart.Series.GetIndex(hotRegion.SeriesName) > -1 && hotRegion.PointIndex > -1)
                        {
                            flag = true;
                        }
                    }
                    if ((!ignoreTransparent || !IsElementTransparent(hotRegion)) && hotRegion.BoundingRectangle.IntersectsWith(rect))
                    {
                        bool flag2 = false;
                        if (hotRegion.Path != null)
                        {
                            GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(hotRegion.Path);
                            if (graphicsPathIterator.SubpathCount > 1)
                            {
                                GraphicsPath graphicsPath = new GraphicsPath();
                                while (graphicsPathIterator.NextMarker(graphicsPath) > 0 && !flag2)
                                {
                                    if (graphicsPath.IsVisible(x3, y3))
                                    {
                                        flag2 = true;
                                    }
                                    graphicsPath.Reset();
                                }
                            }
                            else if (hotRegion.Path.IsVisible(x3, y3))
                            {
                                flag2 = true;
                            }
                        }
                        else
                        {
                            flag2 = true;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                }
                goto IL_0290;
IL_0290:
                num--;
            }
            if (flag)
            {
                series = hotRegion.SeriesName;
                point  = -1;
                obj    = common.Chart.Series[hotRegion.SeriesName];
                type   = ChartElementType.Nothing;
            }
            else
            {
                series = hotRegion.SeriesName;
                point  = hotRegion.PointIndex;
                obj    = hotRegion.SelectedObject;
                subObj = hotRegion.SelectedSubObject;
                type   = hotRegion.Type;
            }
        }
예제 #18
0
        internal override void Paint(Chart chart, ChartGraphics graphics)
        {
            Chart = chart;
            PointF location       = PointF.Empty;
            PointF anchorLocation = PointF.Empty;
            SizeF  size           = SizeF.Empty;

            GetRelativePosition(out location, out size, out anchorLocation);
            PointF     pointF     = new PointF(location.X + size.Width, location.Y + size.Height);
            RectangleF rect       = new RectangleF(location, new SizeF(pointF.X - location.X, pointF.Y - location.Y));
            RectangleF rectangleF = new RectangleF(rect.Location, rect.Size);

            if (rectangleF.Width < 0f)
            {
                rectangleF.X     = rectangleF.Right;
                rectangleF.Width = 0f - rectangleF.Width;
            }
            if (rectangleF.Height < 0f)
            {
                rectangleF.Y      = rectangleF.Bottom;
                rectangleF.Height = 0f - rectangleF.Height;
            }
            if (float.IsNaN(rectangleF.X) || float.IsNaN(rectangleF.Y) || float.IsNaN(rectangleF.Right) || float.IsNaN(rectangleF.Bottom))
            {
                return;
            }
            GraphicsPath graphicsPath = null;

            if (Chart.chartPicture.common.ProcessModePaint)
            {
                switch (calloutStyle)
                {
                case CalloutStyle.SimpleLine:
                    graphicsPath = DrawRectangleLineCallout(graphics, rectangleF, anchorLocation, drawRectangle: false);
                    break;

                case CalloutStyle.Borderline:
                    graphicsPath = DrawRectangleLineCallout(graphics, rectangleF, anchorLocation, drawRectangle: true);
                    break;

                case CalloutStyle.Perspective:
                    graphicsPath = DrawPerspectiveCallout(graphics, rectangleF, anchorLocation);
                    break;

                case CalloutStyle.Cloud:
                    graphicsPath = DrawCloudCallout(graphics, rectangleF, anchorLocation);
                    break;

                case CalloutStyle.Rectangle:
                    graphicsPath = DrawRectangleCallout(graphics, rectangleF, anchorLocation);
                    break;

                case CalloutStyle.Ellipse:
                    graphicsPath = DrawRoundedRectCallout(graphics, rectangleF, anchorLocation, isEllipse: true);
                    break;

                case CalloutStyle.RoundedRectangle:
                    graphicsPath = DrawRoundedRectCallout(graphics, rectangleF, anchorLocation, isEllipse: false);
                    break;
                }
            }
            if (Chart.chartPicture.common.ProcessModeRegions)
            {
                if (graphicsPath != null)
                {
                    GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(graphicsPath);
                    GraphicsPath         graphicsPath2        = new GraphicsPath();
                    while (graphicsPathIterator.NextMarker(graphicsPath2) > 0)
                    {
                        Chart.chartPicture.common.HotRegionsList.AddHotRegion(graphics, (GraphicsPath)graphicsPath2.Clone(), relativePath: false, ReplaceKeywords(ToolTip), ReplaceKeywords(Href), ReplaceKeywords(MapAreaAttributes), this, ChartElementType.Annotation);
                        graphicsPath2.Reset();
                    }
                }
                else
                {
                    Chart.chartPicture.common.HotRegionsList.AddHotRegion(graphics, rectangleF, ReplaceKeywords(ToolTip), ReplaceKeywords(Href), ReplaceKeywords(MapAreaAttributes), this, ChartElementType.Annotation, string.Empty);
                }
            }
            PaintSelectionHandles(graphics, rect, null);
        }
예제 #19
0
        public virtual void NextMarker_GraphicsPath()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));
            path.StartFigure();
            path.SetMarkers();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.SetMarkers();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));
            path.StartFigure();
            path.SetMarkers();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            GraphicsPath path2 = new GraphicsPath();

            path.AddLine(new Point(150, 150), new Point(450, 150));
            path.AddLine(new Point(450, 250), new Point(50, 150));

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            iterator.NextMarker(null);
            iterator.NextMarker(path2);

            Assert.AreEqual(4, path2.PointCount);
            PointF [] actualPoints = path2.PathPoints;
            byte []   actualTypes  = path2.PathTypes;

            PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
                                                       new PointF(400f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(10f, 100f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }

            iterator.NextMarker(null);
            iterator.NextMarker(null);
            iterator.NextMarker(null);
            iterator.NextMarker(path2);

            Assert.AreEqual(4, path2.PointCount);
            actualPoints = path2.PathPoints;
            actualTypes  = path2.PathTypes;

            expectedPoints = new PointF [] { new PointF(10f, 10f),
                                             new PointF(50f, 250f),
                                             new PointF(100f, 5f),
                                             new PointF(200f, 280f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            expectedTypes = new byte [] { (byte)PathPointType.Start,
                                          (byte)PathPointType.Bezier3,
                                          (byte)PathPointType.Bezier3,
                                          (byte)(PathPointType.Bezier3 | PathPointType.PathMarker) };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }
        }