From dba84307479550135db0bccce9554da09c74aa74 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 3 Aug 2020 13:20:17 -0700 Subject: Add tool menu to enable\disable charts --- grapher/AccelCharts.cs | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 grapher/AccelCharts.cs (limited to 'grapher/AccelCharts.cs') diff --git a/grapher/AccelCharts.cs b/grapher/AccelCharts.cs new file mode 100644 index 0000000..62c60e5 --- /dev/null +++ b/grapher/AccelCharts.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class AccelCharts + { + public const int ChartSeparation = 10; + + /// Needed to show full contents in form. Unsure why. + public const int FormHeightPadding = 35; + + public AccelCharts( + Form form, + Chart sensitivityChart, + Chart velocityChart, + Chart gainChart, + ToolStripMenuItem enableVelocityAndGain) + { + ContaingForm = form; + SensitivityChart = sensitivityChart; + VelocityChart = velocityChart; + GainChart = gainChart; + EnableVelocityAndGain = enableVelocityAndGain; + + SensitivityChart.Top = 0; + VelocityChart.Height = SensitivityChart.Height; + VelocityChart.Top = SensitivityChart.Height + ChartSeparation; + GainChart.Height = SensitivityChart.Height; + GainChart.Top = VelocityChart.Top + VelocityChart.Height + ChartSeparation; + + Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); + FormBorderHeight = screenRectangle.Top - ContaingForm.Top; + + EnableVelocityAndGain.Click += new System.EventHandler(OnEnableClick); + EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableCheckStateChange); + + HideVelocityAndGain(); + } + + public Form ContaingForm { get; } + + public Chart SensitivityChart { get; } + + public Chart VelocityChart { get; } + + public Chart GainChart { get; } + + public ToolStripMenuItem EnableVelocityAndGain { get; } + + private int FormBorderHeight { get; } + + private void OnEnableClick(object sender, EventArgs e) + { + EnableVelocityAndGain.Checked = !EnableVelocityAndGain.Checked; + } + + private void OnEnableCheckStateChange(object sender, EventArgs e) + { + if (EnableVelocityAndGain.Checked) + { + ShowVelocityAndGain(); + } + else + { + HideVelocityAndGain(); + } + } + + private void ShowVelocityAndGain() + { + VelocityChart.Show(); + GainChart.Show(); + ContaingForm.Height = SensitivityChart.Height + + ChartSeparation + + VelocityChart.Height + + ChartSeparation + + GainChart.Height + + FormBorderHeight; + } + + private void HideVelocityAndGain() + { + VelocityChart.Hide(); + GainChart.Hide(); + ContaingForm.Height = SensitivityChart.Height + FormBorderHeight; + } + } +} -- cgit v1.2.3