diff options
| author | a1xd <[email protected]> | 2021-09-16 20:45:06 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-09-21 22:22:36 -0400 |
| commit | b5161317281a4c32b6a8d332389ee8178f244ce0 (patch) | |
| tree | a58f23598aa0a1b556769ce18a298ff87e1c15c6 /grapher/Models | |
| parent | rename disable button to reset (diff) | |
| download | rawaccel-b5161317281a4c32b6a8d332389ee8178f244ce0.tar.xz rawaccel-b5161317281a4c32b6a8d332389ee8178f244ce0.zip | |
handle lut mode exceptions on apply
Diffstat (limited to 'grapher/Models')
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 33 | ||||
| -rw-r--r-- | grapher/Models/Options/LUT/LUTPanelOptions.cs | 14 |
2 files changed, 33 insertions, 14 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e694dd4..4ce6ed8 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -112,7 +112,7 @@ namespace grapher } } - public void UpdateActiveSettingsFromFields() + public DriverSettings MakeSettingsFromFields() { var settings = new DriverSettings(); @@ -130,19 +130,38 @@ namespace grapher Settings.SetHiddenOptions(settings); - ButtonDelay(WriteButton); + return settings; + } - SettingsErrors errors = Settings.TryActivate(settings); - if (errors.Empty()) + public void UpdateActiveSettingsFromFields() + { + string error_message; + + try { - RefreshActive(); + ButtonDelay(WriteButton); + + var settings = MakeSettingsFromFields(); + SettingsErrors errors = Settings.TryActivate(settings); + if (errors.Empty()) + { + RefreshActive(); + return; + } + else + { + error_message = errors.ToString(); + } } - else + catch (ApplicationException e) { - new MessageDialog(errors.ToString(), "bad input").ShowDialog(); + error_message = e.Message; } + + new MessageDialog(error_message, "bad input").ShowDialog(); } + public void UpdateInputManagers() { MouseWatcher.UpdateHandles(Settings.ActiveSettings.baseSettings.deviceID); diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs index 0d244b4..4357619 100644 --- a/grapher/Models/Options/LUT/LUTPanelOptions.cs +++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs @@ -137,7 +137,7 @@ namespace grapher.Models.Options.LUT { if (string.IsNullOrWhiteSpace(userText)) { - throw new Exception("Text must be entered in text box to fill Look Up Table."); + throw new ApplicationException("Text must be entered in text box to fill Look Up Table."); } Vec2<float>[] points = new Vec2<float>[256]; @@ -152,7 +152,7 @@ namespace grapher.Models.Options.LUT if (pointSplit.Length != 2) { - throw new Exception($"Point at index {index} is malformed. Expected format: x,y; Given: {pointEntry.Trim()}"); + throw new ApplicationException($"Point at index {index} is malformed. Expected format: x,y; Given: {pointEntry.Trim()}"); } float x; @@ -164,17 +164,17 @@ namespace grapher.Models.Options.LUT } catch (Exception ex) { - throw new Exception($"X-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[0]}", ex); + throw new ApplicationException($"X-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[0]}", ex); } if (x <= 0) { - throw new Exception($"X-value for point at index {index} is less than or equal to 0. Point (0,0) is implied and should not be specified in points text."); + throw new ApplicationException($"X-value for point at index {index} is less than or equal to 0. Point (0,0) is implied and should not be specified in points text."); } if (x <= lastX) { - throw new Exception($"X-value for point at index {index} is less than or equal to previous x-value. Value: {x} Previous: {lastX}"); + throw new ApplicationException($"X-value for point at index {index} is less than or equal to previous x-value. Value: {x} Previous: {lastX}"); } lastX = x; @@ -185,12 +185,12 @@ namespace grapher.Models.Options.LUT } catch (Exception ex) { - throw new Exception($"Y-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[1]}", ex); + throw new ApplicationException($"Y-value for point at index {index} is malformed. Expected: float. Given: {pointSplit[1]}", ex); } if (y <= 0) { - throw new Exception($"Y-value for point at index {index} is less than or equal to 0. Value: {y}"); + throw new ApplicationException($"Y-value for point at index {index} is less than or equal to 0. Value: {y}"); } points[index] = new Vec2<float> { x = x, y = y }; |