diff options
23 files changed, 318 insertions, 30 deletions
diff --git a/grapher/Constants/AccelGUIConstants.cs b/grapher/Constants/AccelGUIConstants.cs new file mode 100644 index 0000000..20ec6d0 --- /dev/null +++ b/grapher/Constants/AccelGUIConstants.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Constants +{ + public static class AccelGUIConstants + { + #region Constants + + /// <summary> Vertical separation between charts, in pixels. </summary> + public const int ChartSeparationVertical = 10; + + /// <summary> Needed to show full contents in form. Unsure why. </summary> + public const int FormHeightPadding = 35; + + /// <summary> DPI by which charts are scaled if none is set by user. </summary> + public const int DefaultDPI = 1200; + + /// <summary> Poll rate by which charts are scaled if none is set by user. </summary> + public const int DefaultPollRate = 1000; + + /// <summary> Resolution of chart calulation. </summary> + public const int Resolution = 100; + + /// <summary> Multiplied by DPI over poll rate to find rough max expected velocity. </summary> + public const double MaxMultiplier = 85; + + /// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary> + public const double XYToCombinedRatio = 1.4; + + #endregion Constants + } +} diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index a26f13d..8fe752c 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -17,7 +17,7 @@ namespace grapher public class AccelGUI { - #region constructors + #region Constructors public AccelGUI( RawAcceleration accelForm, @@ -63,9 +63,9 @@ namespace grapher ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick); } - #endregion constructors + #endregion Constructors - #region properties + #region Properties public RawAcceleration AccelForm { get; } @@ -101,9 +101,9 @@ namespace grapher public ToolStripMenuItem ScaleMenuItem { get; } - #endregion properties + #endregion Properties - #region methods + #region Methods public void UpdateActiveSettingsFromFields() { @@ -174,7 +174,8 @@ namespace grapher { UpdateGraph(); } - #endregion methods + + #endregion Methods } } diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 102de8d..0f0a60a 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -1,4 +1,5 @@ -using grapher.Models.Serialized; +using grapher.Constants; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -11,11 +12,7 @@ namespace grapher.Models.Calculations { public class AccelCalculator { - 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; + #region Structs public struct MagnitudeData { @@ -24,6 +21,9 @@ namespace grapher.Models.Calculations public int y; } + #endregion Structs + + #region Constructors public AccelCalculator(Field dpi, Field pollRate) { @@ -31,6 +31,10 @@ namespace grapher.Models.Calculations PollRate = pollRate; } + #endregion Constructors + + #region Properties + public ReadOnlyCollection<MagnitudeData> MagnitudesCombined { get; private set; } public ReadOnlyCollection<MagnitudeData> MagnitudesX { get; private set; } @@ -47,6 +51,10 @@ namespace grapher.Models.Calculations private int Increment { get; set; } + #endregion Fields + + #region Methods + public void Calculate(AccelData data, ManagedAccel accel, DriverSettings settings) { ScaleByMouseSettings(); @@ -171,12 +179,14 @@ namespace grapher.Models.Calculations public void ScaleByMouseSettings() { var dpiPollFactor = DPI.Data / PollRate.Data; - CombinedMaxVelocity = dpiPollFactor * MaxMultiplier; - Increment = (int) Math.Floor(CombinedMaxVelocity / Resolution); - XYMaxVelocity = CombinedMaxVelocity * 1.5; + CombinedMaxVelocity = dpiPollFactor * AccelGUIConstants.MaxMultiplier; + Increment = (int) Math.Floor(CombinedMaxVelocity / AccelGUIConstants.Resolution); + XYMaxVelocity = CombinedMaxVelocity * AccelGUIConstants.XYToCombinedRatio; MagnitudesCombined = GetMagnitudes(); MagnitudesX = GetMagnitudesX(); MagnitudesY = GetMagnitudesY(); } + + #endregion Methods } } diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 20142a7..6b29f16 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -8,6 +8,8 @@ namespace grapher.Models.Calculations { public class AccelChartData { + #region Constructors + public AccelChartData() { AccelPoints = new SortedDictionary<double, double>(); @@ -17,6 +19,10 @@ namespace grapher.Models.Calculations OutVelocityToPoints = new Dictionary<double, (double, double, double)>(); } + #endregion Constructors + + #region Properties + public SortedDictionary<double, double> AccelPoints { get; } public SortedDictionary<double, double> VelocityPoints { get; } @@ -27,6 +33,10 @@ namespace grapher.Models.Calculations public Dictionary<double, (double, double, double)> OutVelocityToPoints { get; } + #endregion Properties + + #region Methods + public void Clear() { AccelPoints.Clear(); @@ -57,5 +67,7 @@ namespace grapher.Models.Calculations return values; } } + + #endregion Methods } } diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 683c67e..3e1f987 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -10,6 +10,7 @@ namespace grapher.Models.Calculations { public class AccelData { + #region Constructors public AccelData( EstimatedPoints combined, @@ -25,6 +26,10 @@ namespace grapher.Models.Calculations EstimatedY = y; } + #endregion Constructors + + #region Properties + public AccelChartData Combined { get; } public AccelChartData X { get; } @@ -37,6 +42,10 @@ namespace grapher.Models.Calculations private EstimatedPoints EstimatedY { get; } + #endregion Properties + + #region Methods + public void Clear() { Combined.Clear(); @@ -70,5 +79,6 @@ namespace grapher.Models.Calculations EstimatedY.Gain.Set(inYVelocity, yGain); } + #endregion Methods } } diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 0136ced..1574ce2 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,4 +1,5 @@ -using grapher.Models.Calculations; +using grapher.Constants; +using grapher.Models.Calculations; using grapher.Models.Charts; using System; using System.Collections.Generic; @@ -14,10 +15,7 @@ namespace grapher { public class AccelCharts { - public const int ChartSeparationVertical = 10; - - /// <summary> Needed to show full contents in form. Unsure why. </summary> - public const int FormHeightPadding = 35; + #region Constructors public AccelCharts( Form form, @@ -43,9 +41,9 @@ namespace grapher SensitivityChart.SetTop(0); VelocityChart.SetHeight(SensitivityChart.Height); - VelocityChart.SetTop(SensitivityChart.Height + ChartSeparationVertical); + VelocityChart.SetTop(SensitivityChart.Height + AccelGUIConstants.ChartSeparationVertical); GainChart.SetHeight(SensitivityChart.Height); - GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + ChartSeparationVertical); + GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + AccelGUIConstants.ChartSeparationVertical); Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); FormBorderHeight = screenRectangle.Top - ContaingForm.Top; @@ -58,6 +56,10 @@ namespace grapher ShowCombined(); } + #endregion Constructors + + #region Properties + public Form ContaingForm { get; } public ChartXY SensitivityChart { get; } @@ -80,6 +82,10 @@ namespace grapher private int FormBorderHeight { get; } + #endregion Properties + + #region Methods + public void MakeDots(int x, int y, double timeInMs) { if (Combined) @@ -149,9 +155,9 @@ namespace grapher VelocityChart.Show(); GainChart.Show(); ContaingForm.Height = SensitivityChart.Height + - ChartSeparationVertical + + AccelGUIConstants.ChartSeparationVertical + VelocityChart.Height + - ChartSeparationVertical + + AccelGUIConstants.ChartSeparationVertical + GainChart.Height + FormBorderHeight; } @@ -195,5 +201,7 @@ namespace grapher { ContaingForm.Width = SensitivityChart.Left + SensitivityChart.Width; } + + #endregion Methods } } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 81874a2..e5a948a 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -15,11 +15,11 @@ namespace grapher { public class ChartXY { - #region Consts + #region Constants public const int ChartSeparationHorizontal = 10; - #endregion Consts + #endregion Constants #region Constructors diff --git a/grapher/Models/Charts/EstimatedPoints.cs b/grapher/Models/Charts/EstimatedPoints.cs index fa0718b..9ff0e5b 100644 --- a/grapher/Models/Charts/EstimatedPoints.cs +++ b/grapher/Models/Charts/EstimatedPoints.cs @@ -9,6 +9,8 @@ namespace grapher.Models.Charts { public class EstimatedPoints { + #region Constructors + public EstimatedPoints() { Sensitivity = new PointData(); @@ -16,10 +18,16 @@ namespace grapher.Models.Charts Gain = new PointData(); } + #endregion Constructors + + #region Properties + public PointData Sensitivity { get; } public PointData Velocity { get; } public PointData Gain { get; } + + #endregion Properties } } diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 1810081..03693ed 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -16,7 +16,7 @@ namespace grapher #endregion Constants - #region Enums + #region Enumerations public enum FieldState { @@ -27,8 +27,7 @@ namespace grapher Unavailable, } - #endregion Enums - + #endregion Enumerations #region Constructors diff --git a/grapher/Models/Fields/FieldXY.cs b/grapher/Models/Fields/FieldXY.cs index 87e0b9c..83f6434 100644 --- a/grapher/Models/Fields/FieldXY.cs +++ b/grapher/Models/Fields/FieldXY.cs @@ -9,10 +9,16 @@ namespace grapher { public class FieldXY { + #region Constants + public const int DefaultSeparation = 4; public const string ShortenedFormatString = "0.###"; + #endregion Constants + + #region Constructors + public FieldXY(TextBox xBox, TextBox yBox, CheckBox lockCheckBox, Form containingForm, double defaultData) { XField = new Field(xBox, containingForm, defaultData); @@ -32,6 +38,11 @@ namespace grapher CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); SetCombined(); } + + #endregion Constructors + + #region Properties + public double X { get => XField.Data; @@ -66,6 +77,10 @@ namespace grapher private int CombinedWidth { get; } + #endregion Properties + + #region Methods + private void CheckChanged(object sender, EventArgs e) { if (LockCheckBox.CheckState == CheckState.Checked) @@ -126,5 +141,7 @@ namespace grapher XField.Box.Hide(); YField.Box.Hide(); } + + #endregion Methods } } diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index fea4e2d..6f6b776 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -11,6 +11,7 @@ namespace grapher.Models.Mouse { public class MouseWatcher { + #region External /// <summary> /// Enumeration containing HID usage page flags. /// </summary> @@ -677,6 +678,10 @@ namespace grapher.Models.Mouse [DllImport("user32.dll")] public static extern int GetRawInputData(IntPtr hRawInput, RawInputCommand uiCommand, out RawInput pData, ref int pcbSize, int cbSizeHeader); + #endregion External + + #region Constructors + public MouseWatcher(Form containingForm, Label display, AccelCharts accelCharts) { ContainingForm = containingForm; @@ -695,6 +700,10 @@ namespace grapher.Models.Mouse PollTime = 1; } + #endregion Constructors + + #region Properties + private Form ContainingForm { get; } private Label Display { get; } @@ -703,6 +712,10 @@ namespace grapher.Models.Mouse private double PollTime { get; } + #endregion Properties + + #region Methods + public void OnMouseMove(int x, int y, double timeInMs) { Display.Text = $"Last (x, y): ({x}, {y})"; @@ -723,5 +736,7 @@ namespace grapher.Models.Mouse } } + + #endregion Methods } } diff --git a/grapher/Models/Mouse/PointData.cs b/grapher/Models/Mouse/PointData.cs index 12a6e73..3641c23 100644 --- a/grapher/Models/Mouse/PointData.cs +++ b/grapher/Models/Mouse/PointData.cs @@ -8,6 +8,8 @@ namespace grapher.Models.Mouse { public class PointData { + #region Constructors + public PointData() { Lock = new Object(); @@ -15,6 +17,10 @@ namespace grapher.Models.Mouse Y = new double[] { 0 }; } + #endregion Constructors + + #region Properties + public Object Lock { get; } private double[] X { get; set; } @@ -29,6 +35,10 @@ namespace grapher.Models.Mouse } } + #endregion Properties + + #region Methods + public void Get(out double[] x, out double[] y) { lock(Lock) @@ -37,5 +47,7 @@ namespace grapher.Models.Mouse y = Y; } } + + #endregion Methods } } diff --git a/grapher/Models/Options/AccelOptions.cs b/grapher/Models/Options/AccelOptions.cs index 6b98274..224c5cb 100644 --- a/grapher/Models/Options/AccelOptions.cs +++ b/grapher/Models/Options/AccelOptions.cs @@ -11,9 +11,15 @@ namespace grapher { public class AccelOptions { + #region Constants + public const int PossibleOptionsCount = 4; public const int PossibleOptionsXYCount = 2; + #endregion Constants + + #region Fields + public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase> { new LinearLayout(), @@ -27,6 +33,10 @@ namespace grapher new OffLayout() }.ToDictionary(k => k.Name); + #endregion Fields + + #region Constructors + public AccelOptions( ComboBox accelDropdown, Option[] options, @@ -57,6 +67,10 @@ namespace grapher Layout("Off"); } + #endregion Constructors + + #region Properties + public Button WriteButton { get; } public ComboBox AccelDropdown { get; } @@ -69,6 +83,10 @@ namespace grapher public OptionXY[] OptionsXY { get; } + #endregion Properties + + #region Methods + public void SetActiveValue(int index) { var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; @@ -87,5 +105,7 @@ namespace grapher AccelerationIndex = accelerationType.Index; accelerationType.Layout(Options, OptionsXY, WriteButton); } + + #endregion Methods } } diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index 138775a..b2355b5 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -10,12 +10,22 @@ namespace grapher.Models.Options { public class ActiveValueLabel { + #region Constants + public const string DefaultFormatString = "0.######"; public static readonly Color ActiveValueFontColor = Color.FromArgb(255, 65, 65, 65); + #endregion Constants + + #region Fields + private string _prefix; private string _value; + #endregion Fields + + #region Constructors + public ActiveValueLabel(Label valueLabel, Label centeringLabel) { ValueLabel = valueLabel; @@ -29,6 +39,10 @@ namespace grapher.Models.Options Prefix = string.Empty; } + #endregion Constructors + + #region Properties + public Label ValueLabel { get; } public string FormatString { get; set; } @@ -79,6 +93,10 @@ namespace grapher.Models.Options } } + #endregion Properties + + #region Methods + public void Hide() { ValueLabel.Hide(); @@ -103,5 +121,7 @@ namespace grapher.Models.Options { ValueLabel.Text = string.IsNullOrWhiteSpace(Prefix) ? Value: $"{Prefix}: {Value}"; } + + #endregion Methods } } diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index 12506e9..553ce48 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -8,9 +8,15 @@ namespace grapher.Models.Options { public class ActiveValueLabelXY { + #region Constants + public const int ActiveLabelXYSeparation = 2; public const string ShortenedFormatString = "0.###"; + #endregion Constants + + #region Constructors + public ActiveValueLabelXY( ActiveValueLabel x, ActiveValueLabel y) @@ -29,6 +35,10 @@ namespace grapher.Models.Options SetCombined(); } + #endregion Constructors + + #region Properties + public ActiveValueLabel X { get; } public ActiveValueLabel Y { get; } @@ -39,6 +49,10 @@ namespace grapher.Models.Options private int ShortenedWidth { get; } + #endregion Properties + + #region Methods + public void SetValues(double x, double y) { X.SetValue(x); @@ -80,5 +94,7 @@ namespace grapher.Models.Options Combined = false; } + + #region Methods } } diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 0c9fd6a..a269b49 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -10,6 +10,8 @@ namespace grapher.Models.Options { public class ApplyOptions { + #region Constructors + public ApplyOptions( ToolStripMenuItem wholeVectorMenuItem, ToolStripMenuItem byComponentMenuItem) @@ -26,12 +28,19 @@ namespace grapher.Models.Options IsWhole = false; } + #endregion Constructors + + #region Properties public ToolStripMenuItem WholeVectorMenuItem { get; } public ToolStripMenuItem ByComponentVectorMenuItem { get; } public bool IsWhole { get; private set; } + #endregion Properties + + #region Methods + public void SetActive(bool isWhole) { WholeVectorMenuItem.Checked = isWhole; @@ -81,5 +90,6 @@ namespace grapher.Models.Options IsWhole = false; } + #endregion Methods } } diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index 3bdf3c6..9d903ec 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -10,9 +10,14 @@ namespace grapher { public class CapOptions { + #region Constants public const string GainCapFormatString = "0.##"; + #endregion Constants + + #region Constructors + public CapOptions( ToolStripMenuItem sensitivityCapCheck, ToolStripMenuItem velocityGainCapCheck, @@ -34,6 +39,10 @@ namespace grapher EnableSensitivityCap(); } + #endregion Constructors + + #region Properties + public ToolStripMenuItem SensitivityCapCheck { get; } public ToolStripMenuItem VelocityGainCapCheck { get; } @@ -42,6 +51,8 @@ namespace grapher public OptionXY WeightOption { get; } + public bool IsSensitivityGain { get; private set; } + public double SensitivityCapX { get { @@ -84,7 +95,9 @@ namespace grapher } } - public bool IsSensitivityGain { get; private set; } + #endregion Properties + + #region Methods public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled) { @@ -157,5 +170,7 @@ namespace grapher WeightOption.Fields.LockCheckBox.Enabled = false; CapOption.SetName("Velocity Gain Cap"); } + + #endregion Methods } } diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index b0ef374..c5336a6 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -10,6 +10,8 @@ namespace grapher { public class Option { + #region Constructors + public Option( Field field, Label label, @@ -50,12 +52,20 @@ namespace grapher SetName(startingName); } + #endregion Constructors + + #region Properties + public Field Field { get; } public Label Label { get; } public ActiveValueLabel ActiveValueLabel { get; } + #endregion Properties + + #region Methods + public void SetName(string name) { Label.Text = name; @@ -93,5 +103,7 @@ namespace grapher Show(); } + + #endregion Methods } } diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index b026c8a..c1fd0b7 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -10,6 +10,7 @@ namespace grapher { public class OptionXY { + #region Constructors public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels) { Fields = fields; @@ -50,12 +51,20 @@ namespace grapher SetName(startingName); } + #endregion Constructors + + #region Properties + public FieldXY Fields { get; } public Label Label { get; } public ActiveValueLabelXY ActiveValueLabels { get; } + #endregion Properties + + #region Methods + public void SetName(string name) { Label.Text = name; @@ -89,5 +98,6 @@ namespace grapher Show(); } + #endregion Methods } } diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index 91d7e9f..e0b5d4a 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -3,11 +3,17 @@ using System.Runtime.InteropServices; namespace grapher.Models.Serialized { + #region Enumerations + public enum AccelMode { linear, classic, natural, logarithmic, sigmoid, naturalgain, sigmoidgain, power, noaccel } + #endregion Enumerations + + #region Structs + [StructLayout(LayoutKind.Sequential)] public struct AccelArgs { @@ -31,10 +37,14 @@ namespace grapher.Models.Serialized public T y; } + #endregion Structs + [StructLayout(LayoutKind.Sequential)] [Serializable] public class DriverSettings { + #region Fields + private static readonly IntPtr UnmanagedSettingsHandle = Marshal.AllocHGlobal(Marshal.SizeOf<DriverSettings>()); @@ -45,6 +55,10 @@ namespace grapher.Models.Serialized public Vec2<double> sensitivity; public double minimumTime; + #endregion Fields + + #region Methods + public static DriverSettings GetActive() { DriverInterop.GetActiveSettings(UnmanagedSettingsHandle); @@ -83,5 +97,7 @@ namespace grapher.Models.Serialized */ return true; } + + #endregion Methods } } diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs index 7c8e9a4..253e71d 100644 --- a/grapher/Models/Serialized/GUISettings.cs +++ b/grapher/Models/Serialized/GUISettings.cs @@ -12,6 +12,8 @@ namespace grapher.Models.Serialized [Serializable] public class GUISettings { + #region Constructors + public GUISettings() {} public GUISettings(bool autoWrite, int dpi, int pollRate) @@ -21,6 +23,10 @@ namespace grapher.Models.Serialized PollRate = pollRate; } + #endregion Constructors + + #region Properties + [JsonProperty(Order = 1)] public bool AutoWriteToDriverOnStartup { get; set; } @@ -29,5 +35,7 @@ namespace grapher.Models.Serialized [JsonProperty(Order = 3)] public int PollRate { get; set; } + + #endregion Properties } } diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index 7aed917..768841a 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -13,7 +13,14 @@ namespace grapher.Models.Serialized [Serializable] public class RawAccelSettings { + #region Constants + public const string DefaultSettingsFileName = @"settings.json"; + + #endregion Constants + + #region Fields + public static readonly string ExecutingDirectory = AppDomain.CurrentDomain.BaseDirectory; public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, DefaultSettingsFileName); public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings @@ -21,6 +28,10 @@ namespace grapher.Models.Serialized MissingMemberHandling = MissingMemberHandling.Error, }; + #endregion Fields + + #region Constructors + public RawAccelSettings() { } public RawAccelSettings( @@ -31,10 +42,18 @@ namespace grapher.Models.Serialized GUISettings = guiSettings; } + #endregion Constructors + + #region Properties + public GUISettings GUISettings { get; set; } public DriverSettings AccelerationSettings { get; set; } + #endregion Properties + + #region Methods + public static RawAccelSettings Load() { return Load(DefaultSettingsFile); @@ -75,5 +94,7 @@ namespace grapher.Models.Serialized { File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented)); } + + #endregion Methods } } diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index fc58387..7f018cf 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -6,6 +6,8 @@ namespace grapher.Models.Serialized { public class SettingsManager { + #region Constructors + public SettingsManager( ManagedAccel activeAccel, Field dpiField, @@ -18,6 +20,10 @@ namespace grapher.Models.Serialized AutoWriteMenuItem = autoWrite; } + #endregion Constructors + + #region Properties + public ManagedAccel ActiveAccel { get; } public RawAccelSettings RawAccelSettings { get; private set; } @@ -28,6 +34,10 @@ namespace grapher.Models.Serialized private ToolStripMenuItem AutoWriteMenuItem { get; set; } + #endregion Properties + + #region Methods + public void UpdateActiveSettings(DriverSettings settings) { try @@ -94,5 +104,7 @@ namespace grapher.Models.Serialized }); RawAccelSettings.Save(); } + + #endregion Methods } } |