summaryrefslogtreecommitdiff
path: root/grapher/Models/Options
diff options
context:
space:
mode:
Diffstat (limited to 'grapher/Models/Options')
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs164
-rw-r--r--grapher/Models/Options/AccelOptions.cs91
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs191
-rw-r--r--grapher/Models/Options/ActiveValueLabel.cs26
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs28
-rw-r--r--grapher/Models/Options/ApplyOptions.cs184
-rw-r--r--grapher/Models/Options/CapOptions.cs99
-rw-r--r--grapher/Models/Options/Option.cs77
-rw-r--r--grapher/Models/Options/OptionXY.cs17
9 files changed, 733 insertions, 144 deletions
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
new file mode 100644
index 0000000..838917c
--- /dev/null
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -0,0 +1,164 @@
+using grapher.Models.Serialized;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class AccelOptionSet
+ {
+ public AccelOptionSet(
+ Label titleLabel,
+ int topAnchor,
+ AccelTypeOptions accelTypeOptions,
+ Option acceleration,
+ CapOptions cap,
+ Option weight,
+ OffsetOptions offset,
+ Option limitOrExp,
+ Option midpoint)
+ {
+ TitleLabel = titleLabel;
+ TopAnchor = topAnchor;
+ AccelTypeOptions = accelTypeOptions;
+ Acceleration = acceleration;
+ Cap = cap;
+ Weight = weight;
+ Offset = offset;
+ LimitOrExponent = limitOrExp;
+ Midpoint = midpoint;
+
+ AccelTypeOptions.ShowFullText();
+
+ TitleLabel.Top = TopAnchor;
+ IsTitleMode = true;
+ SetRegularMode();
+ }
+
+ public int TopAnchor { get; }
+
+ public Label TitleLabel { get; }
+
+ public AccelTypeOptions AccelTypeOptions { get; }
+
+ public Option Acceleration { get; }
+
+ public CapOptions Cap { get; }
+
+ public Option Weight { get; }
+
+ public OffsetOptions Offset { get; }
+
+ public Option LimitOrExponent { get; }
+
+ public Option Midpoint { get; }
+
+ public bool IsTitleMode { get; private set; }
+
+ public void SetRegularMode()
+ {
+ if (IsTitleMode)
+ {
+ IsTitleMode = false;
+
+ HideTitle();
+ AccelTypeOptions.Left = Acceleration.Left;
+ AccelTypeOptions.Width = Acceleration.Width;
+ AccelTypeOptions.ShowFullText();
+ }
+ }
+
+ public void SetTitleMode(string title)
+ {
+ TitleLabel.Text = title;
+
+ if (!IsTitleMode)
+ {
+ IsTitleMode = true;
+
+ AccelTypeOptions.Left = Acceleration.Field.Left;
+ AccelTypeOptions.Width = Acceleration.Field.Width;
+ AccelTypeOptions.ShowShortenedText();
+ DisplayTitle();
+ }
+ }
+
+ public void Hide()
+ {
+ TitleLabel.Hide();
+ AccelTypeOptions.Hide();
+ }
+
+ public void Show()
+ {
+ if (IsTitleMode)
+ {
+ TitleLabel.Show();
+ }
+
+ AccelTypeOptions.Show();
+ }
+
+ public void DisplayTitle()
+ {
+ TitleLabel.Show();
+
+ SetOptionsTop(TitleLabel.Top + TitleLabel.Height + Constants.OptionVerticalSeperation);
+ }
+
+ public void HideTitle()
+ {
+ TitleLabel.Hide();
+
+ SetOptionsTop(TopAnchor);
+ }
+
+ public void SetArgs(AccelArgs args)
+ {
+ args.accel = Acceleration.Field.Data;
+ args.rate = Acceleration.Field.Data;
+ args.powerScale = Acceleration.Field.Data;
+ args.gainCap = Cap.VelocityGainCap;
+ args.scaleCap = Cap.SensitivityCap;
+ args.limit = LimitOrExponent.Field.Data;
+ args.exponent = LimitOrExponent.Field.Data;
+ args.powerExponent = LimitOrExponent.Field.Data;
+ args.offset = Offset.Offset;
+ args.legacy_offset = Offset.LegacyOffset;
+ args.midpoint = Midpoint.Field.Data;
+ args.weight = Weight.Field.Data;
+ }
+
+ public AccelArgs GenerateArgs()
+ {
+ AccelArgs args = new AccelArgs();
+ SetArgs(args);
+ return args;
+ }
+
+ public void SetActiveValues(int mode, AccelArgs args)
+ {
+ AccelTypeOptions.SetActiveValue(mode);
+ Weight.SetActiveValue(args.weight);
+ Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0);
+ Offset.SetActiveValue(args.offset, args.legacy_offset);
+ Acceleration.SetActiveValue(args.accel);
+ LimitOrExponent.SetActiveValue(args.exponent);
+ Midpoint.SetActiveValue(args.midpoint);
+ }
+
+ private void SetOptionsTop(int top)
+ {
+ AccelTypeOptions.Top = top;
+ Acceleration.Top = AccelTypeOptions.Top + AccelTypeOptions.Height + Constants.OptionVerticalSeperation;
+ Cap.SnapTo(Acceleration);
+ Weight.SnapTo(Cap);
+ Offset.OffsetOption.SnapTo(Weight);
+ LimitOrExponent.SnapTo(Offset.OffsetOption);
+ Midpoint.SnapTo(LimitOrExponent);
+ }
+ }
+}
diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs
deleted file mode 100644
index 6b98274..0000000
--- a/grapher/Models/Options/AccelOptions.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using grapher.Layouts;
-using grapher.Models.Options;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace grapher
-{
- public class AccelOptions
- {
- public const int PossibleOptionsCount = 4;
- public const int PossibleOptionsXYCount = 2;
-
- public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase>
- {
- new LinearLayout(),
- new ClassicLayout(),
- new NaturalLayout(),
- new LogLayout(),
- new SigmoidLayout(),
- new PowerLayout(),
- new NaturalGainLayout(),
- new SigmoidGainLayout(),
- new OffLayout()
- }.ToDictionary(k => k.Name);
-
- public AccelOptions(
- ComboBox accelDropdown,
- Option[] options,
- OptionXY[] optionsXY,
- Button writeButton,
- ActiveValueLabel activeValueLabel)
- {
- AccelDropdown = accelDropdown;
- AccelDropdown.Items.Clear();
- AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray());
- AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
-
- if (options.Length > PossibleOptionsCount)
- {
- throw new Exception("Layout given too many options.");
- }
-
- if (optionsXY.Length > PossibleOptionsXYCount)
- {
- throw new Exception("Layout given too many options.");
- }
-
- Options = options;
- OptionsXY = optionsXY;
- WriteButton = writeButton;
- ActiveValueLabel = activeValueLabel;
-
- Layout("Off");
- }
-
- public Button WriteButton { get; }
-
- public ComboBox AccelDropdown { get; }
-
- 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();
- Layout(accelerationTypeString);
- }
-
- private void Layout(string type)
- {
- var accelerationType = AccelerationTypes[type];
- AccelerationIndex = accelerationType.Index;
- accelerationType.Layout(Options, OptionsXY, WriteButton);
- }
- }
-}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
new file mode 100644
index 0000000..5342f4b
--- /dev/null
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -0,0 +1,191 @@
+using grapher.Layouts;
+using grapher.Models.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher
+{
+ public class AccelTypeOptions
+ {
+ #region Fields
+
+ public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase>
+ {
+ new LinearLayout(),
+ new ClassicLayout(),
+ new NaturalLayout(),
+ new LogLayout(),
+ new SigmoidLayout(),
+ new PowerLayout(),
+ new NaturalGainLayout(),
+ new SigmoidGainLayout(),
+ new OffLayout()
+ }.ToDictionary(k => k.Name);
+
+ #endregion Fields
+
+ #region Constructors
+
+ public AccelTypeOptions(
+ ComboBox accelDropdown,
+ Option[] options,
+ Button writeButton,
+ ActiveValueLabel activeValueLabel)
+ {
+ AccelDropdown = accelDropdown;
+ AccelDropdown.Items.Clear();
+ AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray());
+ AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
+
+ if (options.Length > Constants.PossibleOptionsCount)
+ {
+ throw new Exception("Layout given too many options.");
+ }
+
+ Options = options;
+ WriteButton = writeButton;
+ ActiveValueLabel = activeValueLabel;
+
+ Layout("Off");
+ ShowingDefault = true;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public Button WriteButton { get; }
+
+ public ComboBox AccelDropdown { get; }
+
+ public int AccelerationIndex
+ {
+ get
+ {
+ return AccelerationType.Index;
+ }
+ }
+
+ public LayoutBase AccelerationType { get; private set; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public Option[] Options { get; }
+
+ public int Top
+ {
+ get
+ {
+ return AccelDropdown.Top;
+ }
+ set
+ {
+ AccelDropdown.Top = value;
+ }
+ }
+
+ public int Height
+ {
+ get
+ {
+ return AccelDropdown.Height;
+ }
+ set
+ {
+ AccelDropdown.Height = value;
+ }
+ }
+
+ public int Left
+ {
+ get
+ {
+ return AccelDropdown.Left;
+ }
+ set
+ {
+ AccelDropdown.Left = value;
+ }
+ }
+
+ public int Width
+ {
+ get
+ {
+ return AccelDropdown.Width;
+ }
+ set
+ {
+ AccelDropdown.Width = value;
+ }
+ }
+
+ private bool ShowingDefault { get; set; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public void Hide()
+ {
+ AccelDropdown.Hide();
+
+ foreach(var option in Options)
+ {
+ option.Hide();
+ }
+ }
+
+ public void Show()
+ {
+ AccelDropdown.Show();
+ Layout();
+ }
+
+ public void SetActiveValue(int index)
+ {
+ var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name;
+ ActiveValueLabel.SetValue(name);
+ }
+
+ public void ShowFullText()
+ {
+ if (ShowingDefault)
+ {
+ AccelDropdown.Text = Constants.AccelDropDownDefaultFullText;
+ }
+ }
+
+ public void ShowShortenedText()
+ {
+ if (ShowingDefault)
+ {
+ AccelDropdown.Text = Constants.AccelDropDownDefaultShortText;
+ }
+ }
+
+ private void OnIndexChanged(object sender, EventArgs e)
+ {
+ var accelerationTypeString = AccelDropdown.SelectedItem.ToString();
+ Layout(accelerationTypeString);
+ ShowingDefault = false;
+ }
+
+ private void Layout(string type)
+ {
+ AccelerationType = AccelerationTypes[type];
+ Layout();
+ }
+
+ private void Layout()
+ {
+ AccelerationType.Layout(Options, WriteButton);
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs
index 138775a..d2b43ab 100644
--- a/grapher/Models/Options/ActiveValueLabel.cs
+++ b/grapher/Models/Options/ActiveValueLabel.cs
@@ -10,25 +10,37 @@ namespace grapher.Models.Options
{
public class ActiveValueLabel
{
- public const string DefaultFormatString = "0.######";
- public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65);
+ #region Constants
+
+
+ #endregion Constants
+
+ #region Fields
private string _prefix;
private string _value;
+ #endregion Fields
+
+ #region Constructors
+
public ActiveValueLabel(Label valueLabel, Label centeringLabel)
{
ValueLabel = valueLabel;
- ValueLabel.ForeColor = ActiveValueFontColor;
+ ValueLabel.ForeColor = Constants.ActiveValueFontColor;
Left = centeringLabel.Left;
Width = centeringLabel.Width;
ValueLabel.AutoSize = false;
ValueLabel.TextAlign = ContentAlignment.MiddleCenter;
- FormatString = DefaultFormatString;
+ FormatString = Constants.DefaultActiveValueFormatString;
Prefix = string.Empty;
}
+ #endregion Constructors
+
+ #region Properties
+
public Label ValueLabel { get; }
public string FormatString { get; set; }
@@ -79,6 +91,10 @@ namespace grapher.Models.Options
}
}
+ #endregion Properties
+
+ #region Methods
+
public void Hide()
{
ValueLabel.Hide();
@@ -103,5 +119,7 @@ namespace grapher.Models.Options
{
ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}";
}
+
+ #endregion Methods
}
}
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
index 12506e9..c8caddf 100644
--- a/grapher/Models/Options/ActiveValueLabelXY.cs
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -8,8 +8,12 @@ namespace grapher.Models.Options
{
public class ActiveValueLabelXY
{
- public const int ActiveLabelXYSeparation = 2;
- public const string ShortenedFormatString = "0.###";
+ #region Constants
+
+
+ #endregion Constants
+
+ #region Constructors
public ActiveValueLabelXY(
ActiveValueLabel x,
@@ -19,16 +23,20 @@ namespace grapher.Models.Options
Y = y;
FullWidth = x.Width;
- ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2;
+ ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2;
- Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation;
+ Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation;
Y.Width = ShortenedWidth;
- Y.FormatString = ShortenedFormatString;
+ Y.FormatString = Constants.ShortenedFormatString;
Combined = false;
SetCombined();
}
+ #endregion Constructors
+
+ #region Properties
+
public ActiveValueLabel X { get; }
public ActiveValueLabel Y { get; }
@@ -39,6 +47,10 @@ namespace grapher.Models.Options
private int ShortenedWidth { get; }
+ #endregion Properties
+
+ #region Methods
+
public void SetValues(double x, double y)
{
X.SetValue(x);
@@ -58,7 +70,7 @@ namespace grapher.Models.Options
{
if (!Combined)
{
- X.FormatString = ActiveValueLabel.DefaultFormatString;
+ X.FormatString = Constants.DefaultActiveValueFormatString;
X.Width = FullWidth;
X.Prefix = string.Empty;
Y.Hide();
@@ -71,7 +83,7 @@ namespace grapher.Models.Options
{
if (Combined)
{
- X.FormatString = ShortenedFormatString;
+ X.FormatString = Constants.ShortenedFormatString;
X.Width = ShortenedWidth;
X.Prefix = "X";
Y.Prefix = "Y";
@@ -80,5 +92,7 @@ namespace grapher.Models.Options
Combined = false;
}
+
+ #endregion Methods
}
}
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
new file mode 100644
index 0000000..bfbc1ef
--- /dev/null
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -0,0 +1,184 @@
+using grapher.Models.Serialized;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
+
+namespace grapher.Models.Options
+{
+ public class ApplyOptions
+ {
+ #region Constructors
+
+ public ApplyOptions(
+ ToolStripMenuItem wholeVectorMenuItem,
+ ToolStripMenuItem byComponentMenuItem,
+ CheckBox byComponentVectorXYLock,
+ AccelOptionSet optionSetX,
+ AccelOptionSet optionSetY)
+ {
+ WholeVectorMenuItem = wholeVectorMenuItem;
+ ByComponentVectorMenuItem = byComponentMenuItem;
+
+ WholeVectorMenuItem.Click += new System.EventHandler(OnWholeClicked);
+ ByComponentVectorMenuItem.Click += new System.EventHandler(OnByComponentClicked);
+
+ WholeVectorMenuItem.CheckedChanged += new System.EventHandler(OnWholeCheckedChange);
+ ByComponentVectorMenuItem.CheckedChanged += new System.EventHandler(OnByComponentCheckedChange);
+
+ ByComponentVectorXYLock = byComponentVectorXYLock;
+ OptionSetX = optionSetX;
+ OptionSetY = optionSetY;
+
+ ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked);
+ ByComponentVectorXYLock.Checked = true;
+
+ EnableWholeApplication();
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public ToolStripMenuItem WholeVectorMenuItem { get; }
+
+ public ToolStripMenuItem ByComponentVectorMenuItem { get; }
+
+ public CheckBox ByComponentVectorXYLock { get; }
+
+ public AccelOptionSet OptionSetX { get; }
+
+ public AccelOptionSet OptionSetY { get; }
+
+ public bool IsWhole { get; private set; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public Vec2<AccelMode> GetModes()
+ {
+ var xMode = (AccelMode)OptionSetX.AccelTypeOptions.AccelerationIndex;
+
+ return new Vec2<AccelMode>
+ {
+ x = xMode,
+ y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.AccelTypeOptions.AccelerationIndex
+ };
+ }
+
+ public Vec2<AccelArgs> GetArgs()
+ {
+ var xArgs = OptionSetX.GenerateArgs();
+
+ return new Vec2<AccelArgs>
+ {
+ x = xArgs,
+ y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs()
+ };
+
+ }
+
+ public void SetActiveValues(int xMode, int yMode, AccelArgs xArgs, AccelArgs yArgs, bool isWhole)
+ {
+ OptionSetX.SetActiveValues(xMode, xArgs);
+ OptionSetY.SetActiveValues(yMode, yArgs);
+ WholeVectorMenuItem.Checked = isWhole;
+ ByComponentVectorMenuItem.Checked = !isWhole;
+ }
+
+ public void SetActiveValues(DriverSettings settings)
+ {
+ SetActiveValues((int)settings.modes.x, (int)settings.modes.y, settings.args.x, settings.args.y, settings.combineMagnitudes);
+ }
+
+ public void OnWholeClicked(object sender, EventArgs e)
+ {
+ if (!WholeVectorMenuItem.Checked)
+ {
+ WholeVectorMenuItem.Checked = true;
+ ByComponentVectorMenuItem.Checked = false;
+ }
+ }
+
+ public void OnByComponentClicked(object sender, EventArgs e)
+ {
+ if (!ByComponentVectorMenuItem.Checked)
+ {
+ WholeVectorMenuItem.Checked = false;
+ ByComponentVectorMenuItem.Checked = true;
+ }
+ }
+
+ public void OnWholeCheckedChange(object sender, EventArgs e)
+ {
+ if (WholeVectorMenuItem.Checked)
+ {
+ EnableWholeApplication();
+ }
+ }
+
+ public void OnByComponentCheckedChange(object sender, EventArgs e)
+ {
+ EnableByComponentApplication();
+ }
+
+ public void ShowWholeSet()
+ {
+ OptionSetX.SetRegularMode();
+ OptionSetY.Hide();
+ }
+
+ public void ShowByComponentAsOneSet()
+ {
+ OptionSetX.SetTitleMode("X = Y");
+ OptionSetY.Hide();
+ }
+
+ public void ShowByComponentAsTwoSets()
+ {
+ OptionSetX.SetTitleMode("X");
+ OptionSetY.SetTitleMode("Y");
+ OptionSetY.Show();
+ }
+
+ public void ShowByComponentSet()
+ {
+ if (ByComponentVectorXYLock.Checked)
+ {
+ ShowByComponentAsOneSet();
+ }
+ else
+ {
+ ShowByComponentAsTwoSets();
+ }
+ }
+
+ private void OnByComponentXYLockChecked(object sender, EventArgs e)
+ {
+ if (!IsWhole)
+ {
+ ShowByComponentSet();
+ }
+ }
+
+ public void EnableWholeApplication()
+ {
+ IsWhole = true;
+ ByComponentVectorXYLock.Hide();
+ ShowWholeSet();
+ }
+
+ public void EnableByComponentApplication()
+ {
+ IsWhole = false;
+ ByComponentVectorXYLock.Show();
+ ShowByComponentSet();
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index 87bac88..6dc1116 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -10,20 +10,22 @@ namespace grapher
{
public class CapOptions
{
+ #region Constants
- public const string GainCapFormatString = "0.##";
+
+ #endregion Constants
+
+ #region Constructors
public CapOptions(
ToolStripMenuItem velocityGainCapCheck,
ToolStripMenuItem legacyCapCheck,
- OptionXY capOption,
- OptionXY weightOption)
+ Option capOption)
{
VelocityGainCapCheck = velocityGainCapCheck;
LegacyCapCheck = legacyCapCheck;
CapOption = capOption;
- WeightOption = weightOption;
LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick);
@@ -34,20 +36,24 @@ namespace grapher
EnableVelocityGainCap();
}
+ #endregion Constructors
+
+ #region Properties
+
public ToolStripMenuItem LegacyCapCheck { get; }
public ToolStripMenuItem VelocityGainCapCheck { get; }
- public OptionXY CapOption { get; }
+ public Option CapOption { get; }
- public OptionXY WeightOption { get; }
+ public bool IsSensitivityGain { get; private set; }
- public double SensitivityCapX {
+ public double SensitivityCap {
get
{
if (IsSensitivityGain)
{
- return CapOption.Fields.X;
+ return CapOption.Field.Data;
}
else
{
@@ -56,49 +62,78 @@ namespace grapher
}
}
- public double SensitivityCapY {
+ public double VelocityGainCap {
get
{
if (IsSensitivityGain)
{
- return CapOption.Fields.Y;
+ return 0;
}
else
{
- return 0;
+ return CapOption.Field.Data;
}
}
}
- public double VelocityGainCap {
+ public int Top
+ {
+ get
+ {
+ return CapOption.Top;
+ }
+ set
+ {
+ CapOption.Top = value;
+ }
+ }
+
+ public int Height
+ {
get
{
- if (IsSensitivityGain)
- {
- return 0;
- }
- else
- {
- return CapOption.Fields.X;
- }
+ return CapOption.Height;
}
}
- public bool IsSensitivityGain { get; private set; }
- public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled)
+ #endregion Properties
+
+ #region Methods
+
+ public void Hide()
+ {
+ CapOption.Hide();
+ }
+
+ public void Show()
+ {
+ CapOption.Show();
+ }
+
+ public void SnapTo(Option option)
+ {
+ Top = option.Top + option.Height + Constants.OptionVerticalSeperation;
+ }
+
+
+ public void SetActiveValues(double gainCap, double sensCap, bool capGainEnabled)
{
if (capGainEnabled)
{
- CapOption.ActiveValueLabels.X.FormatString = GainCapFormatString;
- CapOption.ActiveValueLabels.X.Prefix = "Gain";
- CapOption.SetActiveValues(gainCap, gainCap);
+ CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString;
+ CapOption.ActiveValueLabel.Prefix = "Gain";
+ CapOption.SetActiveValue(gainCap);
+ LegacyCapCheck.Checked = true;
+ VelocityGainCapCheck.Checked = false;
}
else
{
- CapOption.ActiveValueLabels.X.FormatString = ActiveValueLabel.DefaultFormatString;
- CapOption.ActiveValueLabels.X.Prefix = string.Empty;
- CapOption.SetActiveValues(sensCapX, sensCapY);
+ CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString;
+ CapOption.ActiveValueLabel.Prefix = string.Empty;
+ CapOption.SetActiveValue(sensCap);
+ LegacyCapCheck.Checked = false;
+ VelocityGainCapCheck.Checked = true;
}
}
@@ -139,19 +174,15 @@ namespace grapher
void EnableSensitivityCap()
{
IsSensitivityGain = true;
- CapOption.Fields.LockCheckBox.Enabled = true;
- WeightOption.Fields.LockCheckBox.Enabled = true;
CapOption.SetName("Sensitivity Cap");
}
void EnableVelocityGainCap()
{
IsSensitivityGain = false;
- CapOption.Fields.LockCheckBox.Checked = true;
- CapOption.Fields.LockCheckBox.Enabled = false;
- WeightOption.Fields.LockCheckBox.Checked = true;
- WeightOption.Fields.LockCheckBox.Enabled = false;
CapOption.SetName("Velocity Gain Cap");
}
+
+ #endregion Methods
}
}
diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs
index b0ef374..22b78d4 100644
--- a/grapher/Models/Options/Option.cs
+++ b/grapher/Models/Options/Option.cs
@@ -10,14 +10,22 @@ namespace grapher
{
public class Option
{
+ #region Constructors
+
public Option(
Field field,
Label label,
- ActiveValueLabel activeValueLabel)
+ ActiveValueLabel activeValueLabel,
+ int left)
{
Field = field;
Label = label;
ActiveValueLabel = activeValueLabel;
+ Left = left;
+
+ label.AutoSize = false;
+ label.Width = Field.Left - left - Constants.OptionLabelBoxSeperation;
+ label.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
}
public Option(
@@ -25,11 +33,13 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
+ int left,
ActiveValueLabel activeValueLabel)
: this(
new Field(box, containingForm, defaultData),
label,
- activeValueLabel)
+ activeValueLabel,
+ left)
{
}
@@ -38,6 +48,7 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
+ int left,
ActiveValueLabel activeValueLabel,
string startingName)
: this(
@@ -45,22 +56,70 @@ namespace grapher
containingForm,
defaultData,
label,
+ left,
activeValueLabel)
{
SetName(startingName);
}
+ #endregion Constructors
+
+ #region Properties
+
public Field Field { get; }
public Label Label { get; }
public ActiveValueLabel ActiveValueLabel { get; }
+ public int Top
+ {
+ get
+ {
+ return Field.Top;
+ }
+ set
+ {
+ Field.Top = value;
+ Label.Top = value;
+ }
+ }
+
+ public int Height
+ {
+ get
+ {
+ return Field.Height;
+ }
+ }
+
+ public int Left
+ {
+ get
+ {
+ return Label.Left;
+ }
+ private set
+ {
+ Label.Left = value;
+ }
+ }
+ public int Width
+ {
+ get
+ {
+ return Field.Left + Field.Width - Label.Left;
+ }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
public void SetName(string name)
{
Label.Text = name;
//Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); //Centered
- Label.Left = Convert.ToInt32(Field.Box.Left - Label.Width - 10); //Right-aligned
}
public void SetActiveValue(double value)
@@ -93,5 +152,17 @@ namespace grapher
Show();
}
+
+ public void SnapTo(Option option)
+ {
+ Top = option.Top + option.Height + Constants.OptionVerticalSeperation;
+ }
+
+ public void SnapTo(CapOptions option)
+ {
+ Top = option.Top + option.Height + Constants.OptionVerticalSeperation;
+ }
+
+ #endregion Methods
}
}
diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs
index 8e22617..c1fd0b7 100644
--- a/grapher/Models/Options/OptionXY.cs
+++ b/grapher/Models/Options/OptionXY.cs
@@ -10,6 +10,7 @@ namespace grapher
{
public class OptionXY
{
+ #region Constructors
public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels)
{
Fields = fields;
@@ -24,9 +25,8 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
- AccelCharts accelCharts,
ActiveValueLabelXY activeValueLabels)
- : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label, activeValueLabels)
+ : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData), label, activeValueLabels)
{
}
@@ -38,8 +38,7 @@ namespace grapher
double defaultData,
Label label,
ActiveValueLabelXY activeValueLabels,
- string startingName,
- AccelCharts accelCharts):
+ string startingName):
this(
xBox,
yBox,
@@ -47,18 +46,25 @@ namespace grapher
containingForm,
defaultData,
label,
- accelCharts,
activeValueLabels)
{
SetName(startingName);
}
+ #endregion Constructors
+
+ #region Properties
+
public FieldXY Fields { get; }
public Label Label { get; }
public ActiveValueLabelXY ActiveValueLabels { get; }
+ #endregion Properties
+
+ #region Methods
+
public void SetName(string name)
{
Label.Text = name;
@@ -92,5 +98,6 @@ namespace grapher
Show();
}
+ #endregion Methods
}
}