diff options
| author | JacobPalecki <[email protected]> | 2020-09-08 16:00:05 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-08 16:00:05 -0700 |
| commit | e5461fa84e65d78823d0022339fa2d8864f7e63c (patch) | |
| tree | b486ef524c93bfeb29a86403114b6805bf9decf1 /grapher/Layouts | |
| parent | Merge pull request #19 from JacobPalecki/gainOffset (diff) | |
| parent | Save show last mouse value (diff) | |
| download | rawaccel-e5461fa84e65d78823d0022339fa2d8864f7e63c.tar.xz rawaccel-e5461fa84e65d78823d0022339fa2d8864f7e63c.zip | |
Merge pull request #20 from JacobPalecki/GUI
GUI: Add By Component & Anisotropy; Remove Logarithm and Sigmoid; Delete Console; Some Refactoring
Diffstat (limited to 'grapher/Layouts')
| -rw-r--r-- | grapher/Layouts/ClassicLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/DefaultLayout.cs | 16 | ||||
| -rw-r--r-- | grapher/Layouts/LayoutBase.cs | 102 | ||||
| -rw-r--r-- | grapher/Layouts/LinearLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/LogLayout.cs | 21 | ||||
| -rw-r--r-- | grapher/Layouts/NaturalGainLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/NaturalLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/OffLayout.cs | 15 | ||||
| -rw-r--r-- | grapher/Layouts/OptionLayout.cs | 41 | ||||
| -rw-r--r-- | grapher/Layouts/PowerLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/SigmoidGainLayout.cs | 14 | ||||
| -rw-r--r-- | grapher/Layouts/SigmoidLayout.cs | 21 |
12 files changed, 165 insertions, 135 deletions
diff --git a/grapher/Layouts/ClassicLayout.cs b/grapher/Layouts/ClassicLayout.cs index 05f6c82..572566f 100644 --- a/grapher/Layouts/ClassicLayout.cs +++ b/grapher/Layouts/ClassicLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "Classic"; Index = (int)AccelMode.classic; - ShowOptions = new bool[] { true, true, true, false }; - OptionNames = new string[] { Offset, Acceleration, Exponent, string.Empty }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(true, Cap); + WeightLayout = new OptionLayout(true, Weight); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, Exponent); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs index 42841d5..83535c2 100644 --- a/grapher/Layouts/DefaultLayout.cs +++ b/grapher/Layouts/DefaultLayout.cs @@ -1,11 +1,4 @@ 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.Layouts { @@ -16,9 +9,14 @@ namespace grapher.Layouts { Name = "Default"; Index = (int)AccelMode.noaccel; - ShowOptions = new bool[] { true, true, true, true }; - OptionNames = new string[] { Offset, Acceleration, $"{Limit}\\{Exponent}", Midpoint }; ButtonEnabled = false; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(true, Cap); + WeightLayout = new OptionLayout(true, Weight); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, $"{Limit}\\{Exponent}"); + MidpointLayout = new OptionLayout(true, Midpoint); } } } diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index eed1716..6ed8fee 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using grapher.Models.Options; using System.Windows.Forms; namespace grapher.Layouts @@ -15,12 +11,18 @@ namespace grapher.Layouts public const string Limit = "Limit"; public const string Midpoint = "Midpoint"; public const string Offset = "Offset"; + public const string Cap = "Cap"; + public const string Weight = "Weight"; public LayoutBase() { - ShowOptions = new bool[] { false, false, false, false }; - ShowOptionsXY = new bool[] { true, true }; - OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty }; + AccelLayout = new OptionLayout(false, string.Empty); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(false, string.Empty); + LimExpLayout = new OptionLayout(false, string.Empty); + MidpointLayout = new OptionLayout(false, string.Empty); + ButtonEnabled = true; } @@ -32,43 +34,75 @@ namespace grapher.Layouts public string Name { get; internal set; } - internal bool[] ShowOptions { get; set; } + protected bool ButtonEnabled { get; set; } + + protected OptionLayout AccelLayout { get; set; } + + protected OptionLayout CapLayout { get; set; } - internal bool[] ShowOptionsXY { get; set; } + protected OptionLayout WeightLayout { get; set; } - internal string[] OptionNames { get; set; } + protected OptionLayout OffsetLayout { get; set; } - internal bool ButtonEnabled { get; set; } + protected OptionLayout LimExpLayout { get; set; } - public void Layout(Option[] options, OptionXY[] optionsXY, Button button) + protected OptionLayout MidpointLayout { get; set; } + + public void Layout( + IOption accelOption, + IOption capOption, + IOption weightOption, + IOption offsetOption, + IOption limExpOption, + IOption midpointOption, + Button button, + int top) { - // Relies on AccelOptions to keep lengths correct. - for (int i = 0; i < options.Length; i++) - { - if (ShowOptions[i]) - { - options[i].Show(OptionNames[i]); - } - else - { - options[i].Hide(); - } - } + AccelLayout.Layout(accelOption); + CapLayout.Layout(capOption); + WeightLayout.Layout(weightOption); + OffsetLayout.Layout(offsetOption); + LimExpLayout.Layout(limExpOption); + MidpointLayout.Layout(midpointOption); + + button.Enabled = ButtonEnabled; - // Relies on AccelOptions to keep lengths correct. - for (int i = 0; i< optionsXY.Length; i++) + IOption previous = null; + foreach (var option in new IOption[] { accelOption, capOption, weightOption, offsetOption, limExpOption, midpointOption}) { - if (ShowOptionsXY[i]) - { - optionsXY[i].Show(); - } - else + if (option.Visible) { - optionsXY[i].Hide(); + if (previous != null) + { + option.SnapTo(previous); + } + else + { + option.Top = top; + } + + previous = option; } } + } - button.Enabled = ButtonEnabled; + public void Layout( + IOption accelOption, + IOption capOption, + IOption weightOption, + IOption offsetOption, + IOption limExpOption, + IOption midpointOption, + Button button) + { + Layout(accelOption, + capOption, + weightOption, + offsetOption, + limExpOption, + midpointOption, + button, + accelOption.Top); } } } diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs index 0a79a64..fded8c7 100644 --- a/grapher/Layouts/LinearLayout.cs +++ b/grapher/Layouts/LinearLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "Linear"; Index = (int)AccelMode.linear; - ShowOptions = new bool[] { true, true, false, false }; - OptionNames = new string[] { Offset, Acceleration, string.Empty, string.Empty }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(true, Cap); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(false, string.Empty); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/LogLayout.cs b/grapher/Layouts/LogLayout.cs deleted file mode 100644 index 1206fb3..0000000 --- a/grapher/Layouts/LogLayout.cs +++ /dev/null @@ -1,21 +0,0 @@ -using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace grapher.Layouts -{ - public class LogLayout : LayoutBase - { - public LogLayout() - : base() - { - Name = "Logarithmic"; - Index = (int)AccelMode.logarithmic; - ShowOptions = new bool[] { true, true, false, false }; - OptionNames = new string[] { Offset, Acceleration, string.Empty, string.Empty }; - } - } -} diff --git a/grapher/Layouts/NaturalGainLayout.cs b/grapher/Layouts/NaturalGainLayout.cs index 9bb1ec8..b982b91 100644 --- a/grapher/Layouts/NaturalGainLayout.cs +++ b/grapher/Layouts/NaturalGainLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "NaturalGain"; Index = (int)AccelMode.naturalgain; - ShowOptions = new bool[] { true, true, true, false }; - OptionNames = new string[] { Offset, Acceleration, Limit, string.Empty }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, Limit); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs index 44c6c18..aa5c22c 100644 --- a/grapher/Layouts/NaturalLayout.cs +++ b/grapher/Layouts/NaturalLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "Natural"; Index = (int)AccelMode.natural; - ShowOptions = new bool[] { true, true, true, false }; - OptionNames = new string[] { Offset, Acceleration, Limit, string.Empty }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, Limit); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs index ce7c149..85c8d3f 100644 --- a/grapher/Layouts/OffLayout.cs +++ b/grapher/Layouts/OffLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,10 +9,14 @@ namespace grapher.Layouts { Name = "Off"; Index = (int)AccelMode.noaccel; - ShowOptions = new bool[] { false, false, false, false }; - OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty }; - ShowOptionsXY = new bool[] { false, false }; ButtonEnabled = true; + + AccelLayout = new OptionLayout(false, string.Empty); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(false, string.Empty); + LimExpLayout = new OptionLayout(false, string.Empty); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/OptionLayout.cs b/grapher/Layouts/OptionLayout.cs new file mode 100644 index 0000000..2f29706 --- /dev/null +++ b/grapher/Layouts/OptionLayout.cs @@ -0,0 +1,41 @@ +using grapher.Models.Options; + +namespace grapher.Layouts +{ + public class OptionLayout + { + #region Constructors + + public OptionLayout(bool show, string name) + { + Show = show; + Name = name; + } + + #endregion Constructors + + #region Properties + + private bool Show { get; } + + private string Name { get; } + + #endregion Properties + + #region Methods + + public void Layout(IOption option) + { + if (Show) + { + option.Show(Name); + } + else + { + option.Hide(); + } + } + + #endregion Methods + } +} diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs index c14083a..e0dcaf8 100644 --- a/grapher/Layouts/PowerLayout.cs +++ b/grapher/Layouts/PowerLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "Power"; Index = (int)AccelMode.power; - ShowOptions = new bool[] { true, true, true, false }; - OptionNames = new string[] { Offset, Scale, Exponent, string.Empty }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(true, Cap); + WeightLayout = new OptionLayout(true, Weight); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, Limit); + MidpointLayout = new OptionLayout(false, string.Empty); } } } diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/SigmoidGainLayout.cs index 93214ec..183e31f 100644 --- a/grapher/Layouts/SigmoidGainLayout.cs +++ b/grapher/Layouts/SigmoidGainLayout.cs @@ -1,9 +1,4 @@ using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Layouts { @@ -14,8 +9,13 @@ namespace grapher.Layouts { Name = "SigmoidGain"; Index = (int)AccelMode.sigmoidgain; - ShowOptions = new bool[] { true, true, true, true }; - OptionNames = new string[] { Offset, Acceleration, Limit, Midpoint }; + + AccelLayout = new OptionLayout(true, Acceleration); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(true, Limit); + MidpointLayout = new OptionLayout(true, Midpoint); } } } diff --git a/grapher/Layouts/SigmoidLayout.cs b/grapher/Layouts/SigmoidLayout.cs deleted file mode 100644 index 1c7f0b9..0000000 --- a/grapher/Layouts/SigmoidLayout.cs +++ /dev/null @@ -1,21 +0,0 @@ -using grapher.Models.Serialized; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace grapher.Layouts -{ - public class SigmoidLayout : LayoutBase - { - public SigmoidLayout() - : base() - { - Name = "Sigmoid"; - Index = (int)AccelMode.sigmoid; - ShowOptions = new bool[] { true, true, true, true }; - OptionNames = new string[] { Offset, Acceleration, Limit, Midpoint }; - } - } -} |