Exemplo n.º 1
0
        public override LegendItem[] GetLegendItems()
        {
            // TODO: determine how to respect line width in legend
            var singleLegendItem = new Config.LegendItem(label, color, lineStyle, lineWidth, markerShape, markerSize);

            return(new LegendItem[] { singleLegendItem });
        }
Exemplo n.º 2
0
        private static void DrawLegendItemLine(Config.LegendItem legendItem, Settings settings, PointF itemLocation, int padding, int stubWidth, float ySpaceBetweenItems)
        {
            if (legendItem.lineWidth == 0 || legendItem.lineStyle == LineStyle.None)
            {
                return;
            }

            float  yCenter = itemLocation.Y + ySpaceBetweenItems / 2;
            PointF xMin    = new PointF(itemLocation.X + padding, yCenter);
            PointF xMax    = new PointF(itemLocation.X + padding + stubWidth, yCenter);

            if (legendItem.lineWidth < 10)
            {
                Pen pen = GDI.Pen(legendItem.color, (float)legendItem.lineWidth, legendItem.lineStyle);
                settings.gfxLegend.DrawLine(pen, xMin, xMax);
            }
            else
            {
                Brush  brush       = new SolidBrush(legendItem.color);
                float  halfHeight  = (float)(legendItem.lineWidth / 2);
                PointF topLeft     = new PointF(xMin.X, xMin.Y - halfHeight);
                float  symbolWidth = xMax.X - xMin.X;
                settings.gfxLegend.FillRectangle(brush, topLeft.X, topLeft.Y, symbolWidth, (float)legendItem.lineWidth);
            }
        }
Exemplo n.º 3
0
        private static void DrawLegendItemString(Config.LegendItem legendItem, Settings settings, PointF itemLocation, int padding, int stubWidth, float legendFontLineHeight)
        {
            Brush brushText    = new SolidBrush(settings.legend.colorText);
            var   textLocation = itemLocation + new Size(padding + stubWidth + padding, 0);

            settings.gfxLegend.DrawString(legendItem.label, settings.legend.font, brushText, textLocation);
        }
Exemplo n.º 4
0
        public override LegendItem[] GetLegendItems()
        {
            var singleLegendItem = new Config.LegendItem(label, color)
            {
                lineStyle   = LineStyle.Solid,
                lineWidth   = lineWidth,
                markerShape = (markersAreVisible) ? MarkerShape.filledCircle : MarkerShape.none,
                markerSize  = (markersAreVisible) ? markerSize : 0
            };

            return(new LegendItem[] { singleLegendItem });
        }
Exemplo n.º 5
0
        private static void DrawLegendItemLine(Config.LegendItem legendItem, Settings settings, Point itemLocation, int padding, int stubWidth, float legendFontLineHeight)
        {
            if (legendItem.lineWidth == 0 || legendItem.lineStyle == LineStyle.None)
            {
                return;
            }

            Pen pen = new Pen(legendItem.color, (float)legendItem.lineWidth)
            {
                DashPattern = StyleTools.DashPattern(legendItem.lineStyle)
            };

            settings.gfxLegend.DrawLine(pen,
                                        itemLocation.X + padding, itemLocation.Y + legendFontLineHeight / 2,
                                        itemLocation.X + padding + stubWidth, itemLocation.Y + legendFontLineHeight / 2);
        }
Exemplo n.º 6
0
        public override LegendItem[] GetLegendItems()
        {
            var singleLegendItem = new Config.LegendItem(label, color);

            return(new LegendItem[] { singleLegendItem });
        }
Exemplo n.º 7
0
        public override LegendItem[] GetLegendItems()
        {
            var singleLegendItem = new Config.LegendItem(label, color, lineStyle, pen.Width, MarkerShape.none);

            return(new LegendItem[] { singleLegendItem });
        }
Exemplo n.º 8
0
        public override LegendItem[] GetLegendItems()
        {
            var singleLegendItem = new Config.LegendItem(label, color, markerShape: MarkerShape.none);

            return(new LegendItem[] { singleLegendItem });
        }
Exemplo n.º 9
0
        private static void DrawLegendItemMarker(Config.LegendItem legendItem, Settings settings, PointF itemLocation, int padding, int stubWidth, float legendFontLineHeight)
        {
            if (legendItem.markerSize == 0 || legendItem.markerShape == MarkerShape.none)
            {
                return;
            }

            Brush brushMarker = new SolidBrush(legendItem.color);
            Pen   penMarker   = new Pen(legendItem.color, 1);

            PointF corner1 = new PointF(itemLocation.X + 2 * padding + settings.legend.font.Size / 4, itemLocation.Y + settings.legend.font.Size / 4 * padding);
            PointF center  = new PointF
            {
                X = corner1.X + settings.legend.font.Size / 4,
                Y = corner1.Y + settings.legend.font.Size / 4
            };

            RectangleF rect = new RectangleF(
                x: itemLocation.X + 2 * padding + settings.legend.font.Size / 4,
                y: itemLocation.Y + settings.legend.font.Size / 4 + padding,
                width: settings.legend.font.Size / 2,
                height: settings.legend.font.Size / 2
                );

            Font textFont = new Font("CourierNew", settings.legend.font.Size);

            // TODO: move this switch to tools or something.
            // Sureley the legend isn't the only place this switch lives.
            switch (legendItem.markerShape)
            {
            case MarkerShape.none:
                //Nothing to do because the Drawline needs to be there for all cases, and it's already there
                break;

            case MarkerShape.asterisk:
                PointF markerPositionAsterisk = itemLocation + new Size(padding * 2, (int)(legendFontLineHeight / 4));
                settings.gfxLegend.DrawString("*", textFont, brushMarker, markerPositionAsterisk);
                break;

            case MarkerShape.cross:
                PointF markerPositionCross = itemLocation + new Size(padding * 2, (int)(legendFontLineHeight / 8));
                settings.gfxLegend.DrawString("+", textFont, brushMarker, markerPositionCross);
                break;

            case MarkerShape.eks:
                PointF markerPositionEks = itemLocation + new Size(padding * 2, 0);
                settings.gfxLegend.DrawString("x", textFont, brushMarker, markerPositionEks);
                break;

            case MarkerShape.filledCircle:
                settings.gfxLegend.FillEllipse(brushMarker, rect);
                break;

            case MarkerShape.filledDiamond:
                // Create points that define polygon.
                PointF[] curvePoints =
                {
                    new PointF(center.X,                                 center.Y + settings.legend.font.Size / 4),
                    new PointF(center.X - settings.legend.font.Size / 4, center.Y),
                    new PointF(center.X,                                 center.Y - settings.legend.font.Size / 4),
                    new PointF(center.X + settings.legend.font.Size / 4, center.Y),
                };
                //Draw polygon to screen
                settings.gfxLegend.FillPolygon(brushMarker, curvePoints);
                break;

            case MarkerShape.filledSquare:
                settings.gfxLegend.FillRectangle(brushMarker, rect);
                break;

            case MarkerShape.hashTag:
                PointF markerPositionHashTag = itemLocation + new Size(padding * 2, (int)(legendFontLineHeight / 8));
                settings.gfxLegend.DrawString("#", textFont, brushMarker, markerPositionHashTag);
                break;

            case MarkerShape.openCircle:
                settings.gfxLegend.DrawEllipse(penMarker, rect);
                break;

            case MarkerShape.openDiamond:
                // Create points that define polygon.
                PointF[] curvePoints2 =
                {
                    new PointF(center.X,                                 center.Y + settings.legend.font.Size / 4),
                    new PointF(center.X - settings.legend.font.Size / 4, center.Y),
                    new PointF(center.X,                                 center.Y - settings.legend.font.Size / 4),
                    new PointF(center.X + settings.legend.font.Size / 4, center.Y),
                };
                //Draw polygon to screen
                settings.gfxLegend.DrawPolygon(penMarker, curvePoints2);
                break;

            case MarkerShape.openSquare:
                settings.gfxLegend.DrawRectangle(penMarker, corner1.X, corner1.Y, settings.legend.font.Size / 2, settings.legend.font.Size / 2);
                break;

            case MarkerShape.triDown:
                // Create points that define polygon.
                PointF[] curvePoints4 =
                {
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X,                                                center.Y + settings.legend.font.Size / 2),
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X - settings.legend.font.Size / 2 * (float)0.866, center.Y - settings.legend.font.Size / 2 * (float)0.5),
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X + settings.legend.font.Size / 2 * (float)0.866, center.Y - settings.legend.font.Size / 2 * (float)0.5),
                };
                //Draw polygon to screen
                settings.gfxLegend.DrawPolygon(penMarker, curvePoints4);
                break;

            case MarkerShape.triUp:
                // Create points that define polygon.
                PointF[] curvePoints3 =
                {
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X,                                                center.Y - settings.legend.font.Size / 2),
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X - settings.legend.font.Size / 2 * (float)0.866, center.Y + settings.legend.font.Size / 2 * (float)0.5),
                    new PointF(center.X,                                                center.Y),
                    new PointF(center.X + settings.legend.font.Size / 2 * (float)0.866, center.Y + settings.legend.font.Size / 2 * (float)0.5),
                };
                //Draw polygon to screen
                settings.gfxLegend.DrawPolygon(penMarker, curvePoints3);
                break;

            case MarkerShape.verticalBar:
                PointF markerPositionVertical = itemLocation + new Size(padding * 2, 0);
                settings.gfxLegend.DrawString("|", textFont, brushMarker, markerPositionVertical);
                break;
            }
        }
Exemplo n.º 10
0
        public override LegendItem[] GetLegendItems()
        {
            var singleLegendItem = new Config.LegendItem(label, color, markerSize: 0, lineWidth: 10);

            return(new LegendItem[] { singleLegendItem });
        }