/// <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);
        }
        /// <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>
        /// AxisModel.Load is used to set the properties of an existing Axis object in a FlexChart based control.
        /// The values used are those stored in an existing AxisModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="ax">Specifies an existing instance of an Axis class object.</param>
        /// <param name="am">Specifies an existing instannce of an AxisModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(Axis ax, AxisModel am)
        {
            ax.Position          = am.Position;
            ax.Origin            = am.Origin;
            ax.Reversed          = am.Reversed;
            ax.Labels            = am.Labels;
            ax.MajorTickMarks    = am.MajorTickMarks;
            ax.MajorGrid         = am.MajorGrid;
            ax.MajorUnit         = am.MajorUnit;
            ax.MinorTickMarks    = am.MinorTickMarks;
            ax.MinorGrid         = am.MinorGrid;
            ax.MinorUnit         = am.MinorUnit;
            ax.LogBase           = am.LogBase;
            ax.AxisLine          = am.AxisLine;
            ax.LabelAlignment    = am.LabelAlignment;
            ax.LabelAngle        = am.LabelAngle;
            ax.Min               = am.Min;
            ax.Max               = am.Max;
            ax.Format            = am.Format;
            ax.Title             = am.Title;
            ax.OverlappingLabels = am.OverlappingLabels;

            //// styles
            ((IAxis)ax).SetStyle(StyleSerializer.StyleFromString(am.Style), "_");
            ((IAxis)ax).SetStyle(StyleSerializer.StyleFromString(am.MajorGridStyle), "_MajorGrid");
            ((IAxis)ax).SetStyle(StyleSerializer.StyleFromString(am.MinorGridStyle), "_MinorGrid");
            ((IAxis)ax).SetStyle(StyleSerializer.StyleFromString(am.TitleStyle), "_Title");
        }
示例#4
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);
        }
        /// <summary>
        /// PieModel.Load is used to set the properties of an existing FlexPie object in a FlexPie based control.
        /// The values used are those stored in an existing PieModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="chart">Specifies an existing instance of a FlexPie class object.</param>
        /// <param name="model">Specifies an existing instannce of a PieModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(FlexPie chart, PieModel model)
        {
            // simple properties
#if WINFORMS
            chart.Header.Content = model.Header;
            chart.Footer.Content = model.Footer;
#endif

#if WPF
            chart.Header = model.Header;
            chart.Footer = model.Footer;
#endif

            // styles
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.Style), null);
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderStyle), "Header");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterStyle), "Footer");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderBorderStyle), "HeaderBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterBorderStyle), "FooterBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.PlotStyle), "Plot");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.SelectedStyle), "Selected");
            chart.InnerRadius = model.InnerRadius;
            chart.Offset      = model.Offset;
            chart.StartAngle  = model.StartAngle;
            chart.Reversed    = model.Reversed;

            double[] values = model.Values;
            string[] names  = model.Names;

            List <FlexPieSlice> slices = new List <FlexPieSlice>();
            for (int ps = 0; ps < values.Length; ps++)
            {
                FlexPieSlice slice = new FlexPieSlice(values[ps], names[ps]);
                slices.Add(slice);
            }
            chart.Binding     = "Value";
            chart.BindingName = "Name";

#if WINFORMS
            chart.DataSource = slices;
#endif
#if WPF
            chart.ItemsSource = slices;
#endif

            LegendModel.Load(chart, model.Legend);
            PieDataLabelModel.Load(chart.DataLabel, model.DataLabel);
        }
        /// <summary>
        /// DataLabelModel.Load is used to set the properties of an existing DataLabel object in a FlexChart based control.
        /// The values used are those stored in an existing DataLabelModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="pieDataLabel">Specifies an existing instance of a PieDataLabel class object.</param>
        /// <param name="pieDataLabelModel">Specifies an existing instannce of a PieDataLabelModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(PieDataLabel pieDataLabel, PieDataLabelModel pieDataLabelModel)
        {
            if (pieDataLabelModel == null)
            {
                pieDataLabelModel = new PieDataLabelModel();
            }

            pieDataLabel.Border         = pieDataLabelModel.Border;
            pieDataLabel.ConnectingLine = pieDataLabelModel.ConnectingLine;
            pieDataLabel.Content        = pieDataLabelModel.Content;
            pieDataLabel.Offset         = pieDataLabelModel.Offset;
            pieDataLabel.Position       = pieDataLabelModel.Position;

            ((IPieDataLabel)pieDataLabel).SetStyle(StyleSerializer.StyleFromString(pieDataLabelModel.Style), "_");
            ((IPieDataLabel)pieDataLabel).SetStyle(StyleSerializer.StyleFromString(pieDataLabelModel.BorderStyle), "_Border");
        }
        /// <summary>
        /// DataLabelModel.Load is used to set the properties of an existing DataLabel object in a FlexChart based control.
        /// The values used are those stored in an existing DataLabelModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="dataLabel">Specifies an existing instance of a DataLabel class object.</param>
        /// <param name="dataLabelModel">Specifies an existing instannce of a DataLabelModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(DataLabel dataLabel, DataLabelModel dataLabelModel)
        {
            if (dataLabelModel == null)
            {
                dataLabelModel = new DataLabelModel();
            }

            dataLabel.Border         = dataLabelModel.Border;
            dataLabel.ConnectingLine = dataLabelModel.ConnectingLine;
            dataLabel.Content        = dataLabelModel.Content;
            dataLabel.Offset         = dataLabelModel.Offset;
            dataLabel.Position       = dataLabelModel.Position;

            ((IDataLabel)dataLabel).SetStyle(StyleSerializer.StyleFromString(dataLabelModel.Style), "_");
            ((IDataLabel)dataLabel).SetStyle(StyleSerializer.StyleFromString(dataLabelModel.BorderStyle), "_Border");
        }
示例#9
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);
        }
示例#11
0
        /// <summary>
        /// LegendModel.Load is used to set the properties of an existing Legend object in a FlexChart based control.
        /// The values used are those stored in an existing LegendModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="legend">Specifies an existing instance of a Legend class object.</param>
        /// <param name="legendModel">Specifies an existing instannce of a LegendModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(FlexChartBase chart, LegendModel legendModel)
        {
#if WINFORMS
            chart.Legend.Position    = legendModel.Position;
            chart.Legend.Orientation = legendModel.Orientation;
            chart.Legend.Title       = legendModel.Title;
            chart.Legend.Reversed    = legendModel.Reversed;

            ((ILegend)chart.Legend).SetStyle(StyleSerializer.StyleFromString(legendModel.Style), "_");
            ((ILegend)chart.Legend).SetStyle(StyleSerializer.StyleFromString(legendModel.TitleStyle), "_TitleStyle");
#endif
#if WPF
            chart.LegendPosition    = legendModel.Position;
            chart.LegendOrientation = legendModel.Orientation;
            chart.LegendTitle       = legendModel.Title;
            chart.LegendReversed    = legendModel.Reversed;

            // Legend styles are actually part of the chart object model and must be set there.
            chart.LegendStyle      = new ChartStyle(StyleSerializer.StyleFromString(legendModel.Style));
            chart.LegendTitleStyle = new ChartStyle(StyleSerializer.StyleFromString(legendModel.TitleStyle));
#endif
        }
        /// <summary>
        /// SeriesModel.Load is used to set the properties of an existing Series object in a FlexChart based control.
        /// The values used are those stored in an existing SeriesModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="ser">Specifies an existing instance of a ISeries class object.</param>
        /// <param name="sm">Specifies an existing instannce of a SeriesModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(ISeries ser, SeriesModel sm)
        {
            // simple properties
            ser.ChartType    = sm.ChartType;
            ser.Name         = sm.Name;
            ser.SymbolMarker = sm.SymbolMarker;
            ser.SymbolSize   = sm.SymbolSize;
            ser.Visibility   = sm.Visiblity;

            // data
            var ds = new List <object>();

            var len = sm.Y != null ? sm.Y.Length : 0;

            for (var i = 0; i < len; i++)
            {
                object o;

                if (sm.X != null)
                {
                    o = new { X = sm.X[i], Y = sm.Y[i] };
                }
                else
                {
                    o = new { Y = sm.Y[i] };
                }

                ds.Add(o);
            }
            ser.BindingX   = sm.X != null ? "X" : null;
            ser.Binding    = "Y";
            ser.DataSource = ds;

            // styles
            ser.SetStyle(StyleSerializer.StyleFromString(sm.Style), null);
        }
示例#13
0
        /// <summary>
        /// ChartModel.Load is used to set the properties of an existing FlexChart object in a FlexChart based control.
        /// The values used are those stored in an existing ChartModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="chart">Specifies an existing instance of a FlexChart class object.</param>
        /// <param name="model">Specifies an existing instannce of a ChartModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(FlexChart chart, ChartModel model)
        {
            // simple properties
            chart.ChartType = model.ChartType;
#if WINFORMS
            chart.Header.Content = model.Header;
            chart.Footer.Content = model.Footer;
#endif

#if WPF
            chart.Header = model.Header;
            chart.Footer = model.Footer;
#endif
            chart.Stacking = model.Stacking;

            if (model.XItems != null && model.XItems.Count > 0)
            {
                chart.BindingX = "X";
                List <object> ds = new List <object>();
                foreach (string s in model.XItems)
                {
                    ds.Add(new { X = s });
                }
#if WINFORMS
                chart.DataSource = ds;
#endif
#if WPF
                chart.ItemsSource = ds;
#endif
            }

            // Load Axes before series so they are available.
            List <Axis> axes = new List <Axis>()
            {
                chart.AxisX, chart.AxisY
            };
            for (int iax = 2; iax < model.Axes.Count; iax++)
            {
                axes.Add(new Axis());
            }

            for (int iax = 0; iax < model.Axes.Count; iax++)
            {
                AxisModel.Load(axes[iax], model.Axes[iax]);
            }

            // data
            var series = chart.Series;
            series.Clear();
            foreach (var sm in model.Series)
            {
                var ser = new Series();
                series.Add(ser);
                SeriesModel.Load(ser, sm);

                if (sm.XAxisIndex > 0 && sm.XAxisIndex < axes.Count)
                {
                    ser.AxisX = axes[sm.XAxisIndex];
                }

                if (sm.YAxisIndex > 0 && sm.YAxisIndex < axes.Count)
                {
                    ser.AxisY = axes[sm.YAxisIndex];
                }
            }

            // styles
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.Style), null);
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderStyle), "Header");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterStyle), "Footer");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderBorderStyle), "HeaderBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterBorderStyle), "FooterBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.PlotStyle), "Plot");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.SelectedStyle), "Selected");

            // legend
            LegendModel.Load(chart, model.Legend);

            // ChartOptions
            OptionsModel.Load(chart.Options, model.Options);

            // DataLabel
            DataLabelModel.Load(chart.DataLabel, model.DataLabel);
        }