diff options
| author | Jacob Palecki <[email protected]> | 2020-09-02 01:02:51 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-02 01:02:51 -0700 |
| commit | 5b9b8ed308e7a8cefbd27b2db72d33d7b002e223 (patch) | |
| tree | 0d66b20cb15f95ac795247da90d3eb1d85a54d58 | |
| parent | Small fixes, correctly align labels and boxes (diff) | |
| download | rawaccel-5b9b8ed308e7a8cefbd27b2db72d33d7b002e223.tar.xz rawaccel-5b9b8ed308e7a8cefbd27b2db72d33d7b002e223.zip | |
Move optionsets to applyoptions
| -rw-r--r-- | grapher/Form1.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 24 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 12 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 17 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 26 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 79 |
6 files changed, 114 insertions, 47 deletions
diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 5df97a3..68a8a31 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -38,7 +38,7 @@ namespace grapher } ActiveValueTitle.AutoSize = false; - ActiveValueTitle.Left = LockXYLabel.Left + LockXYLabel.Width; + ActiveValueTitle.Left = accelerationBoxY.Left + accelerationBoxY.Width; ActiveValueTitle.Width = AccelerationChart.Left - ActiveValueTitle.Left; ActiveValueTitle.TextAlign = ContentAlignment.MiddleCenter; @@ -79,6 +79,7 @@ namespace grapher midpointBoxX, midpointBoxY, sensXYLock, + ByComponentXYLock, sensitivityLabel, rotationLabel, weightLabelX, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 891cd01..6b14672 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -27,8 +27,6 @@ namespace grapher ApplyOptions applyOptions, OptionXY sensitivity, Option rotation, - AccelOptionSet optionSetX, - AccelOptionSet optionSetY, Button writeButton, Label mouseMoveLabel, ToolStripMenuItem scaleMenuItem) @@ -42,8 +40,6 @@ namespace grapher WriteButton = writeButton; ScaleMenuItem = scaleMenuItem; Settings = settings; - OptionSetX = optionSetX; - OptionSetY = optionSetY; Settings.Startup(); RefreshOnRead(); @@ -70,10 +66,6 @@ namespace grapher public Option Rotation { get; } - public AccelOptionSet OptionSetX { get; } - - public AccelOptionSet OptionSetY { get; } - public Button WriteButton { get; } public MouseWatcher MouseWatcher { get; } @@ -95,16 +87,8 @@ namespace grapher y = Sensitivity.Fields.Y }, combineMagnitudes = ApplyOptions.IsWhole, - modes = new Vec2<AccelMode> - { - x = (AccelMode)OptionSetX.AccelTypeOptions.AccelerationIndex, - y = (AccelMode)OptionSetY.AccelTypeOptions.AccelerationIndex - }, - args = new Vec2<AccelArgs> - { - x = OptionSetX.GenerateArgs(), - y = OptionSetY.GenerateArgs() - }, + modes = ApplyOptions.GetModes(), + args = ApplyOptions.GetArgs(), minimumTime = .4 }); RefreshOnRead(); @@ -131,9 +115,7 @@ namespace grapher Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y); Rotation.SetActiveValue(settings.rotation); - ApplyOptions.SetActive(settings.combineMagnitudes); - OptionSetX.SetActiveValues((int)settings.modes.x, settings.args.x); - OptionSetY.SetActiveValues((int)settings.modes.y, settings.args.y); + ApplyOptions.SetActiveValues(settings); AccelCharts.RefreshXY(settings.combineMagnitudes); } diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 3c2a773..8ed4d72 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -52,6 +52,7 @@ namespace grapher.Models TextBox midpointBoxX, TextBox midpointBoxY, CheckBox sensXYLock, + CheckBox byComponentXYLock, Label sensitivityLabel, Label rotationLabel, Label weightLabelX, @@ -95,8 +96,6 @@ namespace grapher.Models new ChartXY(gainChart, gainChartY), showVelocityGainToolStripMenuItem); - var applyOptions = new ApplyOptions(wholeVectorToolStripMenuItem, byVectorComponentToolStripMenuItem); - var sensitivity = new OptionXY( sensitivityBoxX, sensitivityBoxY, @@ -271,6 +270,13 @@ namespace grapher.Models limitOrExponentY, midpointY); + var applyOptions = new ApplyOptions( + wholeVectorToolStripMenuItem, + byVectorComponentToolStripMenuItem, + byComponentXYLock, + optionsSetX, + optionsSetY); + var accelCalculator = new AccelCalculator( new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI), new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate)); @@ -289,8 +295,6 @@ namespace grapher.Models applyOptions, sensitivity, rotation, - optionsSetX, - optionsSetY, writeButton, mouseLabel, scaleMenuItem); diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs index e2f2bf7..46b6e3e 100644 --- a/grapher/Models/Options/AccelOptionSet.cs +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -69,15 +69,16 @@ namespace grapher.Models.Options } } - public void SetTitleMode() + public void SetTitleMode(string title) { if (!IsTitleMode) { IsTitleMode = true; + TitleLabel.Text = title; AccelTypeOptions.Left = Acceleration.Field.Left; AccelTypeOptions.Width = Acceleration.Field.Width; - AccelTypeOptions.ShowFullText(); + AccelTypeOptions.ShowShortenedText(); DisplayTitle(); } } @@ -86,12 +87,6 @@ namespace grapher.Models.Options { TitleLabel.Hide(); AccelTypeOptions.Hide(); - Acceleration.Hide(); - Cap.Hide(); - Weight.Hide(); - Offset.Hide(); - LimitOrExponent.Hide(); - Midpoint.Hide(); } public void Show() @@ -102,12 +97,6 @@ namespace grapher.Models.Options } AccelTypeOptions.Show(); - Acceleration.Show(); - Cap.Show(); - Weight.Show(); - Offset.Show(); - LimitOrExponent.Show(); - Midpoint.Show(); } public void DisplayTitle() diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 2359b8d..5342f4b 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -62,7 +62,15 @@ namespace grapher public ComboBox AccelDropdown { get; } - public int AccelerationIndex { get; private set; } + public int AccelerationIndex + { + get + { + return AccelerationType.Index; + } + } + + public LayoutBase AccelerationType { get; private set; } public ActiveValueLabel ActiveValueLabel { get; } @@ -125,11 +133,17 @@ namespace grapher public void Hide() { AccelDropdown.Hide(); + + foreach(var option in Options) + { + option.Hide(); + } } public void Show() { AccelDropdown.Show(); + Layout(); } public void SetActiveValue(int index) @@ -163,9 +177,13 @@ namespace grapher private void Layout(string type) { - var accelerationType = AccelerationTypes[type]; - AccelerationIndex = accelerationType.Index; - accelerationType.Layout(Options, WriteButton); + AccelerationType = AccelerationTypes[type]; + Layout(); + } + + private void Layout() + { + AccelerationType.Layout(Options, WriteButton); } #endregion Methods diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 703f0d5..0241fdf 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Serialized; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,7 +15,10 @@ namespace grapher.Models.Options public ApplyOptions( ToolStripMenuItem wholeVectorMenuItem, - ToolStripMenuItem byComponentMenuItem) + ToolStripMenuItem byComponentMenuItem, + CheckBox byComponentVectorXYLock, + AccelOptionSet optionSetX, + AccelOptionSet optionSetY) { WholeVectorMenuItem = wholeVectorMenuItem; ByComponentVectorMenuItem = byComponentMenuItem; @@ -25,6 +29,14 @@ namespace grapher.Models.Options 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 = false; + ByComponentVectorXYLock.Checked = true; + IsWhole = false; } @@ -36,18 +48,54 @@ namespace grapher.Models.Options 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 void SetActive(bool isWhole) + 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) @@ -82,6 +130,31 @@ namespace grapher.Models.Options } } + public void ShowWholeOptionSet() + { + OptionSetX.SetTitleMode("X = Y"); + OptionSetY.Hide(); + } + + public void ShowByComponentSets() + { + OptionSetX.SetTitleMode("X"); + OptionSetY.SetTitleMode("Y"); + OptionSetY.Show(); + } + + private void OnByComponentXYLockChecked(object sender, EventArgs e) + { + if (ByComponentVectorXYLock.Checked) + { + ShowWholeOptionSet(); + } + else + { + ShowByComponentSets(); + } + } + public void EnableWholeApplication() { IsWhole = true; |