protected override void InitializeControls() { var chart = new FlexChart() { Dock = DockStyle.Fill }; data = new PointDataSource(chart); data.NewData(); Chart = chart; var cbChartType = new ComboBoxEx("Chart Type"); cbChartType.DataSource = new ChartType[] { ChartType.Column, ChartType.Bar, ChartType.Line, ChartType.LineSymbols, ChartType.Scatter, ChartType.Area, ChartType.Spline, ChartType.SplineSymbols, ChartType.SplineArea, ChartType.Step }; cbChartType.SelectedValueChanged += (s, a) => chart.ChartType = (ChartType)Enum.Parse(typeof(ChartType), cbChartType.SelectedItem.ToString()); pnlControls.Controls.Add(cbChartType); var cbStacking = new ComboBoxEx("Stacking"); cbStacking.DataSource = Enum.GetNames(typeof(Stacking)); cbStacking.SelectedValueChanged += (s, a) => chart.Stacking = (Stacking)Enum.Parse(typeof(Stacking), cbStacking.SelectedItem.ToString()); pnlControls.Controls.Add(cbStacking); var cbRenderMode = new ComboBoxEx("RenderMode"); cbRenderMode.DataSource = Enum.GetNames(typeof(RenderMode)); cbRenderMode.SelectedValueChanged += (s, a) => chart.RenderMode = (RenderMode)Enum.Parse(typeof(RenderMode), cbRenderMode.SelectedItem.ToString()); pnlControls.SetFlowBreak(cbRenderMode, true); pnlControls.Controls.Add(cbRenderMode); var btnNew = new ButtonEx("New Data"); btnNew.Click += (s, a) => data.NewData(); pnlControls.Controls.Add(btnNew); var btnUpdate = new ButtonEx("Update"); btnUpdate.Click += (s, a) => data.UpdateData(); pnlControls.Controls.Add(btnUpdate); var btnAddSeries = new ButtonEx("+ Series"); btnAddSeries.Click += (s, a) => data.AddSeries(); pnlControls.Controls.Add(btnAddSeries); var btnRemoveSeries = new ButtonEx("- Series"); btnRemoveSeries.Click += (s, a) => { var cnt = chart.Series.Count; if (cnt > 0) { chart.Series.RemoveAt(cnt - 1); } }; pnlControls.Controls.Add(btnRemoveSeries); var btnAddPoint = new ButtonEx("+ Point"); btnAddPoint.Click += (s, a) => data.AddPoint(); pnlControls.Controls.Add(btnAddPoint); var btnRemovePoint = new ButtonEx("- Point"); btnRemovePoint.Click += (s, a) => data.RemovePoint(); pnlControls.Controls.Add(btnRemovePoint); }
private void btnAddPoint_Click(object sender, EventArgs e) { data.AddPoint(); }