diff options
Diffstat (limited to 'grapher/Models/Serialized')
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 18 | ||||
| -rw-r--r-- | grapher/Models/Serialized/GUISettings.cs | 17 | ||||
| -rw-r--r-- | grapher/Models/Serialized/RawAccelSettings.cs | 25 | ||||
| -rw-r--r-- | grapher/Models/Serialized/SettingsManager.cs | 25 |
4 files changed, 67 insertions, 18 deletions
diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index cdccf88..d7c9444 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -4,11 +4,17 @@ using System.Threading; namespace grapher.Models.Serialized { + #region Enumerations + public enum AccelMode { - linear, classic, natural, logarithmic, sigmoid, naturalgain, sigmoidgain, power, noaccel + linear, classic, natural, naturalgain, sigmoidgain, power, noaccel } + #endregion Enumerations + + #region Structs + [StructLayout(LayoutKind.Sequential)] public struct AccelArgs { @@ -33,10 +39,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>()); private static object UnmanagedSettingsLock = new object(); @@ -48,6 +58,10 @@ namespace grapher.Models.Serialized public Vec2<double> sensitivity; public double minimumTime; + #endregion Fields + + #region Methods + public static DriverSettings GetActive() { DriverInterop.GetActiveSettings(UnmanagedSettingsHandle); @@ -97,5 +111,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..2543104 100644 --- a/grapher/Models/Serialized/GUISettings.cs +++ b/grapher/Models/Serialized/GUISettings.cs @@ -1,17 +1,13 @@ 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 GUISettings { + #region Constructors + public GUISettings() {} public GUISettings(bool autoWrite, int dpi, int pollRate) @@ -21,6 +17,10 @@ namespace grapher.Models.Serialized PollRate = pollRate; } + #endregion Constructors + + #region Properties + [JsonProperty(Order = 1)] public bool AutoWriteToDriverOnStartup { get; set; } @@ -29,5 +29,10 @@ namespace grapher.Models.Serialized [JsonProperty(Order = 3)] public int PollRate { get; set; } + + [JsonProperty(Order = 4)] + public bool ShowLastMouseMove { get; set; } + + #endregion Properties } } diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index 7aed917..3f5aebc 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -1,26 +1,25 @@ using Newtonsoft.Json; 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; namespace grapher.Models.Serialized { [Serializable] public class RawAccelSettings { - public const string DefaultSettingsFileName = @"settings.json"; + #region Fields + public static readonly string ExecutingDirectory = AppDomain.CurrentDomain.BaseDirectory; - public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, DefaultSettingsFileName); + public static readonly string DefaultSettingsFile = Path.Combine(ExecutingDirectory, Constants.DefaultSettingsFileName); public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error, }; + #endregion Fields + + #region Constructors + public RawAccelSettings() { } public RawAccelSettings( @@ -31,10 +30,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 +82,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 c300bde..ccffc3f 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -6,18 +6,26 @@ namespace grapher.Models.Serialized { public class SettingsManager { + #region Constructors + public SettingsManager( ManagedAccel activeAccel, Field dpiField, Field pollRateField, - ToolStripMenuItem autoWrite) + ToolStripMenuItem autoWrite, + ToolStripMenuItem showLastMouseMove) { ActiveAccel = activeAccel; DpiField = dpiField; PollRateField = pollRateField; AutoWriteMenuItem = autoWrite; + ShowLastMouseMoveMenuItem = showLastMouseMove; } + #endregion Constructors + + #region Properties + public ManagedAccel ActiveAccel { get; } public RawAccelSettings RawAccelSettings { get; private set; } @@ -28,6 +36,12 @@ namespace grapher.Models.Serialized private ToolStripMenuItem AutoWriteMenuItem { get; set; } + private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; } + + #endregion Properties + + #region Methods + public void UpdateActiveSettings(DriverSettings settings, Action afterAccelSettingsUpdate = null) { settings.SendToDriverAndUpdate(ActiveAccel, () => @@ -37,7 +51,8 @@ namespace grapher.Models.Serialized { AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, DPI = (int)DpiField.Data, - PollRate = (int)PollRateField.Data + PollRate = (int)PollRateField.Data, + ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked, }; RawAccelSettings.Save(); @@ -53,6 +68,7 @@ namespace grapher.Models.Serialized DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI); PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate); AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup; + ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove; } public void Startup() @@ -80,9 +96,12 @@ namespace grapher.Models.Serialized { AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked, DPI = (int)DpiField.Data, - PollRate = (int)PollRateField.Data + PollRate = (int)PollRateField.Data, + ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked, }); RawAccelSettings.Save(); } + + #endregion Methods } } |