diff options
| author | Jacob Palecki <[email protected]> | 2021-09-13 00:40:57 -0700 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-09-23 22:33:13 -0400 |
| commit | c0f2aa4a41de22936a5ed177c3b83792cc8231a8 (patch) | |
| tree | c543fecc5816ad96cb1811b8a9fd7030a258d693 | |
| parent | YToXRatio fully works (diff) | |
| download | rawaccel-c0f2aa4a41de22936a5ed177c3b83792cc8231a8.tar.xz rawaccel-c0f2aa4a41de22936a5ed177c3b83792cc8231a8.zip | |
Most of Cap Type options in GUI
| -rw-r--r-- | grapher/Models/Options/Cap/CapOptions.cs | 147 | ||||
| -rw-r--r-- | grapher/Models/Options/Cap/CapTypeOptions.cs | 93 | ||||
| -rw-r--r-- | grapher/Models/Options/ComboBoxOptionsBase.cs | 129 | ||||
| -rw-r--r-- | grapher/Models/Options/LUT/LutApplyOptions.cs | 138 |
4 files changed, 401 insertions, 106 deletions
diff --git a/grapher/Models/Options/Cap/CapOptions.cs b/grapher/Models/Options/Cap/CapOptions.cs new file mode 100644 index 0000000..144cd79 --- /dev/null +++ b/grapher/Models/Options/Cap/CapOptions.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options.Cap +{ + public class CapOptions : OptionBase + { + public enum CapType + { + In, + Out, + Both, + } + + public CapOptions( + ComboBox capTypeDropDown, + Option capIn, + Option capOut, + Option slope) + { + CapTypeDropdown = capTypeDropDown; + In = capIn; + Out = capOut; + Slope = slope; + + SetupCapTypeDropdown(CapTypeDropdown); + CapTypeDropdown.SelectedItem = CapType.In; + } + + public ComboBox CapTypeDropdown { get; } + + public Option In { get; } + + public Option Out { get; } + + public Option Slope { get; } + + public CapType SelectedCapType { get; private set; } + + public override int Left + { + get => In.Left; + + set + { + In.Left = value; + Out.Left = value; + Slope.Left = value; + } + } + + public override int Top + { + get => CapTypeDropdown.Top; + set + { + CapTypeDropdown.Top = value; + Layout(); + } + } + + public override int Height + { + get => BottomElement.Top + BottomElement.Height - CapTypeDropdown.Top; + } + + public override int Width + { + get => CapTypeDropdown.Width; + + set + { + CapTypeDropdown.Width = value; + In.Width = value; + Out.Width = value; + Slope.Width = value; + } + } + + public override bool Visible + { + get => CapTypeDropdown.Visible; + } + + private Option BottomElement { get; set; } + + public void Layout() + { + Layout(CapTypeDropdown.Top + CapTypeDropdown.Height + Constants.OptionVerticalSeperation); + } + + private void Layout(int top) + { + switch (SelectedCapType) + { + case CapType.In: + Slope.Show(); + In.Show(); + Out.Hide(); + + Slope.Top = top; + In.SnapTo(Slope); + BottomElement = In; + break; + case CapType.Out: + Slope.Show(); + In.Hide(); + Out.Show(); + + Slope.Top = top; + In.SnapTo(Slope); + BottomElement = In; + break; + case CapType.Both: + Slope.Hide(); + In.Show(); + Out.Show(); + + In.Top = top; + Out.SnapTo(In); + BottomElement = Out; + break; + } + } + + private void FindSelectedTypeFromDropdown() + { + SelectedCapType = (CapType)CapTypeDropdown.SelectedItem; + } + + private void OnCapTypeDropdownSelectedItemChanged(object sender, EventArgs e) + { + FindSelectedTypeFromDropdown(); + Layout(); + } + + private void SetupCapTypeDropdown(ComboBox capTypeDropDown) + { + capTypeDropDown.Items.Clear(); + capTypeDropDown.DataSource = Enum.GetValues(typeof(CapType)); + } + } +} diff --git a/grapher/Models/Options/Cap/CapTypeOptions.cs b/grapher/Models/Options/Cap/CapTypeOptions.cs new file mode 100644 index 0000000..b2cca57 --- /dev/null +++ b/grapher/Models/Options/Cap/CapTypeOptions.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options.Cap +{ + public class CapTypeOptions : ComboBoxOptionsBase + { + #region Enum + + public enum CapType + { + In, + Out, + Both, + } + + #endregion Enum + + #region Classes + + public class CapTypeOption + { + public CapType Type { get; set; } + + public string Name => Type.ToString(); + + public override string ToString() => Name; + } + + #endregion Classes + + #region Static + + public static readonly CapTypeOption InCap = new CapTypeOption + { + Type = CapType.In, + }; + + public static readonly CapTypeOption OutCap = new CapTypeOption + { + Type = CapType.Out, + }; + + public static readonly CapTypeOption BothCap = new CapTypeOption + { + Type = CapType.Both, + }; + + public static readonly CapTypeOption[] AllCapTypeOptions = new CapTypeOption[] + { + InCap, + OutCap, + BothCap + }; + + #endregion Static + + #region Constructors + + public CapTypeOptions( + Label label, + ComboBox dropdown, + ActiveValueLabel activeValueLabel) + : base( + label, + dropdown, + activeValueLabel) + { + } + + #endregion Constructors + + #region Properties + + CapTypeOption CapOption + { + get + { + return OptionsDropdown.SelectedItem as CapTypeOption; + } + set + { + OptionsDropdown.SelectedItem = value; + } + } + + #endregion Properties + } +} diff --git a/grapher/Models/Options/ComboBoxOptionsBase.cs b/grapher/Models/Options/ComboBoxOptionsBase.cs new file mode 100644 index 0000000..64e0092 --- /dev/null +++ b/grapher/Models/Options/ComboBoxOptionsBase.cs @@ -0,0 +1,129 @@ +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 abstract class ComboBoxOptionsBase : OptionBase + { + #region Constructors + + public ComboBoxOptionsBase( + Label label, + ComboBox dropdown, + ActiveValueLabel activeValueLabel) + { + OptionsDropdown = dropdown; + OptionsDropdown.Items.Clear(); + + Label = label; + Label.AutoSize = false; + Label.Width = 50; + + ActiveValueLabel = activeValueLabel; + } + + #endregion Constructors + + #region Properties + + public Label Label { get; } + + public ActiveValueLabel ActiveValueLabel { get; } + + public ComboBox OptionsDropdown { get; } + + public override bool Visible + { + get + { + return Label.Visible || ShouldShow; + } + } + + public override int Left + { + get + { + return Label.Left; + } + set + { + Label.Left = value; + OptionsDropdown.Left = Label.Left + Label.Width + Constants.OptionVerticalSeperation; + } + } + + public override int Height + { + get + { + return Label.Height; + } + } + + public override int Top + { + get + { + return Label.Top; + } + set + { + OptionsDropdown.Top = value; + Label.Top = (OptionsDropdown.Height - Label.Height) / 2 + OptionsDropdown.Top; + ActiveValueLabel.Top = value; + } + } + + public override int Width + { + get + { + return Label.Width; + } + set + { + OptionsDropdown.Width = value - Label.Width - Constants.OptionLabelBoxSeperation; + } + } + + protected bool ShouldShow { get; set; } + + #endregion Properties + + #region Methods + + public override void Hide() + { + Label.Hide(); + OptionsDropdown.Hide(); + ActiveValueLabel.Hide(); + ShouldShow = false; + } + + public override void Show(string labelText) + { + Label.Show(); + + if (!string.IsNullOrWhiteSpace(labelText)) + { + Label.Text = labelText; + } + + OptionsDropdown.Show(); + ActiveValueLabel.Show(); + ShouldShow = true; + } + + public override void AlignActiveValues() + { + ActiveValueLabel.Align(); + } + + #endregion Methods + } +} diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs index 7d8c737..61cae61 100644 --- a/grapher/Models/Options/LUT/LutApplyOptions.cs +++ b/grapher/Models/Options/LUT/LutApplyOptions.cs @@ -7,10 +7,9 @@ using System.Windows.Forms; namespace grapher.Models.Options.LUT { - public class LutApplyOptions : OptionBase + public class LutApplyOptions : ComboBoxOptionsBase { - public const string LUTApplyOptionsLabelText = "Apply as:"; - public const int LUTApplyLabelDropdownSeparation = 4; + #region Enum public enum LutApplyType { @@ -18,6 +17,10 @@ namespace grapher.Models.Options.LUT Velocity } + #endregion Enum + + #region Classes + public class LutApplyOption { public LutApplyType Type { get; set; } @@ -27,6 +30,10 @@ namespace grapher.Models.Options.LUT public override string ToString() => Name; } + #endregion Classes + + #region Static + public static readonly LutApplyOption Sensitivity = new LutApplyOption { Type = LutApplyType.Sensitivity, @@ -37,129 +44,58 @@ namespace grapher.Models.Options.LUT Type = LutApplyType.Velocity, }; + #endregion Static + + #region Constructors + public LutApplyOptions( Label label, ComboBox applyOptionsDropdown, ActiveValueLabel lutApplyActiveValue) + : base( + label, + applyOptionsDropdown, + lutApplyActiveValue) { - ApplyOptions = applyOptionsDropdown; - ApplyOptions.Items.Clear(); - ApplyOptions.Items.AddRange( + OptionsDropdown.Items.AddRange( new LutApplyOption[] { Sensitivity, Velocity, }); + } - Label = label; - Label.Text = LUTApplyOptionsLabelText; - Label.AutoSize = false; - Label.Width = 50; + #endregion Constructors - ActiveValueLabel = lutApplyActiveValue; - } + #region Properties public LutApplyType ApplyType { get => ApplyOption.Type; } public LutApplyOption ApplyOption { get { - return ApplyOptions.SelectedItem as LutApplyOption; - } - set - { - ApplyOptions.SelectedItem = value; - } - } - - public Label Label { get; } - - public ActiveValueLabel ActiveValueLabel { get; } - - public ComboBox ApplyOptions { get; } - - public override bool Visible - { - get - { - return Label.Visible || ShouldShow; - } - } - - public override int Left - { - get - { - return Label.Left; + return OptionsDropdown.SelectedItem as LutApplyOption; } set { - Label.Left = value; - ApplyOptions.Left = Label.Left + Label.Width + LUTApplyLabelDropdownSeparation; + OptionsDropdown.SelectedItem = value; } } - public override int Height - { - get - { - return Label.Height; - } - } + #endregion Properties - public override int Top - { - get - { - return Label.Top; - } - set - { - ApplyOptions.Top = value; - Label.Top = (ApplyOptions.Height - Label.Height) / 2 + ApplyOptions.Top; - ActiveValueLabel.Top = value; - } - } + #region Methods - public override int Width + public static LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity) { - get - { - return Label.Width; - } - set + if (applyAsVelocity) { - ApplyOptions.Width = value - Label.Width - Constants.OptionLabelBoxSeperation; + return Velocity; } - } - - private bool ShouldShow { get; set; } - - public override void Hide() - { - Label.Hide(); - ApplyOptions.Hide(); - ActiveValueLabel.Hide(); - ShouldShow = false; - } - - public override void Show(string labelText) - { - Label.Show(); - - if (!string.IsNullOrWhiteSpace(labelText)) + else { - Label.Text = labelText; + return Sensitivity; } - - ApplyOptions.Show(); - ActiveValueLabel.Show(); - ShouldShow = true; - } - - public override void AlignActiveValues() - { - ActiveValueLabel.Align(); } public void SetActiveValue(bool applyAsVelocity) @@ -168,16 +104,6 @@ namespace grapher.Models.Options.LUT ActiveValueLabel.SetValue(ApplyOption.Name); } - public LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity) - { - if (applyAsVelocity) - { - return Velocity; - } - else - { - return Sensitivity; - } - } + #endregion Methods } } |