summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-08-20 14:22:14 -0700
committerJacob Palecki <[email protected]>2020-08-20 14:22:14 -0700
commit7dbeae9d4cf108e78072b356d832123f12e42a90 (patch)
tree9711fddfb5241a3dc859cd421aa4937d38a8852f /grapher/Models/Options
parentDisplay active values (diff)
downloadrawaccel-7dbeae9d4cf108e78072b356d832123f12e42a90.tar.xz
rawaccel-7dbeae9d4cf108e78072b356d832123f12e42a90.zip
Add accel type to active values and tweak color
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/AccelOptions.cs13
-rw-r--r--grapher/Models/Options/ActiveValueLabel.cs73
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs22
-rw-r--r--grapher/Models/Options/CapOptions.cs10
4 files changed, 109 insertions, 9 deletions
diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs
index 8da873f..cd7c4e5 100644
--- a/grapher/Models/Options/AccelOptions.cs
+++ b/grapher/Models/Options/AccelOptions.cs
@@ -1,4 +1,5 @@
using grapher.Layouts;
+using grapher.Models.Options;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,7 +32,8 @@ namespace grapher
ComboBox accelDropdown,
Option[] options,
OptionXY[] optionsXY,
- Button writeButton)
+ Button writeButton,
+ ActiveValueLabel activeValueLabel)
{
AccelDropdown = accelDropdown;
AccelDropdown.Items.Clear();
@@ -51,6 +53,7 @@ namespace grapher
Options = options;
OptionsXY = optionsXY;
WriteButton = writeButton;
+ ActiveValueLabel = activeValueLabel;
Layout("Default");
}
@@ -61,10 +64,18 @@ namespace grapher
public int AccelerationIndex { get; private set; }
+ public ActiveValueLabel ActiveValueLabel { get; }
+
public Option[] Options { get; }
public OptionXY[] OptionsXY { get; }
+ public void SetActiveValue(int index)
+ {
+ var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name;
+ ActiveValueLabel.SetValue(name);
+ }
+
private void OnIndexChanged(object sender, EventArgs e)
{
var accelerationTypeString = AccelDropdown.SelectedItem.ToString();
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs
index ecafaba..138775a 100644
--- a/grapher/Models/Options/ActiveValueLabel.cs
+++ b/grapher/Models/Options/ActiveValueLabel.cs
@@ -11,22 +11,73 @@ namespace grapher.Models.Options
public class ActiveValueLabel
{
public const string DefaultFormatString = "0.######";
+ public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65);
+
+ private string _prefix;
+ private string _value;
public ActiveValueLabel(Label valueLabel, Label centeringLabel)
{
ValueLabel = valueLabel;
- ValueLabel.ForeColor = Color.DarkGray;
- ValueLabel.Left = centeringLabel.Left;
- ValueLabel.Width = centeringLabel.Width;
+ ValueLabel.ForeColor = ActiveValueFontColor;
+ Left = centeringLabel.Left;
+ Width = centeringLabel.Width;
ValueLabel.AutoSize = false;
ValueLabel.TextAlign = ContentAlignment.MiddleCenter;
+
+ FormatString = DefaultFormatString;
+ Prefix = string.Empty;
}
public Label ValueLabel { get; }
- private int Left { get; }
+ public string FormatString { get; set; }
+
+ public string Prefix
+ {
+ get { return _prefix; }
+ set
+ {
+ _prefix = value;
+ RefreshText();
+ }
+ }
+
+ private string Value
+ {
+ get { return _value; }
+ set
+ {
+ _value = value;
+ RefreshText();
+ }
+ }
- private int Width { get; }
+ public int Left
+ {
+ get
+ {
+ return ValueLabel.Left;
+ }
+
+ set
+ {
+ ValueLabel.Left = value;
+ }
+ }
+
+ public int Width
+ {
+ get
+ {
+ return ValueLabel.Width;
+ }
+
+ set
+ {
+ ValueLabel.Width = value;
+ }
+ }
public void Hide()
{
@@ -40,7 +91,17 @@ namespace grapher.Models.Options
public void SetValue(double value)
{
- ValueLabel.Text = value.ToString(DefaultFormatString);
+ SetValue(value.ToString(FormatString));
+ }
+
+ public void SetValue(string value)
+ {
+ Value = value;
+ }
+
+ public void RefreshText()
+ {
+ ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}";
}
}
}
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
index b3b580f..12506e9 100644
--- a/grapher/Models/Options/ActiveValueLabelXY.cs
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -8,7 +8,8 @@ namespace grapher.Models.Options
{
public class ActiveValueLabelXY
{
- public const int ActiveLabelXYSeparation = 4;
+ public const int ActiveLabelXYSeparation = 2;
+ public const string ShortenedFormatString = "0.###";
public ActiveValueLabelXY(
ActiveValueLabel x,
@@ -16,6 +17,14 @@ namespace grapher.Models.Options
{
X = x;
Y = y;
+
+ FullWidth = x.Width;
+ ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2;
+
+ Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation;
+ Y.Width = ShortenedWidth;
+ Y.FormatString = ShortenedFormatString;
+
Combined = false;
SetCombined();
}
@@ -26,6 +35,10 @@ namespace grapher.Models.Options
public bool Combined { get; private set; }
+ private int FullWidth { get; }
+
+ private int ShortenedWidth { get; }
+
public void SetValues(double x, double y)
{
X.SetValue(x);
@@ -45,6 +58,9 @@ namespace grapher.Models.Options
{
if (!Combined)
{
+ X.FormatString = ActiveValueLabel.DefaultFormatString;
+ X.Width = FullWidth;
+ X.Prefix = string.Empty;
Y.Hide();
}
@@ -55,6 +71,10 @@ namespace grapher.Models.Options
{
if (Combined)
{
+ X.FormatString = ShortenedFormatString;
+ X.Width = ShortenedWidth;
+ X.Prefix = "X";
+ Y.Prefix = "Y";
Y.Show();
}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index fedda08..493561a 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -1,4 +1,5 @@
-using System;
+using grapher.Models.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,6 +10,9 @@ namespace grapher
{
public class CapOptions
{
+
+ public const string GainCapFormatString = "0.##";
+
public CapOptions(
ToolStripMenuItem sensitivityCapCheck,
ToolStripMenuItem velocityGainCapCheck,
@@ -86,10 +90,14 @@ namespace grapher
{
if (capGainEnabled)
{
+ CapOption.ActiveValueLabels.X.FormatString = GainCapFormatString;
+ CapOption.ActiveValueLabels.X.Prefix = "Gain";
CapOption.SetActiveValues(gainCap, gainCap);
}
else
{
+ CapOption.ActiveValueLabels.X.FormatString = ActiveValueLabel.DefaultFormatString;
+ CapOption.ActiveValueLabels.X.Prefix = string.Empty;
CapOption.SetActiveValues(sensCapX, sensCapY);
}
}