Ejemplo n.º 1
0
        void MapObject(PlotArea plotArea, MigraDoc.DocumentObjectModel.Shapes.Charts.PlotArea domPlotArea)
        {
            plotArea.BottomPadding = domPlotArea.BottomPadding.Point;
            plotArea.RightPadding  = domPlotArea.RightPadding.Point;
            plotArea.LeftPadding   = domPlotArea.LeftPadding.Point;
            plotArea.TopPadding    = domPlotArea.TopPadding.Point;

            if (!domPlotArea.IsNull("LineFormat"))
            {
                LineFormatMapper.Map(plotArea.LineFormat, domPlotArea.LineFormat);
            }
            if (!domPlotArea.IsNull("FillFormat"))
            {
                FillFormatMapper.Map(plotArea.FillFormat, domPlotArea.FillFormat);
            }
        }
Ejemplo n.º 2
0
        void MapObject(Chart chart, DocumentObjectModel.Shapes.Charts.Chart domChart)
        {
            DocumentObjectModel.Shapes.Charts.Legend   domLegend = null;
            DocumentObjectModel.Shapes.Charts.TextArea textArea  = null;

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.BottomArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Bottom;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.BottomArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.RightArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Right;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.RightArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.LeftArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Left;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.LeftArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.TopArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Top;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.TopArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.HeaderArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Top;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.HeaderArea;
                }
            }

            foreach (DocumentObjectModel.DocumentObject domObj in domChart.FooterArea.Elements)
            {
                if (domObj is DocumentObjectModel.Shapes.Charts.Legend)
                {
                    chart.Legend.Docking = DockingType.Bottom;
                    domLegend            = domObj as DocumentObjectModel.Shapes.Charts.Legend;
                    textArea             = domChart.FooterArea;
                }
            }

            if (domLegend != null)
            {
                if (!domLegend.IsNull("LineFormat"))
                {
                    LineFormatMapper.Map(chart.Legend.LineFormat, domLegend.LineFormat);
                }
                if (!textArea.IsNull("Style"))
                {
                    FontMapper.Map(chart.Legend.Font, textArea.Document, textArea.Style);
                }
                if (!domLegend.IsNull("Format.Font"))
                {
                    FontMapper.Map(chart.Legend.Font, domLegend.Format.Font);
                }
            }
        }
Ejemplo n.º 3
0
        static void MapObject(Axis axis, DocumentObjectModel.Shapes.Charts.Axis domAxis)
        {
            if (!domAxis.IsNull("TickLabels.Format"))
            {
                axis.TickLabels.Format = domAxis.TickLabels.Format;
            }
            if (!domAxis.IsNull("TickLabels.Style"))
            {
                FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Document, domAxis.TickLabels.Style);
            }
            if (!domAxis.IsNull("TickLabels.Font"))
            {
                FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Font);
            }

            if (!domAxis.IsNull("MajorTickMark"))
            {
                axis.MajorTickMark = (TickMarkType)domAxis.MajorTickMark;
            }
            if (!domAxis.IsNull("MinorTickMark"))
            {
                axis.MinorTickMark = (TickMarkType)domAxis.MinorTickMark;
            }

            if (!domAxis.IsNull("MajorTick"))
            {
                axis.MajorTick = domAxis.MajorTick;
            }
            if (!domAxis.IsNull("MinorTick"))
            {
                axis.MinorTick = domAxis.MinorTick;
            }

            if (!domAxis.IsNull("Title"))
            {
                axis.Title.Caption = domAxis.Title.Caption;
                if (!domAxis.IsNull("Title.Style"))
                {
                    FontMapper.Map(axis.Title.Font, domAxis.Title.Document, domAxis.Title.Style);
                }
                if (!domAxis.IsNull("Title.Font"))
                {
                    FontMapper.Map(axis.Title.Font, domAxis.Title.Font);
                }
                axis.Title.Orientation       = domAxis.Title.Orientation.Value;
                axis.Title.Alignment         = (HorizontalAlignment)domAxis.Title.Alignment;
                axis.Title.VerticalAlignment = (VerticalAlignment)domAxis.Title.VerticalAlignment;
            }

            axis.HasMajorGridlines = domAxis.HasMajorGridlines;
            axis.HasMinorGridlines = domAxis.HasMinorGridlines;

            if (!domAxis.IsNull("MajorGridlines") && !domAxis.MajorGridlines.IsNull("LineFormat"))
            {
                LineFormatMapper.Map(axis.MajorGridlines.LineFormat, domAxis.MajorGridlines.LineFormat);
            }
            if (!domAxis.IsNull("MinorGridlines") && !domAxis.MinorGridlines.IsNull("LineFormat"))
            {
                LineFormatMapper.Map(axis.MinorGridlines.LineFormat, domAxis.MinorGridlines.LineFormat);
            }

            if (!domAxis.IsNull("MaximumScale"))
            {
                axis.MaximumScale = domAxis.MaximumScale;
            }
            if (!domAxis.IsNull("MinimumScale"))
            {
                axis.MinimumScale = domAxis.MinimumScale;
            }

            if (!domAxis.IsNull("LineFormat"))
            {
                LineFormatMapper.Map(axis.LineFormat, domAxis.LineFormat);
            }
        }
Ejemplo n.º 4
0
        internal static void Map(LineFormat lineFormat, DocumentObjectModel.Shapes.LineFormat domLineFormat)
        {
            LineFormatMapper mapper = new LineFormatMapper();

            mapper.MapObject(lineFormat, domLineFormat);
        }
Ejemplo n.º 5
0
        void MapObject(SeriesCollection seriesCollection, DocumentObjectModel.Shapes.Charts.SeriesCollection domSeriesCollection)
        {
            foreach (DocumentObjectModel.Shapes.Charts.Series domSeries in domSeriesCollection)
            {
                Series series = seriesCollection.AddSeries();
                series.Name = domSeries.Name;

                if (domSeries.IsNull("ChartType"))
                {
                    DocumentObjectModel.Shapes.Charts.Chart chart = (DocumentObjectModel.Shapes.Charts.Chart)DocumentObjectModel.DocumentRelations.GetParentOfType(domSeries, typeof(DocumentObjectModel.Shapes.Charts.Chart));
                    series.ChartType = (ChartType)chart.Type;
                }
                else
                {
                    series.ChartType = (ChartType)domSeries.ChartType;
                }

                if (!domSeries.IsNull("DataLabel"))
                {
                    DataLabelMapper.Map(series.DataLabel, domSeries.DataLabel);
                }
                if (!domSeries.IsNull("LineFormat"))
                {
                    LineFormatMapper.Map(series.LineFormat, domSeries.LineFormat);
                }
                if (!domSeries.IsNull("FillFormat"))
                {
                    FillFormatMapper.Map(series.FillFormat, domSeries.FillFormat);
                }

                series.HasDataLabel = domSeries.HasDataLabel;
                if (domSeries.MarkerBackgroundColor.IsEmpty)
                {
                    series.MarkerBackgroundColor = XColor.Empty;
                }
                else
                {
#if noCMYK
                    series.MarkerBackgroundColor = XColor.FromArgb(domSeries.MarkerBackgroundColor.Argb);
#else
                    series.MarkerBackgroundColor =
                        ColorHelper.ToXColor(domSeries.MarkerBackgroundColor, domSeries.Document.UseCmykColor);
#endif
                }
                if (domSeries.MarkerForegroundColor.IsEmpty)
                {
                    series.MarkerForegroundColor = XColor.Empty;
                }
                else
                {
#if noCMYK
                    series.MarkerForegroundColor = XColor.FromArgb(domSeries.MarkerForegroundColor.Argb);
#else
                    series.MarkerForegroundColor =
                        ColorHelper.ToXColor(domSeries.MarkerForegroundColor, domSeries.Document.UseCmykColor);
#endif
                }
                series.MarkerSize = domSeries.MarkerSize.Point;
                if (!domSeries.IsNull("MarkerStyle"))
                {
                    series.MarkerStyle = (MarkerStyle)domSeries.MarkerStyle;
                }

                foreach (DocumentObjectModel.Shapes.Charts.Point domPoint in domSeries.Elements)
                {
                    if (domPoint != null)
                    {
                        Point point = series.Add(domPoint.Value);
                        FillFormatMapper.Map(point.FillFormat, domPoint.FillFormat);
                        LineFormatMapper.Map(point.LineFormat, domPoint.LineFormat);
                    }
                    else
                    {
                        series.Add(double.NaN);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 internal static void Map(LineFormat lineFormat, DocumentObjectModel.Shapes.LineFormat domLineFormat)
 {
     LineFormatMapper mapper = new LineFormatMapper();
     mapper.MapObject(lineFormat, domLineFormat);
 }