From 53c9025337166a408febc15078af3e9b136b3bab Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 19 Aug 2020 15:26:25 -0700 Subject: Add natural gain accel; add scale by DPI, poll rate in GUI --- grapher/Models/AccelGUI.cs | 17 ++++++- grapher/Models/Calculations/AccelCalculator.cs | 64 ++++++++++++++++++++------ grapher/Models/Options/AccelOptions.cs | 1 + 3 files changed, 66 insertions(+), 16 deletions(-) (limited to 'grapher/Models') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 8eb2226..2c27bf7 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -18,6 +18,7 @@ namespace grapher public AccelGUI( RawAcceleration accelForm, + AccelCalculator accelCalculator, AccelCharts accelCharts, ManagedAccel managedAccel, AccelOptions accelOptions, @@ -30,9 +31,11 @@ namespace grapher Option limtOrExp, Option midpoint, Button writeButton, - Label mouseMoveLabel) + Label mouseMoveLabel, + ToolStripMenuItem scaleMenuItem) { AccelForm = accelForm; + AccelCalculator = accelCalculator; AccelCharts = accelCharts; ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; @@ -45,11 +48,14 @@ namespace grapher LimitOrExponent = limtOrExp; Midpoint = midpoint; WriteButton = writeButton; + ScaleMenuItem = scaleMenuItem; ManagedAcceleration.ReadFromDriver(); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); + + ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick); } #endregion constructors @@ -58,6 +64,8 @@ namespace grapher public RawAcceleration AccelForm { get; } + public AccelCalculator AccelCalculator { get; } + public AccelCharts AccelCharts { get; } public ManagedAccel ManagedAcceleration { get; } @@ -84,17 +92,22 @@ namespace grapher public MouseWatcher MouseWatcher { get; } + public ToolStripMenuItem ScaleMenuItem { get; } + #endregion properties #region methods - public void UpdateGraph() { AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); } + private void OnScaleMenuItemClick(object sender, EventArgs e) + { + UpdateGraph(); + } #endregion methods } diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index bba3c32..0346fb8 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -4,13 +4,17 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace grapher.Models.Calculations { - public static class AccelCalculator + public class AccelCalculator { - public const int MaxCombined = 100; - public const int MaxXY = 150; + public const int DefaultDPI = 1200; + public const int DefaultPollRate = 1000; + public const int Resolution = 100; + public const double MaxMultiplier = 85; + public const double XYToCombinedRatio = 1.3; public struct MagnitudeData { @@ -19,12 +23,33 @@ namespace grapher.Models.Calculations public int y; } - public static ReadOnlyCollection MagnitudesCombined = GetMagnitudes(); - public static ReadOnlyCollection MagnitudesX = GetMagnitudesX(); - public static ReadOnlyCollection MagnitudesY = GetMagnitudesY(); - public static void Calculate(AccelData data, ManagedAccel accel) + public AccelCalculator(Field dpi, Field pollRate) { + DPI = dpi; + PollRate = pollRate; + } + + public ReadOnlyCollection MagnitudesCombined { get; private set; } + + public ReadOnlyCollection MagnitudesX { get; private set; } + + public ReadOnlyCollection MagnitudesY { get; private set; } + + public Field DPI { get; private set; } + + public Field PollRate { get; private set; } + + private double CombinedMaxVelocity { get; set; } + + private double XYMaxVelocity { get; set; } + + private int Increment { get; set; } + + public void Calculate(AccelData data, ManagedAccel accel) + { + ScaleByMouseSettings(); + data.Clear(); Calculate(data.Combined, accel, accel.GetSensitivityX(), MagnitudesCombined); @@ -70,12 +95,12 @@ namespace grapher.Models.Calculations data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList()); } - public static ReadOnlyCollection GetMagnitudes() + public ReadOnlyCollection GetMagnitudes() { var magnitudes = new List(); - for (int i = 0; i < MaxCombined; i++) + for (int i = 0; i < CombinedMaxVelocity; i+=Increment) { - for (int j = 0; j <= i; j++) + for (int j = 0; j <= i; j+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = Magnitude(i, j); @@ -90,11 +115,11 @@ namespace grapher.Models.Calculations return magnitudes.AsReadOnly(); } - public static ReadOnlyCollection GetMagnitudesX() + public ReadOnlyCollection GetMagnitudesX() { var magnitudes = new List(); - for (int i = 0; i < MaxXY; i++) + for (int i = 0; i < XYMaxVelocity; i+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = i; @@ -106,11 +131,11 @@ namespace grapher.Models.Calculations return magnitudes.AsReadOnly(); } - public static ReadOnlyCollection GetMagnitudesY() + public ReadOnlyCollection GetMagnitudesY() { var magnitudes = new List(); - for (int i = 0; i < MaxXY; i++) + for (int i = 0; i < XYMaxVelocity; i+=Increment) { MagnitudeData magnitudeData; magnitudeData.magnitude = i; @@ -141,5 +166,16 @@ namespace grapher.Models.Calculations { return Magnitude(x, y) / time; } + + public void ScaleByMouseSettings() + { + var dpiPollFactor = DPI.Data / PollRate.Data; + CombinedMaxVelocity = dpiPollFactor * MaxMultiplier; + Increment = (int) Math.Floor(CombinedMaxVelocity / Resolution); + XYMaxVelocity = CombinedMaxVelocity * 1.5; + MagnitudesCombined = GetMagnitudes(); + MagnitudesX = GetMagnitudesX(); + MagnitudesY = GetMagnitudesY(); + } } } diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index b233552..03d6ff6 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -22,6 +22,7 @@ namespace grapher new LogLayout(), new SigmoidLayout(), new PowerLayout(), + new NaturalGainLayout(), new OffLayout() }.ToDictionary(k => k.Name); -- cgit v1.2.3 From 3dd0bb9163380de64d0df4f0b5c16dd86979714e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 00:32:11 -0700 Subject: Sigmoid gain --- grapher/Models/Options/AccelOptions.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'grapher/Models') diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 03d6ff6..8da873f 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -23,6 +23,7 @@ namespace grapher new SigmoidLayout(), new PowerLayout(), new NaturalGainLayout(), + new SigmoidGainLayout(), new OffLayout() }.ToDictionary(k => k.Name); -- cgit v1.2.3 From fe17d04e571d180e663c7014e803ce790693f4b1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 12:51:33 -0700 Subject: Display active values --- grapher/Models/AccelGUI.cs | 13 ++++++ grapher/Models/Calculations/AccelCalculator.cs | 6 +-- grapher/Models/Options/ActiveValueLabel.cs | 46 ++++++++++++++++++ grapher/Models/Options/ActiveValueLabelXY.cs | 64 ++++++++++++++++++++++++++ grapher/Models/Options/CapOptions.cs | 20 ++++++-- grapher/Models/Options/Option.cs | 50 +++++++++++++++++--- grapher/Models/Options/OptionXY.cs | 22 +++++++-- 7 files changed, 203 insertions(+), 18 deletions(-) create mode 100644 grapher/Models/Options/ActiveValueLabel.cs create mode 100644 grapher/Models/Options/ActiveValueLabelXY.cs (limited to 'grapher/Models') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 2c27bf7..afc3def 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -102,6 +102,19 @@ namespace grapher { AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); + UpdateActiveValueLabels(); + } + + public void UpdateActiveValueLabels() + { + Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); + Rotation.SetActiveValue(ManagedAcceleration.Rotation); + Offset.SetActiveValue(ManagedAcceleration.Offset); + Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); + Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); + Weight.SetActiveValues(ManagedAcceleration.WeightX, ManagedAcceleration.WeightY); + LimitOrExponent.SetActiveValue(ManagedAcceleration.LimitExp); + Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); } private void OnScaleMenuItemClick(object sender, EventArgs e) diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 0346fb8..63ed281 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -52,9 +52,9 @@ namespace grapher.Models.Calculations data.Clear(); - Calculate(data.Combined, accel, accel.GetSensitivityX(), MagnitudesCombined); - Calculate(data.X, accel, accel.GetSensitivityX(), MagnitudesX); - Calculate(data.Y, accel, accel.GetSensitivityY(), MagnitudesY); + Calculate(data.Combined, accel, accel.SensitivityX, MagnitudesCombined); + Calculate(data.X, accel, accel.SensitivityX, MagnitudesX); + Calculate(data.Y, accel, accel.SensitivityY, MagnitudesY); } public static void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection magnitudeData) diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs new file mode 100644 index 0000000..ecafaba --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Options +{ + public class ActiveValueLabel + { + public const string DefaultFormatString = "0.######"; + + public ActiveValueLabel(Label valueLabel, Label centeringLabel) + { + ValueLabel = valueLabel; + ValueLabel.ForeColor = Color.DarkGray; + ValueLabel.Left = centeringLabel.Left; + ValueLabel.Width = centeringLabel.Width; + ValueLabel.AutoSize = false; + ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + } + + public Label ValueLabel { get; } + + private int Left { get; } + + private int Width { get; } + + public void Hide() + { + ValueLabel.Hide(); + } + + public void Show() + { + ValueLabel.Show(); + } + + public void SetValue(double value) + { + ValueLabel.Text = value.ToString(DefaultFormatString); + } + } +} diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs new file mode 100644 index 0000000..b3b580f --- /dev/null +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Options +{ + public class ActiveValueLabelXY + { + public const int ActiveLabelXYSeparation = 4; + + public ActiveValueLabelXY( + ActiveValueLabel x, + ActiveValueLabel y) + { + X = x; + Y = y; + Combined = false; + SetCombined(); + } + + public ActiveValueLabel X { get; } + + public ActiveValueLabel Y { get; } + + public bool Combined { get; private set; } + + public void SetValues(double x, double y) + { + X.SetValue(x); + Y.SetValue(y); + + if (x == y) + { + SetCombined(); + } + else + { + SetSeparate(); + } + } + + public void SetCombined() + { + if (!Combined) + { + Y.Hide(); + } + + Combined = true; + } + + public void SetSeparate() + { + if (Combined) + { + Y.Show(); + } + + Combined = false; + } + } +} diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 2ee7f6b..fedda08 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -30,13 +30,13 @@ namespace grapher EnableSensitivityCap(); } - ToolStripMenuItem SensitivityCapCheck { get; } + public ToolStripMenuItem SensitivityCapCheck { get; } - ToolStripMenuItem VelocityGainCapCheck { get; } + public ToolStripMenuItem VelocityGainCapCheck { get; } - OptionXY CapOption { get; } + public OptionXY CapOption { get; } - OptionXY WeightOption { get; } + public OptionXY WeightOption { get; } public double SensitivityCapX { get @@ -82,6 +82,18 @@ namespace grapher public bool IsSensitivityGain { get; private set; } + public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled) + { + if (capGainEnabled) + { + CapOption.SetActiveValues(gainCap, gainCap); + } + else + { + CapOption.SetActiveValues(sensCapX, sensCapY); + } + } + void OnSensitivityCapCheckClick(object sender, EventArgs e) { if (!SensitivityCapCheck.Checked) diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index eb5105e..bacd760 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,19 +10,42 @@ namespace grapher { public class Option { - public Option(Field field, Label label) + public Option( + Field field, + Label label, + ActiveValueLabel activeValueLabel) { Field = field; Label = label; + ActiveValueLabel = activeValueLabel; } - public Option(TextBox box, Form containingForm, double defaultData, Label label) - : this(new Field(box, containingForm, defaultData), label) + public Option( + TextBox box, + Form containingForm, + double defaultData, + Label label, + ActiveValueLabel activeValueLabel) + : this( + new Field(box, containingForm, defaultData), + label, + activeValueLabel) { } - public Option(TextBox box, Form containingForm, double defaultData, Label label, string startingName) - : this(box, containingForm, defaultData, label) + public Option( + TextBox box, + Form containingForm, + double defaultData, + Label label, + ActiveValueLabel activeValueLabel, + string startingName) + : this( + box, + containingForm, + defaultData, + label, + activeValueLabel) { SetName(startingName); } @@ -30,22 +54,36 @@ namespace grapher public Label Label { get; } + public ActiveValueLabel ActiveValueLabel { get; } + public void SetName(string name) { Label.Text = name; Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0)); } + public void SetActiveValue(double value) + { + ActiveValueLabel.SetValue(value); + } + public void Hide() { Field.Box.Hide(); Label.Hide(); + ActiveValueLabel.Hide(); } public void Show() { Field.Box.Show(); Label.Show(); + ActiveValueLabel.Show(); + } + + public void UpdateActiveValue(double value) + { + ActiveValueLabel.SetValue(value); } public void Show(string name) diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index 90a46d7..b22bb78 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,10 +10,11 @@ namespace grapher { public class OptionXY { - public OptionXY(FieldXY fields, Label label) + public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels) { Fields = fields; Label = label; + ActiveValueLabels = activeValueLabels; } public OptionXY( @@ -22,8 +24,9 @@ namespace grapher Form containingForm, double defaultData, Label label, - AccelCharts accelCharts) - : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label) + AccelCharts accelCharts, + ActiveValueLabelXY activeValueLabels) + : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label, activeValueLabels) { } @@ -34,6 +37,7 @@ namespace grapher Form containingForm, double defaultData, Label label, + ActiveValueLabelXY activeValueLabels, string startingName, AccelCharts accelCharts): this( @@ -43,7 +47,8 @@ namespace grapher containingForm, defaultData, label, - accelCharts) + accelCharts, + activeValueLabels) { SetName(startingName); } @@ -52,12 +57,19 @@ namespace grapher public Label Label { get; } + public ActiveValueLabelXY ActiveValueLabels { get; } + public void SetName(string name) { Label.Text = name; Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0)); } + public void SetActiveValues(double x, double y) + { + ActiveValueLabels.SetValues(x, y); + } + public void Hide() { Fields.Hide(); -- cgit v1.2.3 From 7dbeae9d4cf108e78072b356d832123f12e42a90 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 14:22:14 -0700 Subject: Add accel type to active values and tweak color --- grapher/Models/AccelGUI.cs | 1 + grapher/Models/Options/AccelOptions.cs | 13 ++++- grapher/Models/Options/ActiveValueLabel.cs | 73 +++++++++++++++++++++++++--- grapher/Models/Options/ActiveValueLabelXY.cs | 22 ++++++++- grapher/Models/Options/CapOptions.cs | 10 +++- 5 files changed, 110 insertions(+), 9 deletions(-) (limited to 'grapher/Models') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index afc3def..e345743 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -109,6 +109,7 @@ namespace grapher { Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); Rotation.SetActiveValue(ManagedAcceleration.Rotation); + AccelerationOptions.SetActiveValue(ManagedAcceleration.Type); Offset.SetActiveValue(ManagedAcceleration.Offset); Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 8da873f..cd7c4e5 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -1,4 +1,5 @@ using grapher.Layouts; +using grapher.Models.Options; using System; using System.Collections.Generic; using System.Linq; @@ -31,7 +32,8 @@ namespace grapher ComboBox accelDropdown, Option[] options, OptionXY[] optionsXY, - Button writeButton) + Button writeButton, + ActiveValueLabel activeValueLabel) { AccelDropdown = accelDropdown; AccelDropdown.Items.Clear(); @@ -51,6 +53,7 @@ namespace grapher Options = options; OptionsXY = optionsXY; WriteButton = writeButton; + ActiveValueLabel = activeValueLabel; Layout("Default"); } @@ -61,10 +64,18 @@ namespace grapher public int AccelerationIndex { get; private set; } + public ActiveValueLabel ActiveValueLabel { get; } + public Option[] Options { get; } public OptionXY[] OptionsXY { get; } + public void SetActiveValue(int index) + { + var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; + ActiveValueLabel.SetValue(name); + } + private void OnIndexChanged(object sender, EventArgs e) { var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index ecafaba..138775a 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -11,22 +11,73 @@ namespace grapher.Models.Options public class ActiveValueLabel { public const string DefaultFormatString = "0.######"; + public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); + + private string _prefix; + private string _value; public ActiveValueLabel(Label valueLabel, Label centeringLabel) { ValueLabel = valueLabel; - ValueLabel.ForeColor = Color.DarkGray; - ValueLabel.Left = centeringLabel.Left; - ValueLabel.Width = centeringLabel.Width; + ValueLabel.ForeColor = ActiveValueFontColor; + Left = centeringLabel.Left; + Width = centeringLabel.Width; ValueLabel.AutoSize = false; ValueLabel.TextAlign = ContentAlignment.MiddleCenter; + + FormatString = DefaultFormatString; + Prefix = string.Empty; } public Label ValueLabel { get; } - private int Left { get; } + public string FormatString { get; set; } + + public string Prefix + { + get { return _prefix; } + set + { + _prefix = value; + RefreshText(); + } + } + + private string Value + { + get { return _value; } + set + { + _value = value; + RefreshText(); + } + } - private int Width { get; } + public int Left + { + get + { + return ValueLabel.Left; + } + + set + { + ValueLabel.Left = value; + } + } + + public int Width + { + get + { + return ValueLabel.Width; + } + + set + { + ValueLabel.Width = value; + } + } public void Hide() { @@ -40,7 +91,17 @@ namespace grapher.Models.Options public void SetValue(double value) { - ValueLabel.Text = value.ToString(DefaultFormatString); + SetValue(value.ToString(FormatString)); + } + + public void SetValue(string value) + { + Value = value; + } + + public void RefreshText() + { + ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}"; } } } diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index b3b580f..12506e9 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -8,7 +8,8 @@ namespace grapher.Models.Options { public class ActiveValueLabelXY { - public const int ActiveLabelXYSeparation = 4; + public const int ActiveLabelXYSeparation = 2; + public const string ShortenedFormatString = "0.###"; public ActiveValueLabelXY( ActiveValueLabel x, @@ -16,6 +17,14 @@ namespace grapher.Models.Options { X = x; Y = y; + + FullWidth = x.Width; + ShortenedWidth = (FullWidth - ActiveLabelXYSeparation) / 2; + + Y.Left = X.Left + ShortenedWidth + ActiveLabelXYSeparation; + Y.Width = ShortenedWidth; + Y.FormatString = ShortenedFormatString; + Combined = false; SetCombined(); } @@ -26,6 +35,10 @@ namespace grapher.Models.Options public bool Combined { get; private set; } + private int FullWidth { get; } + + private int ShortenedWidth { get; } + public void SetValues(double x, double y) { X.SetValue(x); @@ -45,6 +58,9 @@ namespace grapher.Models.Options { if (!Combined) { + X.FormatString = ActiveValueLabel.DefaultFormatString; + X.Width = FullWidth; + X.Prefix = string.Empty; Y.Hide(); } @@ -55,6 +71,10 @@ namespace grapher.Models.Options { if (Combined) { + X.FormatString = ShortenedFormatString; + X.Width = ShortenedWidth; + X.Prefix = "X"; + Y.Prefix = "Y"; Y.Show(); } diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index fedda08..493561a 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,6 +10,9 @@ namespace grapher { public class CapOptions { + + public const string GainCapFormatString = "0.##"; + public CapOptions( ToolStripMenuItem sensitivityCapCheck, ToolStripMenuItem velocityGainCapCheck, @@ -86,10 +90,14 @@ namespace grapher { if (capGainEnabled) { + CapOption.ActiveValueLabels.X.FormatString = GainCapFormatString; + CapOption.ActiveValueLabels.X.Prefix = "Gain"; CapOption.SetActiveValues(gainCap, gainCap); } else { + CapOption.ActiveValueLabels.X.FormatString = ActiveValueLabel.DefaultFormatString; + CapOption.ActiveValueLabels.X.Prefix = string.Empty; CapOption.SetActiveValues(sensCapX, sensCapY); } } -- cgit v1.2.3 From 55b739c50db217e6a61678c1eb1412e8884e3462 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 20 Aug 2020 15:46:04 -0700 Subject: Serialization mostly working --- grapher/Models/AccelGUI.cs | 27 ++++++++- grapher/Models/Serialized/GUISettings.cs | 51 +++++++++++++++++ grapher/Models/Serialized/RawAccelSettings.cs | 81 +++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 grapher/Models/Serialized/GUISettings.cs create mode 100644 grapher/Models/Serialized/RawAccelSettings.cs (limited to 'grapher/Models') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e345743..a0a76c8 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -1,5 +1,6 @@ using grapher.Models.Calculations; using grapher.Models.Mouse; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -32,7 +33,8 @@ namespace grapher Option midpoint, Button writeButton, Label mouseMoveLabel, - ToolStripMenuItem scaleMenuItem) + ToolStripMenuItem scaleMenuItem, + ToolStripMenuItem autoWriteMenuItem) { AccelForm = accelForm; AccelCalculator = accelCalculator; @@ -51,6 +53,7 @@ namespace grapher ScaleMenuItem = scaleMenuItem; ManagedAcceleration.ReadFromDriver(); + SavedSettings = StartupLoad(AccelCalculator.DPI, AccelCalculator.PollRate, autoWriteMenuItem); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); @@ -64,6 +67,8 @@ namespace grapher public RawAcceleration AccelForm { get; } + public RawAccelSettings SavedSettings { get; } + public AccelCalculator AccelCalculator { get; } public AccelCharts AccelCharts { get; } @@ -103,6 +108,7 @@ namespace grapher AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); AccelCharts.Bind(); UpdateActiveValueLabels(); + SavedSettings.Save(); } public void UpdateActiveValueLabels() @@ -118,6 +124,25 @@ namespace grapher Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); } + private RawAccelSettings StartupLoad(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) + { + if (RawAccelSettings.Exists()) + { + var settings = RawAccelSettings.Load(); + settings.GUISettings.BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + return settings; + } + else + { + return new RawAccelSettings( + ManagedAcceleration, + new GUISettings( + AccelCalculator.DPI, + AccelCalculator.PollRate, + autoWriteMenuItem)); + } + } + private void OnScaleMenuItemClick(object sender, EventArgs e) { UpdateGraph(); diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs new file mode 100644 index 0000000..8c182ae --- /dev/null +++ b/grapher/Models/Serialized/GUISettings.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + [Serializable] + public class GUISettings + { + public GUISettings( + Field dpiField, + Field pollRateField, + ToolStripMenuItem autoWriteMenuItem) + { + BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + } + + public bool AutoWriteToDriverOnStartup { get; set; } + + public int DPI { get; set; } + + public int PollRate { get; set; } + + [field: NonSerialized] + private Field DpiField { get; set; } + + [field: NonSerialized] + private Field PollRateField { get; set; } + + [field: NonSerialized] + private ToolStripMenuItem AutoWriteMenuItem { get; set; } + + public void UpdateSettings() + { + DPI = (int)DpiField.Data; + PollRate = (int)PollRateField.Data; + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked; + } + + public void BindToGUI(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) + { + DpiField = dpiField; + PollRateField = pollRateField; + AutoWriteMenuItem = autoWriteMenuItem; + } + } +} diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs new file mode 100644 index 0000000..d8896b6 --- /dev/null +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -0,0 +1,81 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + [Serializable] + public class RawAccelSettings + { + public const string DefaultSettingsFile = @".\settings.json"; + + public RawAccelSettings( + ManagedAccel managedAccel, + GUISettings guiSettings) + { + ManagedAccel = managedAccel; + GUISettings = guiSettings; + } + + public ManagedAccel ManagedAccel { get; set; } + + public GUISettings GUISettings { get; set; } + + public static RawAccelSettings Load() + { + return Load(DefaultSettingsFile); + } + + public static RawAccelSettings Load(string file) + { + if (!Exists(file)) + { + throw new Exception($"Settings file does not exist at {file}"); + } + + object deserializedObject; + try + { + deserializedObject = JsonConvert.DeserializeObject(File.ReadAllText(file)); + } + catch + { + throw new Exception($"Settings file at {file} does not contain valid JSON."); + } + + RawAccelSettings deserializedSettings = (RawAccelSettings)deserializedObject; + + if (deserializedSettings == null) + { + throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings."); + } + + return deserializedSettings; + } + + public static bool Exists() + { + return Exists(DefaultSettingsFile); + } + + public static bool Exists(string file) + { + return File.Exists(file); + } + + public void Save() + { + Save(DefaultSettingsFile); + } + + public void Save(string file) + { + File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented)); + } + } +} -- cgit v1.2.3 From b874058d82a60a39163e91a26f370ff308b8af32 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sat, 22 Aug 2020 02:46:45 -0700 Subject: Saving and loading fully works --- grapher/Models/AccelGUI.cs | 71 +++++++-------- grapher/Models/Serialized/GUISettings.cs | 40 +++------ grapher/Models/Serialized/ModifierArgs.cs | 75 ++++++++++++++++ grapher/Models/Serialized/RawAccelSettings.cs | 31 ++++--- grapher/Models/Serialized/SettingsManager.cs | 123 ++++++++++++++++++++++++++ 5 files changed, 259 insertions(+), 81 deletions(-) create mode 100644 grapher/Models/Serialized/ModifierArgs.cs create mode 100644 grapher/Models/Serialized/SettingsManager.cs (limited to 'grapher/Models') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index a0a76c8..e0dcc03 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -21,7 +21,7 @@ namespace grapher RawAcceleration accelForm, AccelCalculator accelCalculator, AccelCharts accelCharts, - ManagedAccel managedAccel, + SettingsManager settings, AccelOptions accelOptions, OptionXY sensitivity, Option rotation, @@ -39,7 +39,6 @@ namespace grapher AccelForm = accelForm; AccelCalculator = accelCalculator; AccelCharts = accelCharts; - ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; Sensitivity = sensitivity; Rotation = rotation; @@ -51,9 +50,8 @@ namespace grapher Midpoint = midpoint; WriteButton = writeButton; ScaleMenuItem = scaleMenuItem; - - ManagedAcceleration.ReadFromDriver(); - SavedSettings = StartupLoad(AccelCalculator.DPI, AccelCalculator.PollRate, autoWriteMenuItem); + Settings = settings; + Settings.Startup(); UpdateGraph(); MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts); @@ -67,13 +65,11 @@ namespace grapher public RawAcceleration AccelForm { get; } - public RawAccelSettings SavedSettings { get; } - public AccelCalculator AccelCalculator { get; } public AccelCharts AccelCharts { get; } - public ManagedAccel ManagedAcceleration { get; } + public SettingsManager Settings { get; } public AccelOptions AccelerationOptions { get; } @@ -103,44 +99,43 @@ namespace grapher #region methods + public void UpdateActiveSettingsFromFields() + { + Settings.UpdateActiveSettings( + AccelerationOptions.AccelerationIndex, + Rotation.Field.Data, + Sensitivity.Fields.X, + Sensitivity.Fields.Y, + Weight.Fields.X, + Weight.Fields.Y, + Cap.SensitivityCapX, + Cap.SensitivityCapY, + Offset.Field.Data, + Acceleration.Field.Data, + LimitOrExponent.Field.Data, + Midpoint.Field.Data, + Cap.VelocityGainCap); + UpdateGraph(); + } + public void UpdateGraph() { - AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration); + AccelCalculator.Calculate(AccelCharts.AccelData, Settings.ActiveAccel); AccelCharts.Bind(); UpdateActiveValueLabels(); - SavedSettings.Save(); } public void UpdateActiveValueLabels() { - Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY); - Rotation.SetActiveValue(ManagedAcceleration.Rotation); - AccelerationOptions.SetActiveValue(ManagedAcceleration.Type); - Offset.SetActiveValue(ManagedAcceleration.Offset); - Acceleration.SetActiveValue(ManagedAcceleration.Acceleration); - Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled); - Weight.SetActiveValues(ManagedAcceleration.WeightX, ManagedAcceleration.WeightY); - LimitOrExponent.SetActiveValue(ManagedAcceleration.LimitExp); - Midpoint.SetActiveValue(ManagedAcceleration.Midpoint); - } - - private RawAccelSettings StartupLoad(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) - { - if (RawAccelSettings.Exists()) - { - var settings = RawAccelSettings.Load(); - settings.GUISettings.BindToGUI(dpiField, pollRateField, autoWriteMenuItem); - return settings; - } - else - { - return new RawAccelSettings( - ManagedAcceleration, - new GUISettings( - AccelCalculator.DPI, - AccelCalculator.PollRate, - autoWriteMenuItem)); - } + Sensitivity.SetActiveValues(Settings.ActiveAccel.SensitivityX, Settings.ActiveAccel.SensitivityY); + Rotation.SetActiveValue(Settings.ActiveAccel.Rotation); + AccelerationOptions.SetActiveValue(Settings.ActiveAccel.Type); + Offset.SetActiveValue(Settings.ActiveAccel.Offset); + Acceleration.SetActiveValue(Settings.ActiveAccel.Acceleration); + Cap.SetActiveValues(Settings.ActiveAccel.GainCap, Settings.ActiveAccel.CapX, Settings.ActiveAccel.CapY, Settings.ActiveAccel.GainCapEnabled); + Weight.SetActiveValues(Settings.ActiveAccel.WeightX, Settings.ActiveAccel.WeightY); + LimitOrExponent.SetActiveValue(Settings.ActiveAccel.LimitExp); + Midpoint.SetActiveValue(Settings.ActiveAccel.Midpoint); } private void OnScaleMenuItemClick(object sender, EventArgs e) diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs index 8c182ae..7c8e9a4 100644 --- a/grapher/Models/Serialized/GUISettings.cs +++ b/grapher/Models/Serialized/GUISettings.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -11,41 +12,22 @@ namespace grapher.Models.Serialized [Serializable] public class GUISettings { - public GUISettings( - Field dpiField, - Field pollRateField, - ToolStripMenuItem autoWriteMenuItem) + public GUISettings() {} + + public GUISettings(bool autoWrite, int dpi, int pollRate) { - BindToGUI(dpiField, pollRateField, autoWriteMenuItem); + AutoWriteToDriverOnStartup = autoWrite; + DPI = dpi; + PollRate = pollRate; } + [JsonProperty(Order = 1)] public bool AutoWriteToDriverOnStartup { get; set; } + [JsonProperty(Order = 2)] public int DPI { get; set; } + [JsonProperty(Order = 3)] public int PollRate { get; set; } - - [field: NonSerialized] - private Field DpiField { get; set; } - - [field: NonSerialized] - private Field PollRateField { get; set; } - - [field: NonSerialized] - private ToolStripMenuItem AutoWriteMenuItem { get; set; } - - public void UpdateSettings() - { - DPI = (int)DpiField.Data; - PollRate = (int)PollRateField.Data; - AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked; - } - - public void BindToGUI(Field dpiField, Field pollRateField, ToolStripMenuItem autoWriteMenuItem) - { - DpiField = dpiField; - PollRateField = pollRateField; - AutoWriteMenuItem = autoWriteMenuItem; - } } } diff --git a/grapher/Models/Serialized/ModifierArgs.cs b/grapher/Models/Serialized/ModifierArgs.cs new file mode 100644 index 0000000..206a3c9 --- /dev/null +++ b/grapher/Models/Serialized/ModifierArgs.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Serialized +{ + public enum accel_mode + { + linear=1, classic, natural, logarithmic, sigmoid, power, naturalgain, sigmoidgain, noaccel + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct vec2d + { + public double x; + public double y; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct accel_args + { + public double offset; + public double accel; + public double limit; + public double exponent; + public double midpoint; + public double power_scale; + public double gain_cap; + public vec2d weight; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct accel_fn_args + { + public accel_args acc_args; + public int accel_mode; + public double time_min; + public vec2d cap; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [Serializable] + public struct modifier_args + { + public double degrees; + public vec2d sens; + public accel_fn_args acc_fn_args; + + public modifier_args(ManagedAccel managedAccel) + { + degrees = managedAccel.Rotation; + sens.x = managedAccel.SensitivityX; + sens.y = managedAccel.SensitivityY; + acc_fn_args.accel_mode = managedAccel.Type; + acc_fn_args.time_min = managedAccel.MinimumTime; + acc_fn_args.cap.x = managedAccel.CapX; + acc_fn_args.cap.y = managedAccel.CapY; + acc_fn_args.acc_args.accel = managedAccel.Acceleration; + acc_fn_args.acc_args.exponent = managedAccel.LimitExp; + acc_fn_args.acc_args.gain_cap = managedAccel.GainCap; + acc_fn_args.acc_args.limit = managedAccel.LimitExp; + acc_fn_args.acc_args.midpoint = managedAccel.Midpoint; + acc_fn_args.acc_args.offset = managedAccel.Offset; + acc_fn_args.acc_args.power_scale = managedAccel.PowerScale; + acc_fn_args.acc_args.weight.x = managedAccel.WeightX; + acc_fn_args.acc_args.weight.y = managedAccel.WeightY; + } + } +} diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index d8896b6..21a7f0c 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,20 +13,29 @@ namespace grapher.Models.Serialized [Serializable] public class RawAccelSettings { - public const string DefaultSettingsFile = @".\settings.json"; + public const string DefaultSettingsFileName = @"settings.json"; + public static readonly string ExecutingDirectory = AppDomain.CurrentDomain.BaseDirectory; + public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, DefaultSettingsFileName); + public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings + { + MissingMemberHandling = MissingMemberHandling.Error, + }; + + public RawAccelSettings() { } public RawAccelSettings( ManagedAccel managedAccel, GUISettings guiSettings) { - ManagedAccel = managedAccel; + AccelerationSettings = new modifier_args(managedAccel); GUISettings = guiSettings; } - public ManagedAccel ManagedAccel { get; set; } public GUISettings GUISettings { get; set; } + public modifier_args AccelerationSettings { get; set; } + public static RawAccelSettings Load() { return Load(DefaultSettingsFile); @@ -38,21 +48,14 @@ namespace grapher.Models.Serialized throw new Exception($"Settings file does not exist at {file}"); } - object deserializedObject; + RawAccelSettings deserializedSettings; try { - deserializedObject = JsonConvert.DeserializeObject(File.ReadAllText(file)); + deserializedSettings = JsonConvert.DeserializeObject(File.ReadAllText(file), SerializerSettings); } - catch - { - throw new Exception($"Settings file at {file} does not contain valid JSON."); - } - - RawAccelSettings deserializedSettings = (RawAccelSettings)deserializedObject; - - if (deserializedSettings == null) + catch(Exception e) { - throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings."); + throw new Exception($"Settings file at {file} does not contain valid Raw Accel Settings.", e); } return deserializedSettings; diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs new file mode 100644 index 0000000..848606d --- /dev/null +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Serialized +{ + public class SettingsManager + { + public SettingsManager( + ManagedAccel activeAccel, + Field dpiField, + Field pollRateField, + ToolStripMenuItem autoWrite) + { + ActiveAccel = activeAccel; + DpiField = dpiField; + PollRateField = pollRateField; + AutoWriteMenuItem = autoWrite; + } + + public ManagedAccel ActiveAccel { get; } + + public RawAccelSettings RawAccelSettings { get; private set; } + + private Field DpiField { get; set; } + + private Field PollRateField { get; set; } + + private ToolStripMenuItem AutoWriteMenuItem { get; set; } + + public void UpdateActiveSettings( + int mode, + double degrees, + double sensitivityX, + double sensitivityY, + double weightX, + double weightY, + double capX, + double capY, + double offset, + double accel, + double limitOrExp, + double midpoint, + double gainCap) + { + ActiveAccel.UpdateAccel( + mode, + degrees, + sensitivityX, + sensitivityY, + weightX, + weightY, + capX, + capY, + offset, + accel, + limitOrExp, + midpoint, + gainCap); + + RawAccelSettings.AccelerationSettings = new modifier_args(ActiveAccel); + RawAccelSettings.GUISettings = new GUISettings + { + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + DPI = (int)DpiField.Data, + PollRate = (int)PollRateField.Data + }; + + RawAccelSettings.Save(); + } + + public void UpdateActiveAccelFromFileSettings() + { + ActiveAccel.UpdateAccel( + RawAccelSettings.AccelerationSettings.acc_fn_args.accel_mode, + RawAccelSettings.AccelerationSettings.degrees, + RawAccelSettings.AccelerationSettings.sens.x, + RawAccelSettings.AccelerationSettings.sens.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.weight.x, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.weight.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.cap.x, + RawAccelSettings.AccelerationSettings.acc_fn_args.cap.y, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.offset, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.accel, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.exponent, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.midpoint, + RawAccelSettings.AccelerationSettings.acc_fn_args.acc_args.gain_cap); + DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI); + PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate); + AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup; + } + + public void Startup() + { + ActiveAccel.ReadFromDriver(); + + if(RawAccelSettings.Exists()) + { + RawAccelSettings = RawAccelSettings.Load(); + if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup) + { + UpdateActiveAccelFromFileSettings(); + } + } + else + { + RawAccelSettings = new RawAccelSettings( + ActiveAccel, + new GUISettings + { + AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, + DPI = (int)DpiField.Data, + PollRate = (int)PollRateField.Data + }); + RawAccelSettings.Save(); + } + } + } +} -- cgit v1.2.3