コード例 #1
0
        private static void DeserializeFlexPieFromData(FlexPie flexPie, object flexPieData, string format = "xml")
        {
            flexPie.BeginUpdate();

            PieModel model = DeserializeModelFromData(typeof(PieModel), flexPieData, format) as PieModel;

            PieModel.Load(flexPie, model);

            flexPie.EndUpdate();
        }
コード例 #2
0
        /// <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);
        }