diff options
| author | a1xd <[email protected]> | 2020-07-31 17:56:46 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-31 17:56:46 -0400 |
| commit | 1fcbb0fa51dbc35958d211026e4d40384a049049 (patch) | |
| tree | efb65bf3f305f376ea75f4f687b08bf8998c020f /grapher/Layouts/LayoutBase.cs | |
| parent | Merge pull request #6 from a1xd/st-refactor (diff) | |
| parent | Show no settings for off, remove unused class for PR (diff) | |
| download | rawaccel-1fcbb0fa51dbc35958d211026e4d40384a049049.tar.xz rawaccel-1fcbb0fa51dbc35958d211026e4d40384a049049.zip | |
Merge pull request #7 from JacobPalecki/GUI
Add GUI
Diffstat (limited to 'grapher/Layouts/LayoutBase.cs')
| -rw-r--r-- | grapher/Layouts/LayoutBase.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs new file mode 100644 index 0000000..a4d0827 --- /dev/null +++ b/grapher/Layouts/LayoutBase.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Layouts +{ + public abstract class LayoutBase + { + public const string Acceleration = "Acceleration"; + public const string Scale = "Scale"; + public const string Exponent = "Exponent"; + public const string Limit = "Limit"; + public const string Midpoint = "Midpoint"; + public const string Offset = "Offset"; + + 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 }; + ButtonEnabled = true; + } + + /// <summary> + /// Gets or sets mapping from acceleration type to identifying integer. + /// Must match order in tagged_union in rawaccel.hpp (which is 1-indexed, meaning 0 is off.) + /// </summary> + public int Index { get; internal set; } + + public string Name { get; internal set; } + + internal bool[] ShowOptions { get; set; } + + internal bool[] ShowOptionsXY { get; set; } + + internal string[] OptionNames { get; set; } + + internal bool ButtonEnabled { get; set; } + + public void Layout(Option[] options, OptionXY[] optionsXY, Button button) + { + // 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(); + } + } + + // Relies on AccelOptions to keep lengths correct. + for (int i = 0; i< optionsXY.Length; i++) + { + if (ShowOptionsXY[i]) + { + optionsXY[i].Show(); + } + else + { + optionsXY[i].Hide(); + } + } + + button.Enabled = ButtonEnabled; + } + } +} |