Esempio n. 1
0
 public virtual void Draw(Graphics g, ToPhysicalAngleDelegate converter)
 {
     foreach (AngledItem item in Items)
     {
         item.Draw(g, converter);
     }
 }
Esempio n. 2
0
 internal GraphicItemSet(PolygonControl cc)
 {
     this.Container = cc;
     Items          = new List <T>();
     Toolkit        = new List <IDisposable>();
     Mapper         = new ToPhysicalAngleDelegate(Container.PhysicalAngleOf);
 }
Esempio n. 3
0
 public AngledItemSet(PolygonControl container)
     : base(container)
 {
     AngleOffset = 0f;
     //Mapper = new ToControlPositionDelegate(ToControlPosition);
     Mapper = new ToPhysicalAngleDelegate(toContainerAngle);
     //Container.UnitSizeChanged += new PolygonControl.UnitSizeChangedDelegate(Container_UnitSizeChanged);
 }
Esempio n. 4
0
        public override void Draw(Graphics g, ToPhysicalAngleDelegate angleOf)
        {
            if (!IsVisible)
            {
                return;
            }

            //if (angleOf == null)
            //    angleOf = Container.PhysicalAngleOf;

            GraphicsPath path = Multiply(Path, Container.UnitSize * DefaultSymbolSize);

            if (Distance != 0 || Angle != 0)
            {
                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);
                PointF pos = new PointF(x, y);

                Matrix translateMatrix = new Matrix();
                translateMatrix.Translate(pos.X, pos.Y);
                path.Transform(translateMatrix);
                translateMatrix.Dispose();
            }

            if (IsHighlighted)
            {
                HighLight(g, path);
            }
            else
            {
                drawWithLeadingLine(g, path);
            }

            if (DisplayHint)
            {
                drawHint(g);
            }

            path.Dispose();
        }
Esempio n. 5
0
        //public override void Resize(float sizeFactor)
        //{
        //    //Distance *= sizeFactor;
        //    if (IsFixed)
        //        return;

        //    Path = Multiply(Path, Container.UnitSize);

        //    //List<PointF> points = new List<PointF>();
        //    //for (int i = 0; i < Path.PathPoints.Length; i++)
        //    //{
        //    //    PointF pt = Path.PathPoints[i];
        //    //    pt.X *= sizeFactor;
        //    //    pt.Y *= sizeFactor;
        //    //    points.Add(pt);
        //    //}

        //    //Path = new GraphicsPath(points.ToArray(), Path.PathTypes);
        //}

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

        //    if (angleOf == null)
        //        angleOf = Container.RelativeToCenter;

        //    GraphicsPath all = new GraphicsPath();
        //    //float rotated = Container.AngleOffset;

        //    for (float angleLow = 0; angleLow < 360f; angleLow += 360f / Repetition)
        //    {
        //        GraphicsPath path = Multiply(Path, Container.UnitSize);
        //        if (BypassPredicate != null && BypassPredicate(angleLow))
        //            continue;

        //        Matrix matrix = new Matrix();

        //        PointF pos = angleOf(Distance, angleLow, 0);
        //        matrix.Translate(pos.X, pos.Y);

        //        float physicalAngle = Container.AngleOf(pos);
        //        matrix.Rotate(physicalAngle + Rotation);

        //        //angleLow = Container.PhysicalAngleOf(angleLow);
        //        //matrix.Rotate(angleLow);

        //        //matrix.Rotate((Container.IsClockwise ? angleLow : -angleLow) + rotated);

        //        path.Transform(matrix);

        //        all.AddPath(path, false);
        //    }

        //    drawPath(g, all);
        //}

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

            if (angleOf == null)
            {
                angleOf = Container.PhysicalAngleOf;
            }

            GraphicsPath all = new GraphicsPath();

            for (float angle = 0; angle < 360f; angle += 360f / Repetition)
            {
                GraphicsPath path = Multiply(Path, Container.UnitSize);
                if (BypassPredicate != null && BypassPredicate(angle))
                {
                    continue;
                }

                Matrix matrix = new Matrix();

                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);
                PointF pos = new PointF(x, y);

                matrix.Translate(pos.X, pos.Y);

                matrix.Rotate(actualAngle + Rotation);

                path.Transform(matrix);

                all.AddPath(path, false);
            }

            drawPath(g, all);
        }
Esempio n. 6
0
        public override void Draw(Graphics g, ToPhysicalAngleDelegate angleOf)
        {
            if (!IsVisible)
            {
                return;
            }

            if (angleOf == null)
            {
                angleOf = Container.PhysicalAngleOf;
            }

            GraphicsPath path = Multiply(Path, Container.UnitSize);

            if (Distance != 0 || Angle != 0)
            {
                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);
                PointF pos = new PointF(x, y);

                Matrix translateMatrix = new Matrix();
                translateMatrix.Translate(pos.X, pos.Y);

                translateMatrix.Rotate(actualAngle + Rotation);

                //if (Rotation != 0)
                //    translateMatrix.Rotate(Container.AngleOffset + (Container.IsClockwise ? Rotation : -Rotation));
                path.Transform(translateMatrix);
                translateMatrix.Dispose();
            }

            drawPath(g, path);

            path.Dispose();
        }
Esempio n. 7
0
        //public override void Resize(float sizeFactor)
        //{
        //    if (!IsFixed)
        //        Radius *= sizeFactor;
        //}

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

            if (angleOf == null)
            {
                angleOf = Container.PhysicalAngleOf;
            }

            float actualDistance = Radius * Container.UnitSize;
            float actualAngle    = angleOf(-45);
            float x = (float)Math.Round(actualDistance * COS(actualAngle), 4);
            float y = (float)Math.Round(actualDistance * SIN(actualAngle), 4);

            PointF corner1 = new PointF(x, y);
            PointF corner2 = new PointF(-x, -y);

            x = Math.Min(corner1.X, corner2.X);
            y = Math.Min(corner1.Y, corner2.Y);
            float width  = Math.Max(corner1.X, corner2.X) - x;
            float height = Math.Max(corner1.Y, corner2.Y) - y;

            RectangleF rect = new RectangleF(x, y, width, height);

            if (IsFilled && TheBrush != Brushes.Transparent)
            {
                g.FillEllipse(TheBrush, rect);
            }

            if (IsBordered)
            {
                g.DrawEllipse(ThePen, rect);
            }
        }
Esempio n. 8
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);
             *  }
             * }
             * //*/
        }
Esempio n. 9
0
 public abstract void Draw(Graphics g, ToPhysicalAngleDelegate angleOf);