/// <summary>
        /// Overloaded constructor used create an instance of the PieModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// IPieChart interface object passed as the parameter.
        /// </summary>
        /// <param name="chart"></param>
        public PieModel(IPieChart chart)
        {
            // simple properties
            Header = chart.Header;
            Footer = chart.Footer;

            // styles
            Style             = StyleSerializer.StyleToString(chart.GetStyle(), chart as IBrushConverter);
            HeaderStyle       = StyleSerializer.StyleToString(chart.GetStyle("Header"), chart as IBrushConverter);
            FooterStyle       = StyleSerializer.StyleToString(chart.GetStyle("Footer"), chart as IBrushConverter);
            HeaderBorderStyle = StyleSerializer.StyleToString(chart.GetStyle("HeaderBorder"), chart as IBrushConverter);
            FooterBorderStyle = StyleSerializer.StyleToString(chart.GetStyle("FooterBorder"), chart as IBrushConverter);
            PlotStyle         = StyleSerializer.StyleToString(chart.GetStyle("Plot"), chart as IBrushConverter);
            SelectedStyle     = StyleSerializer.StyleToString(chart.GetStyle("Selected"), chart as IBrushConverter);

            InnerRadius = chart.InnerRadius;
            Offset      = chart.Offset;
            StartAngle  = chart.StartAngle;
            Reversed    = chart.Reversed;

            // data
            Values = chart.GetValues();
            Names  = chart.GetNames();

            Legend    = new LegendModel(chart.Legend, chart);
            DataLabel = new PieDataLabelModel(chart.DataLabel, chart);
        }
        /// <summary>
        /// Overloaded constructor used create an instance of the AxisModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// IAxis interface object passed as the parameter.
        /// </summary>
        /// <param name="ax">Specifies the IAxis interface object to be serialized.</param>
        public AxisModel(IAxis ax)
        {
            Position          = ax.Position;
            AxisType          = ax.AxisType;
            Origin            = ax.Origin;
            Reversed          = ax.Reversed;
            Labels            = ax.Labels;
            MajorTickMarks    = ax.MajorTickMarks;
            MajorGrid         = ax.MajorGrid;
            MajorUnit         = ax.MajorUnit;
            MinorTickMarks    = ax.MinorTickMarks;
            MinorGrid         = ax.MinorGrid;
            MinorUnit         = ax.MinorUnit;
            LogBase           = ax.LogBase;
            AxisLine          = ax.AxisLine;
            LabelAlignment    = ax.LabelAlignment;
            LabelAngle        = ax.LabelAngle;
            Min               = ax.Min;
            Max               = ax.Max;
            Format            = ax.Format;
            Title             = ax.Title;
            OverlappingLabels = ax.OverlappingLabels;

            //styles
            Style          = StyleSerializer.StyleToString(ax.GetStyle("_"), ax.Chart as IBrushConverter);
            MajorGridStyle = StyleSerializer.StyleToString(ax.GetStyle("_MajorGrid"), ax.Chart as IBrushConverter);
            MinorGridStyle = StyleSerializer.StyleToString(ax.GetStyle("_MinorGrid"), ax.Chart as IBrushConverter);
            TitleStyle     = StyleSerializer.StyleToString(ax.GetStyle("_Title"), ax.Chart as IBrushConverter);
        }
Пример #3
0
        /// <summary>
        /// Overloaded constructor used create an instance of the ChartModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// IChart interface object passed as the parameter.
        /// </summary>
        /// <param name="chart">Specifies the IChart interface object to be serialized.</param>
        /// <remarks>
        /// The ChartModel class contains as serializable properties all other FlexChart objects appropriate
        /// for serializing the FlexChart control, it is only necessary to request serialization of the
        /// IChart object to store all information about the chart.  Subobjects do need not be serialized separately.
        /// </remarks>
        public ChartModel(IChart chart)
        {
            // simple properties
            ChartType = chart.ChartType;
            Header    = chart.Header;
            Footer    = chart.Footer;

            Stacking = chart.Stacking;

            {   // capture the XItems used for Axis Labeling.
                List <object> oItems = chart.GetXItems();
                if (oItems != null && oItems.Count > 0 && oItems[0].GetType() == typeof(string))
                {
                    List <string> sItems = new List <string>();
                    foreach (object o in oItems)
                    {
                        sItems.Add(o as string);
                    }
                    XItems = sItems;
                }
            }

            // styles
            Style             = StyleSerializer.StyleToString(chart.GetStyle(), chart as IBrushConverter);
            HeaderStyle       = StyleSerializer.StyleToString(chart.GetStyle("Header"), chart as IBrushConverter);
            FooterStyle       = StyleSerializer.StyleToString(chart.GetStyle("Footer"), chart as IBrushConverter);
            HeaderBorderStyle = StyleSerializer.StyleToString(chart.GetStyle("HeaderBorder"), chart as IBrushConverter);
            FooterBorderStyle = StyleSerializer.StyleToString(chart.GetStyle("FooterBorder"), chart as IBrushConverter);
            PlotStyle         = StyleSerializer.StyleToString(chart.GetStyle("Plot"), chart as IBrushConverter);
            SelectedStyle     = StyleSerializer.StyleToString(chart.GetStyle("Selected"), chart as IBrushConverter);

            // data
            Series = new List <SeriesModel>();
            foreach (var ser in chart.Series)
            {
                Series.Add(new SeriesModel(ser));
            }

            // axes
            //
            Axes = new List <AxisModel>();
            foreach (IAxis ax in chart.GetAxes())
            {
                Axes.Add(new AxisModel(ax));
            }
            // legend
            //
            Legend = new LegendModel(chart.Legend, chart);

            // ChartOptions
            Options = new OptionsModel(chart);

            // DataLabel
            DataLabel = new DataLabelModel(chart.DataLabel, chart);
        }
        /// <summary>
        /// Overloaded constructor used create an instance of the DataLabelModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// IDataLabel interface object passed as the parameter.
        /// </summary>
        /// <param name="dataLabel">Specifies the IDataLabel interface object to be serialized.</param>
        /// <param name="chart">Specifies the IChart interface object of the parent IChart object being serialized.</param>
        public DataLabelModel(IDataLabel dataLabel, IChart chart)
        {
            Border         = dataLabel.Border;
            ConnectingLine = dataLabel.ConnectingLine;
            Content        = dataLabel.Content;
            Offset         = dataLabel.Offset;
            Position       = dataLabel.Position;

            Style       = StyleSerializer.StyleToString(dataLabel.GetStyle("_"), chart as IBrushConverter);
            BorderStyle = StyleSerializer.StyleToString(dataLabel.GetStyle("_Border"), chart as IBrushConverter);
        }
Пример #5
0
        /// <summary>
        /// Overloaded constructor used create an instance of the LegendModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// ILegend interface object passed as the parameter.
        /// </summary>
        /// <param name="legend">Specifies the ILegend interface object to be serialized.</param>
        /// <param name="chart">Specifies the IChart interface object of the parent IChart object being serialized.</param>
        public LegendModel(ILegend legend, IChartBase chart)
        {
            Position    = legend.Position;
            Orientation = legend.Orientation;
            Title       = legend.Title;
            Reversed    = legend.Reversed;

#if WINFORMS
            Style      = StyleSerializer.StyleToString(legend.GetStyle("_"), chart as IBrushConverter);
            TitleStyle = StyleSerializer.StyleToString(legend.GetStyle("_Title"), chart as IBrushConverter);
#endif
#if WPF
            Style      = StyleSerializer.StyleToString(legend.GetStyle(), chart as IBrushConverter);
            TitleStyle = StyleSerializer.StyleToString(legend.GetStyle("Title"), chart as IBrushConverter);
#endif
        }
        /// <summary>
        /// Overloaded constructor used create an instance of the SeriesModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// IChart interface object passed as the parameter.
        /// </summary>
        /// <param name="series">Specifies the ISeries interface object to be serialized.</param>
        public SeriesModel(ISeries series)
        {
            // simple properties
            ChartType    = series.ChartType;
            Name         = series.Name;
            SymbolSize   = series.SymbolSize;
            SymbolMarker = series.SymbolMarker;
            Visiblity    = series.Visibility;

            XAxisIndex = (series.AxisX != null) ? series.Chart.GetAxes().IndexOf(series.AxisX) : 0;
            YAxisIndex = (series.AxisY != null) ? series.Chart.GetAxes().IndexOf(series.AxisY) : 0;

            // data
            X  = series.GetValues(1);
            Y  = series.GetValues(0);
            Y2 = series.GetValues(2);
            Y3 = series.GetValues(3);
            Y4 = series.GetValues(4);

            // styles
            Style = StyleSerializer.StyleToString(series.GetStyle(), series.Chart as IBrushConverter);
        }