summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-08-20 12:51:33 -0700
committerJacob Palecki <[email protected]>2020-08-20 12:51:33 -0700
commitfe17d04e571d180e663c7014e803ce790693f4b1 (patch)
treec2e026ab79b73d3e48cc71aebde90b095771587c /grapher/Models/Options
parentAdd empty active labels for all options (diff)
downloadrawaccel-fe17d04e571d180e663c7014e803ce790693f4b1.tar.xz
rawaccel-fe17d04e571d180e663c7014e803ce790693f4b1.zip
Display active values
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/ActiveValueLabel.cs46
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs64
-rw-r--r--grapher/Models/Options/CapOptions.cs20
-rw-r--r--grapher/Models/Options/Option.cs50
-rw-r--r--grapher/Models/Options/OptionXY.cs22
5 files changed, 187 insertions, 15 deletions
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs
new file mode 100644
index 0000000..ecafaba
--- /dev/null
+++ b/grapher/Models/Options/ActiveValueLabel.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class ActiveValueLabel
+ {
+ public const string DefaultFormatString = "0.######";
+
+ public ActiveValueLabel(Label valueLabel, Label centeringLabel)
+ {
+ ValueLabel = valueLabel;
+ ValueLabel.ForeColor = Color.DarkGray;
+ ValueLabel.Left = centeringLabel.Left;
+ ValueLabel.Width = centeringLabel.Width;
+ ValueLabel.AutoSize = false;
+ ValueLabel.TextAlign = ContentAlignment.MiddleCenter;
+ }
+
+ public Label ValueLabel { get; }
+
+ private int Left { get; }
+
+ private int Width { get; }
+
+ public void Hide()
+ {
+ ValueLabel.Hide();
+ }
+
+ public void Show()
+ {
+ ValueLabel.Show();
+ }
+
+ public void SetValue(double value)
+ {
+ ValueLabel.Text = value.ToString(DefaultFormatString);
+ }
+ }
+}
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
new file mode 100644
index 0000000..b3b580f
--- /dev/null
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Options
+{
+ public class ActiveValueLabelXY
+ {
+ public const int ActiveLabelXYSeparation = 4;
+
+ public ActiveValueLabelXY(
+ ActiveValueLabel x,
+ ActiveValueLabel y)
+ {
+ X = x;
+ Y = y;
+ Combined = false;
+ SetCombined();
+ }
+
+ public ActiveValueLabel X { get; }
+
+ public ActiveValueLabel Y { get; }
+
+ public bool Combined { get; private set; }
+
+ public void SetValues(double x, double y)
+ {
+ X.SetValue(x);
+ Y.SetValue(y);
+
+ if (x == y)
+ {
+ SetCombined();
+ }
+ else
+ {
+ SetSeparate();
+ }
+ }
+
+ public void SetCombined()
+ {
+ if (!Combined)
+ {
+ Y.Hide();
+ }
+
+ Combined = true;
+ }
+
+ public void SetSeparate()
+ {
+ if (Combined)
+ {
+ Y.Show();
+ }
+
+ Combined = false;
+ }
+ }
+}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index 2ee7f6b..fedda08 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -30,13 +30,13 @@ namespace grapher
EnableSensitivityCap();
}
- ToolStripMenuItem SensitivityCapCheck { get; }
+ public ToolStripMenuItem SensitivityCapCheck { get; }
- ToolStripMenuItem VelocityGainCapCheck { get; }
+ public ToolStripMenuItem VelocityGainCapCheck { get; }
- OptionXY CapOption { get; }
+ public OptionXY CapOption { get; }
- OptionXY WeightOption { get; }
+ public OptionXY WeightOption { get; }
public double SensitivityCapX {
get
@@ -82,6 +82,18 @@ namespace grapher
public bool IsSensitivityGain { get; private set; }
+ public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled)
+ {
+ if (capGainEnabled)
+ {
+ CapOption.SetActiveValues(gainCap, gainCap);
+ }
+ else
+ {
+ CapOption.SetActiveValues(sensCapX, sensCapY);
+ }
+ }
+
void OnSensitivityCapCheckClick(object sender, EventArgs e)
{
if (!SensitivityCapCheck.Checked)
diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs
index eb5105e..bacd760 100644
--- a/grapher/Models/Options/Option.cs
+++ b/grapher/Models/Options/Option.cs
@@ -1,4 +1,5 @@
-using System;
+using grapher.Models.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,19 +10,42 @@ namespace grapher
{
public class Option
{
- public Option(Field field, Label label)
+ public Option(
+ Field field,
+ Label label,
+ ActiveValueLabel activeValueLabel)
{
Field = field;
Label = label;
+ ActiveValueLabel = activeValueLabel;
}
- public Option(TextBox box, Form containingForm, double defaultData, Label label)
- : this(new Field(box, containingForm, defaultData), label)
+ public Option(
+ TextBox box,
+ Form containingForm,
+ double defaultData,
+ Label label,
+ ActiveValueLabel activeValueLabel)
+ : this(
+ new Field(box, containingForm, defaultData),
+ label,
+ activeValueLabel)
{
}
- public Option(TextBox box, Form containingForm, double defaultData, Label label, string startingName)
- : this(box, containingForm, defaultData, label)
+ public Option(
+ TextBox box,
+ Form containingForm,
+ double defaultData,
+ Label label,
+ ActiveValueLabel activeValueLabel,
+ string startingName)
+ : this(
+ box,
+ containingForm,
+ defaultData,
+ label,
+ activeValueLabel)
{
SetName(startingName);
}
@@ -30,22 +54,36 @@ namespace grapher
public Label Label { get; }
+ public ActiveValueLabel ActiveValueLabel { get; }
+
public void SetName(string name)
{
Label.Text = name;
Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0));
}
+ public void SetActiveValue(double value)
+ {
+ ActiveValueLabel.SetValue(value);
+ }
+
public void Hide()
{
Field.Box.Hide();
Label.Hide();
+ ActiveValueLabel.Hide();
}
public void Show()
{
Field.Box.Show();
Label.Show();
+ ActiveValueLabel.Show();
+ }
+
+ public void UpdateActiveValue(double value)
+ {
+ ActiveValueLabel.SetValue(value);
}
public void Show(string name)
diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs
index 90a46d7..b22bb78 100644
--- a/grapher/Models/Options/OptionXY.cs
+++ b/grapher/Models/Options/OptionXY.cs
@@ -1,4 +1,5 @@
-using System;
+using grapher.Models.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,10 +10,11 @@ namespace grapher
{
public class OptionXY
{
- public OptionXY(FieldXY fields, Label label)
+ public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels)
{
Fields = fields;
Label = label;
+ ActiveValueLabels = activeValueLabels;
}
public OptionXY(
@@ -22,8 +24,9 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
- AccelCharts accelCharts)
- : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label)
+ AccelCharts accelCharts,
+ ActiveValueLabelXY activeValueLabels)
+ : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label, activeValueLabels)
{
}
@@ -34,6 +37,7 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
+ ActiveValueLabelXY activeValueLabels,
string startingName,
AccelCharts accelCharts):
this(
@@ -43,7 +47,8 @@ namespace grapher
containingForm,
defaultData,
label,
- accelCharts)
+ accelCharts,
+ activeValueLabels)
{
SetName(startingName);
}
@@ -52,12 +57,19 @@ namespace grapher
public Label Label { get; }
+ public ActiveValueLabelXY ActiveValueLabels { get; }
+
public void SetName(string name)
{
Label.Text = name;
Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0));
}
+ public void SetActiveValues(double x, double y)
+ {
+ ActiveValueLabels.SetValues(x, y);
+ }
+
public void Hide()
{
Fields.Hide();