public void InitBindings(FlexChartBase chart) { tableLayoutPanel1.SuspendLayout(); tblBindings.SuspendLayout(); tblBindings.Controls.Clear(); tblBindings.RowStyles.Clear(); tblBindings.RowStyles.Add(new RowStyle(SizeType.AutoSize)); tblBindings.RowStyles.Add(new RowStyle(SizeType.AutoSize)); var fc = chart as FlexChart; if (fc != null) { InitBindings(fc); } else { var fp = chart as FlexPie; if (fp != null) { InitBindings(fp); } } tblBindings.ResumeLayout(); tableLayoutPanel1.ResumeLayout(); }
private void btnSerialize_Click(object sender, EventArgs e) { byte[] chartBytes = null; FlexChartBase chartBase = SelectedChart; if (chartBase != null) { txtXml.Text = Serializer.SerializeChartToXml(chartBase); txtJson.Text = Serializer.SerializeChartToJson(chartBase); chartBytes = Serializer.SerializeChartToBytes(chartBase); } else { txtXml.Text = null; txtJson.Text = null; txtBinary.Text = null; txtBase64.Text = null; } if (chartBytes != null) { // Display the byte[] data in nice hex format. txtBinary.Text = BinaryBytesToHexString(chartBytes, 20); // Also display the byte[] data in a nice base64 string format. txtBase64.Text = Convert.ToBase64String(chartBytes, Base64FormattingOptions.InsertLineBreaks); } }
/// <summary> /// Gets the designer for the specified chart. /// </summary> /// <param name="chart"></param> /// <returns></returns> public static ChartDesigner GetDesigner(FlexChartBase chart) { ChartDesigner designer = null; dict.TryGetValue(chart, out designer); return(designer); }
void Init(FlexChartBase chart) { this.chart = chart; adorner = new ChartAdorner(chart); adorner.SelectedElementChanged += Chart_SelectedElementChanged; InitForms(); }
/// <summary> /// Serializes a FlexChart based control to a file. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="filename">The full path to the file to store the serialized FlexChart based control.</param> /// <param name="flexChart">The instance of the FlexChart based control to serialize.</param> /// <param name="format">A string specifying the format to use for serialization. Presently this includes /// "xml", "json", "binary" and "base64" format specifications. /// </param> /// <returns>A boolean value indicating true if the serialization to the file was successfull.</returns> public static bool SerializeChartToFile(string filename, FlexChartBase flexChart, string format = "xml") { bool result = false; switch (format.ToLower()) { case "xml": File.WriteAllText(filename, SerializeChartToXml(flexChart)); result = true; break; case "json": File.WriteAllText(filename, SerializeChartToJson(flexChart)); result = true; break; case "binary": File.WriteAllBytes(filename, SerializeChartToBytes(flexChart)); result = true; break; case "base64": File.WriteAllText(filename, Convert.ToBase64String( SerializeChartToBytes(flexChart), Base64FormattingOptions.InsertLineBreaks)); result = true; break; } return(result); }
/// <summary> /// Deserializes a FlexChart based control from a byte array. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="flexChart">The instance of the FlexChart based control into which the serialized chart data is to be loaded.</param> /// <param name="flexChartBytes">A byte array containing the serialized chart information.</param> public static void DeserializeChartFromBytes(FlexChartBase flexChart, byte[] flexChartBytes) { if (flexChart is FlexChart) { DeserializeFlexChartFromBytes(flexChart as FlexChart, flexChartBytes); } if (flexChart is FlexPie) { DeserializeFlexPieFromBytes(flexChart as FlexPie, flexChartBytes); } }
/// <summary> /// Deserializes a FlexChart based control from a JSON string. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="flexChart">The instance of the FlexChart based control into which the serialized chart data is to be loaded.</param> /// <param name="flexChartString">A string containing the JSON string with serialized chart information.</param> public static void DeserializeChartFromJson(FlexChartBase flexChart, string flexChartString) { if (flexChart is FlexChart) { DeserializeFlexChartFromJson(flexChart as FlexChart, flexChartString); } else if (flexChart is FlexPie) { DeserializeFlexPieFromJson(flexChart as FlexPie, flexChartString); } }
/// <summary> /// Serializes a FlexChart based control to a byte array. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="flexChart">The instance of the FlexChart based control to serialize to a byte array.</param> /// <returns>A byte array containing the serialized chart.</returns> public static byte[] SerializeChartToBytes(FlexChartBase flexChart) { if (flexChart is FlexChart) { return(SerializeFlexChartToBytes(flexChart as FlexChart)); } else if (flexChart is FlexPie) { return(SerializeFlexPieToBytes(flexChart as FlexPie)); } return(null); }
/// <summary> /// Serializes a FlexChart based control to a JSON string. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="flexChart">The instance of the FlexChart based control to serialize to a JSON string.</param> /// <returns>A string containing a formatted JSON string.</returns> public static string SerializeChartToJson(FlexChartBase flexChart) { if (flexChart is FlexChart) { return(SerializeFlexChartToJson(flexChart as FlexChart)); } else if (flexChart is FlexPie) { return(SerializeFlexPieToJson(flexChart as FlexPie)); } return(null); }
/// <summary> /// Deserializes a FlexChart based control from a file. At present, this includes FlexChart and FlexPie controls. /// </summary> /// <param name="filename">The full path of the file containing a serialized FlexChart based control.</param> /// <param name="flexChart">The instance of the FlexChart based control into which the serialized chart data is to be loaded.</param> /// <param name="format">A string specifying the format to use for deserialization. Presently this includes /// "xml", "json", "binary" and "base64" format specifications. /// </param> /// <returns>A boolean value indicating true if the deserialization from the file was successfull.</returns> public static bool DeserializeChartFromFile(string filename, FlexChartBase flexChart, string format = "xml") { if (flexChart is FlexChart) { DeserializeFlexChartFromFile(filename, flexChart as FlexChart, format); } else if (flexChart is FlexPie) { DeserializeFlexPieFromFile(filename, flexChart as FlexPie, format); } return(false); }
private void btnDeserializeTab_Click(object sender, EventArgs e) { FlexChartBase chartBase = SelectedChart; bool isSerialized = false; try { switch (SelectedFormat) { case "Xml": // xml isSerialized = !string.IsNullOrEmpty(txtXml.Text); if (isSerialized) { Serializer.DeserializeChartFromXml(chartBase, txtXml.Text); } break; case "Json": // json isSerialized = !string.IsNullOrEmpty(txtJson.Text); if (isSerialized) { Serializer.DeserializeChartFromJson(chartBase, txtJson.Text); } break; case "Binary": // binary (hex format) isSerialized = !string.IsNullOrEmpty(txtBinary.Text); if (isSerialized) { Serializer.DeserializeChartFromBytes(chartBase, HexToBinaryBytes(txtBinary.Text)); } break; case "Base64": // binary (base64 format) isSerialized = !string.IsNullOrEmpty(txtBase64.Text); if (isSerialized) { Serializer.DeserializeChartFromBytes(chartBase, Convert.FromBase64String(txtBase64.Text)); } break; } } catch { isSerialized = false; } if (!isSerialized) { MessageBox.Show("The tab does not contain valid serialized data."); } }
/// <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 }
public LegendProperties(Legend legend, FlexChartBase chart) { this.legend = legend; this.chart = chart; }
internal FlexChartBaseProperties(FlexChartBase baseChart) { this.baseChart = baseChart; }
internal PieDataLabelProperties(PieDataLabel dataLabel, FlexChartBase chart) : base(dataLabel, chart) { this.dataLabel = dataLabel; }
internal DataLabelBaseProperties(DataLabelBase dataLabelBase, FlexChartBase chart) { this.dataLabelBase = dataLabelBase; this.chart = chart; }
public TitleProperties(ChartTitle title, FlexChartBase chart, bool header) { this.title = title; this.chart = chart; this.header = header; }
public ChartAdorner(FlexChartBase chart) { this.chart = chart; Attach(); }
protected FlexChartBaseSample(FlexChartBase chart) : this() { Chart = chart; }
/// <summary> /// Creates designer for the specified chart instance. /// </summary> /// <param name="chart"></param> public ChartDesigner(FlexChartBase chart) { dict[chart] = this; Init(chart); }