summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-09-28 01:32:02 -0400
committerGitHub <[email protected]>2020-09-28 01:32:02 -0400
commite49d06cae37765bb614c1740f9495a8c1d3100ac (patch)
tree6ca7d9612db7a139b60ccfd7407c338e4a0109f7 /grapher/Models
parentMerge pull request #26 from a1xd/argcheck (diff)
parentFix legacy offset bugs (diff)
downloadrawaccel-e49d06cae37765bb614c1740f9495a8c1d3100ac.tar.xz
rawaccel-e49d06cae37765bb614c1740f9495a8c1d3100ac.zip
Merge pull request #27 from JacobPalecki/GUI
GUI Error Handling
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/AccelGUI.cs5
-rw-r--r--grapher/Models/Options/OffsetOptions.cs27
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs29
3 files changed, 36 insertions, 25 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 5b37e81..15a0c0e 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -3,7 +3,6 @@ using grapher.Models.Mouse;
using grapher.Models.Options;
using grapher.Models.Serialized;
using System;
-using System.Drawing;
using System.Windows.Forms;
namespace grapher
@@ -97,7 +96,7 @@ namespace grapher
}
else
{
- WriteButton.Text = "bad args";
+ throw new Exception($"Bad arguments: \n {SettingsManager.ErrorStringFrom(errors)}");
}
}
@@ -151,12 +150,14 @@ namespace grapher
{
WriteButton.Text = Constants.WriteButtonDefaultText;
WriteButton.Enabled = true;
+ WriteButton.Update();
}
private void SetWriteButtonDelay()
{
WriteButton.Enabled = false;
WriteButton.Text = $"{Constants.WriteButtonDelayText} : {ButtonTimer.Interval} ms";
+ WriteButton.Update();
}
private void OnScaleMenuItemClick(object sender, EventArgs e)
diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs
index c6bee75..6638ed7 100644
--- a/grapher/Models/Options/OffsetOptions.cs
+++ b/grapher/Models/Options/OffsetOptions.cs
@@ -31,33 +31,11 @@ namespace grapher.Models.Options
public bool IsLegacy { get; private set; }
- public double LegacyOffset
- {
- get
- {
- if (IsLegacy)
- {
- return OffsetOption.Field.Data;
- }
- else
- {
- return 0;
- }
- }
- }
-
public double Offset
{
get
{
- if (IsLegacy)
- {
- return 0;
- }
- else
- {
- return OffsetOption.Field.Data;
- }
+ return OffsetOption.Field.Data;
}
}
@@ -131,6 +109,9 @@ namespace grapher.Models.Options
public void SetActiveValue(double offset, bool legacy)
{
OffsetOption.SetActiveValue(offset);
+
+ VelocityGainOffsetCheck.Checked = !legacy;
+ LegacyOffsetCheck.Checked = legacy;
}
public override void AlignActiveValues()
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index 93cf42b..416823e 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -2,6 +2,7 @@
using System;
using System.Windows.Forms;
using System.Threading;
+using System.Text;
namespace grapher.Models.Serialized
{
@@ -47,6 +48,34 @@ namespace grapher.Models.Serialized
#region Methods
+ public static string ErrorStringFrom(SettingsErrors errors)
+ {
+ StringBuilder builder = new StringBuilder();
+ bool yPresent = errors.y?.Count > 0;
+
+ if (yPresent)
+ {
+ builder.AppendLine("\nx:");
+ }
+
+ foreach (var error in errors.x)
+ {
+ builder.AppendLine(error);
+ }
+
+ if (yPresent)
+ {
+ builder.AppendLine("\ny:");
+
+ foreach (var error in errors.y)
+ {
+ builder.AppendLine(error);
+ }
+ }
+
+ return builder.ToString();
+ }
+
public SettingsErrors TryUpdateActiveSettings(DriverSettings settings)
{
var errors = TryUpdateAccel(settings);