/// <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> /// 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"); }