summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grapher/Constants/Constants.cs7
-rw-r--r--grapher/Form1.Designer.cs48
-rw-r--r--grapher/Form1.cs2
-rw-r--r--grapher/Layouts/DefaultLayout.cs1
-rw-r--r--grapher/Layouts/LayoutBase.cs4
-rw-r--r--grapher/Layouts/OffLayout.cs1
-rw-r--r--grapher/Models/AccelGUI.cs150
-rw-r--r--grapher/Models/AccelGUIFactory.cs4
-rw-r--r--grapher/Models/Charts/AccelCharts.cs4
-rw-r--r--grapher/Models/Serialized/GUISettings.cs27
-rw-r--r--grapher/Models/Serialized/RawAccelSettings.cs12
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs22
12 files changed, 184 insertions, 98 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs
index b41ffa2..639bd9b 100644
--- a/grapher/Constants/Constants.cs
+++ b/grapher/Constants/Constants.cs
@@ -58,7 +58,7 @@ namespace grapher
public const int NarrowChartLeft = 482;
/// <summary> Vertical placement of write button above bottom of sensitivity graph </summary>
- public const int WriteButtonVerticalOffset = 80;
+ public const int ButtonVerticalOffset = 60;
/// <summary> Format string for shortened x and y textboxes. </summary>
public const string ShortenedFormatString = "0.###";
@@ -85,7 +85,10 @@ namespace grapher
public const string WriteButtonDefaultText = "Apply";
/// <summary> Default text to be displayed on write button. </summary>
- public const string WriteButtonDelayText = "Delay";
+ public const string ToggleButtonDefaultText = "Toggle";
+
+ /// <summary> Default text to be displayed on write button. </summary>
+ public const string ButtonDelayText = "Delay";
/// <summary> Title of sensitivity chart. </summary>
public const string SensitivityChartTitle = "Sensitivity";
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index b8b1c8f..c2d77c9 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -116,8 +116,6 @@ namespace grapher
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.wholeVectorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byVectorComponentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
@@ -167,6 +165,7 @@ namespace grapher
this.ScaleActiveXLabel = new System.Windows.Forms.Label();
this.scaleLabelX = new System.Windows.Forms.Label();
this.scaleBoxX = new System.Windows.Forms.TextBox();
+ this.toggleButton = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit();
@@ -371,9 +370,9 @@ namespace grapher
// writeButton
//
this.writeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
- this.writeButton.Location = new System.Drawing.Point(177, 359);
+ this.writeButton.Location = new System.Drawing.Point(103, 377);
this.writeButton.Name = "writeButton";
- this.writeButton.Size = new System.Drawing.Size(128, 40);
+ this.writeButton.Size = new System.Drawing.Size(92, 35);
this.writeButton.TabIndex = 23;
this.writeButton.Text = "Apply";
this.writeButton.UseVisualStyleBackColor = true;
@@ -501,8 +500,7 @@ namespace grapher
this.menuStrip1.BackColor = System.Drawing.SystemColors.ControlLight;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.graphsToolStripMenuItem,
- this.advancedToolStripMenuItem,
- this.startupToolStripMenuItem});
+ this.advancedToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1884, 24);
@@ -528,7 +526,7 @@ namespace grapher
this.pollRateToolStripMenuItem,
this.ScaleMenuItem});
this.scaleByDPIToolStripMenuItem.Name = "scaleByDPIToolStripMenuItem";
- this.scaleByDPIToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.scaleByDPIToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.scaleByDPIToolStripMenuItem.Text = "Scale by Mouse Settings";
//
// dPIToolStripMenuItem
@@ -568,7 +566,7 @@ namespace grapher
// showVelocityGainToolStripMenuItem
//
this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem";
- this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain";
//
// showLastMouseMoveToolStripMenuItem
@@ -577,7 +575,7 @@ namespace grapher
this.showLastMouseMoveToolStripMenuItem.CheckOnClick = true;
this.showLastMouseMoveToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.showLastMouseMoveToolStripMenuItem.Name = "showLastMouseMoveToolStripMenuItem";
- this.showLastMouseMoveToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.showLastMouseMoveToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.showLastMouseMoveToolStripMenuItem.Text = "Show Last Mouse Move";
//
// advancedToolStripMenuItem
@@ -658,23 +656,6 @@ namespace grapher
this.byVectorComponentToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.byVectorComponentToolStripMenuItem.Text = "By Component";
//
- // startupToolStripMenuItem
- //
- this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.AutoWriteMenuItem});
- this.startupToolStripMenuItem.Name = "startupToolStripMenuItem";
- this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20);
- this.startupToolStripMenuItem.Text = "Startup";
- //
- // AutoWriteMenuItem
- //
- this.AutoWriteMenuItem.Checked = true;
- this.AutoWriteMenuItem.CheckOnClick = true;
- this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
- this.AutoWriteMenuItem.Name = "AutoWriteMenuItem";
- this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22);
- this.AutoWriteMenuItem.Text = "Apply Settings File on Startup";
- //
// AccelerationChartY
//
chartArea4.AxisX.Title = "Input Speed (counts/ms)";
@@ -1188,11 +1169,21 @@ namespace grapher
this.scaleBoxX.Size = new System.Drawing.Size(76, 20);
this.scaleBoxX.TabIndex = 6;
//
+ // toggleButton
+ //
+ this.toggleButton.Location = new System.Drawing.Point(223, 384);
+ this.toggleButton.Name = "toggleButton";
+ this.toggleButton.Size = new System.Drawing.Size(104, 24);
+ this.toggleButton.TabIndex = 24;
+ this.toggleButton.Text = "toggle";
+ this.toggleButton.UseVisualStyleBackColor = true;
+ //
// RawAcceleration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1884, 956);
+ this.Controls.Add(this.toggleButton);
this.Controls.Add(this.scaleLabelY);
this.Controls.Add(this.ScaleActiveYLabel);
this.Controls.Add(this.scaleBoxY);
@@ -1308,7 +1299,6 @@ namespace grapher
private System.Windows.Forms.Label constantThreeLabelX;
private System.Windows.Forms.TextBox offsetBoxX;
private System.Windows.Forms.Label offsetLabelX;
- private System.Windows.Forms.Button writeButton;
private System.Windows.Forms.TextBox sensitivityBoxY;
private System.Windows.Forms.TextBox capBoxY;
private System.Windows.Forms.CheckBox sensXYLock;
@@ -1345,8 +1335,6 @@ namespace grapher
private System.Windows.Forms.Label OffsetActiveXLabel;
private System.Windows.Forms.Label LimitActiveXLabel;
private System.Windows.Forms.Label MidpointActiveXLabel;
- private System.Windows.Forms.ToolStripMenuItem startupToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem wholeVectorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem byVectorComponentToolStripMenuItem;
@@ -1386,6 +1374,8 @@ namespace grapher
private System.Windows.Forms.Label ScaleActiveXLabel;
private System.Windows.Forms.Label scaleLabelX;
private System.Windows.Forms.TextBox scaleBoxX;
+ private System.Windows.Forms.CheckBox toggleButton;
+ private System.Windows.Forms.Button writeButton;
}
}
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index a1d43b3..91cc4e2 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -50,6 +50,7 @@ namespace grapher
accelTypeDropX,
accelTypeDropY,
writeButton,
+ toggleButton,
showVelocityGainToolStripMenuItem,
showLastMouseMoveToolStripMenuItem,
wholeVectorToolStripMenuItem,
@@ -58,7 +59,6 @@ namespace grapher
legacyCapToolStripMenuItem,
gainOffsetToolStripMenuItem,
legacyOffsetToolStripMenuItem,
- AutoWriteMenuItem,
ScaleMenuItem,
DPITextBox,
PollRateTextBox,
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
index c8cce6d..c2f7fd7 100644
--- a/grapher/Layouts/DefaultLayout.cs
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -9,7 +9,6 @@ namespace grapher.Layouts
{
Name = "Default";
Index = (int)AccelMode.noaccel;
- ButtonEnabled = false;
LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
index c380397..7ed08ef 100644
--- a/grapher/Layouts/LayoutBase.cs
+++ b/grapher/Layouts/LayoutBase.cs
@@ -26,7 +26,6 @@ namespace grapher.Layouts
ExponentLayout = new OptionLayout(false, string.Empty);
MidpointLayout = new OptionLayout(false, string.Empty);
- ButtonEnabled = true;
LogarithmicCharts = false;
}
@@ -40,8 +39,6 @@ namespace grapher.Layouts
public bool LogarithmicCharts { get; protected set; }
- protected bool ButtonEnabled { get; set; }
-
protected OptionLayout AccelLayout { get; set; }
protected OptionLayout ScaleLayout { get; set; }
@@ -70,7 +67,6 @@ namespace grapher.Layouts
Button button,
int top)
{
- button.Enabled = ButtonEnabled;
IOption previous = null;
diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs
index 664e364..0b54cbb 100644
--- a/grapher/Layouts/OffLayout.cs
+++ b/grapher/Layouts/OffLayout.cs
@@ -9,7 +9,6 @@ namespace grapher.Layouts
{
Name = "Off";
Index = (int)AccelMode.noaccel;
- ButtonEnabled = true;
LogarithmicCharts = false;
AccelLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 11685ee..c561b23 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -3,7 +3,9 @@ using grapher.Models.Mouse;
using grapher.Models.Options;
using grapher.Models.Serialized;
using System;
+using System.Drawing;
using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
namespace grapher
{
@@ -19,6 +21,7 @@ namespace grapher
SettingsManager settings,
ApplyOptions applyOptions,
Button writeButton,
+ ButtonBase toggleButton,
MouseWatcher mouseWatcher,
ToolStripMenuItem scaleMenuItem)
{
@@ -27,19 +30,28 @@ namespace grapher
AccelCharts = accelCharts;
ApplyOptions = applyOptions;
WriteButton = writeButton;
+ ToggleButton = (CheckBox)toggleButton;
ScaleMenuItem = scaleMenuItem;
Settings = settings;
Settings.Startup();
- RefreshOnRead();
+ RefreshOnRead(Settings.RawAccelSettings.AccelerationSettings);
+
+ DefaultButtonFont = WriteButton.Font;
+ SmallButtonFont = new Font(WriteButton.Font.Name, WriteButton.Font.Size * 0.666f);
MouseWatcher = mouseWatcher;
ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick);
WriteButton.Click += new System.EventHandler(OnWriteButtonClick);
+ ToggleButton.Click += new System.EventHandler(OnToggleButtonClick);
+ AccelForm.FormClosing += new FormClosingEventHandler(SaveGUISettingsOnClose);
+
+ ButtonTimerInterval = Convert.ToInt32(DriverInterop.WriteDelayMs);
+ ButtonTimer = new Timer();
+ ButtonTimer.Tick += new System.EventHandler(OnButtonTimerTick);
+ SetupButtons();
- ButtonTimer = SetupButtonTimer();
ChartRefresh = SetupChartTimer();
- SetupWriteButton();
}
#endregion Constructors
@@ -58,6 +70,8 @@ namespace grapher
public Button WriteButton { get; }
+ public CheckBox ToggleButton { get; }
+
public Timer ButtonTimer { get; }
public MouseWatcher MouseWatcher { get; }
@@ -66,10 +80,30 @@ namespace grapher
private Timer ChartRefresh { get; }
+ private Font SmallButtonFont { get; }
+
+ private Font DefaultButtonFont { get; }
+
+ private bool SettingsNotDefault { get; set; }
+
+ private bool LastToggleChecked { get; set; }
+
+ private int ButtonTimerInterval { get; }
+
#endregion Properties
#region Methods
+ private void SaveGUISettingsOnClose(Object sender, FormClosingEventArgs e)
+ {
+ var guiSettings = Settings.MakeGUISettingsFromFields();
+ if (!Settings.RawAccelSettings.GUISettings.ValueEquals(guiSettings))
+ {
+ Settings.RawAccelSettings.GUISettings = guiSettings;
+ Settings.RawAccelSettings.Save();
+ }
+ }
+
public void UpdateActiveSettingsFromFields()
{
var driverSettings = Settings.RawAccelSettings.AccelerationSettings;
@@ -92,7 +126,8 @@ namespace grapher
SettingsErrors errors = Settings.TryUpdateActiveSettings(settings);
if (errors.Empty())
{
- RefreshOnRead();
+ RefreshToggleStateFromNewSettings();
+ RefreshOnRead(Settings.RawAccelSettings.AccelerationSettings);
}
else
{
@@ -100,26 +135,24 @@ namespace grapher
}
}
- public void RefreshOnRead()
+ public void RefreshOnRead(DriverSettings args)
{
- UpdateShownActiveValues();
- UpdateGraph();
+ UpdateShownActiveValues(args);
+ UpdateGraph(args);
}
- public void UpdateGraph()
+ public void UpdateGraph(DriverSettings args)
{
AccelCharts.Calculate(
- Settings.ActiveAccel,
- Settings.RawAccelSettings.AccelerationSettings);
+ Settings.ActiveAccel,
+ args);
AccelCharts.Bind();
}
- public void UpdateShownActiveValues()
+ public void UpdateShownActiveValues(DriverSettings args)
{
- var settings = Settings.RawAccelSettings.AccelerationSettings;
-
- AccelCharts.ShowActive(settings);
- ApplyOptions.SetActiveValues(settings);
+ AccelCharts.ShowActive(args);
+ ApplyOptions.SetActiveValues(args);
}
private Timer SetupChartTimer()
@@ -131,38 +164,47 @@ namespace grapher
return chartTimer;
}
- private Timer SetupButtonTimer()
+ private void SetupButtons()
{
- Timer buttonTimer = new Timer();
- buttonTimer.Enabled = true;
- buttonTimer.Interval = Convert.ToInt32(DriverInterop.WriteDelayMs);
- buttonTimer.Tick += new System.EventHandler(OnButtonTimerTick);
- return buttonTimer;
+ WriteButton.Top = AccelCharts.Top + AccelCharts.TopChartHeight - Constants.ButtonVerticalOffset;
+ SetWriteButtonDefault();
+
+ ToggleButton.Appearance = Appearance.Button;
+ ToggleButton.FlatStyle = FlatStyle.System;
+ ToggleButton.TextAlign = ContentAlignment.MiddleCenter;
+ ToggleButton.Size = WriteButton.Size;
+ ToggleButton.Top = WriteButton.Top;
+
+ RefreshToggleStateFromNewSettings();
+ SetToggleButtonDefault();
}
- private void SetupWriteButton()
+ private void RefreshToggleStateFromNewSettings()
{
- WriteButton.Top = AccelCharts.Top + AccelCharts.TopChartHeight - Constants.WriteButtonVerticalOffset;
- SetWriteButtonDefault();
+ SettingsNotDefault = !Settings.RawAccelSettings.IsDefaultEquivalent();
+ LastToggleChecked = SettingsNotDefault;
}
private void SetWriteButtonDefault()
{
+ WriteButton.Font = DefaultButtonFont;
WriteButton.Text = Constants.WriteButtonDefaultText;
WriteButton.Enabled = true;
WriteButton.Update();
}
- private void SetWriteButtonDelay()
+ private void SetToggleButtonDefault()
{
- WriteButton.Enabled = false;
- WriteButton.Text = $"{Constants.WriteButtonDelayText} : {ButtonTimer.Interval} ms";
- WriteButton.Update();
+ ToggleButton.Checked = LastToggleChecked;
+ ToggleButton.Enabled = SettingsNotDefault;
+ ToggleButton.Font = DefaultButtonFont;
+ ToggleButton.Text = ToggleButton.Checked ? "Enabled" : "Disabled";
+ ToggleButton.Update();
}
private void OnScaleMenuItemClick(object sender, EventArgs e)
{
- UpdateGraph();
+ UpdateGraph(Settings.RawAccelSettings.AccelerationSettings);
}
private void OnWriteButtonClick(object sender, EventArgs e)
@@ -170,18 +212,64 @@ namespace grapher
UpdateActiveSettingsFromFields();
}
+ private void OnToggleButtonClick(object sender, EventArgs e)
+ {
+ var settings = ToggleButton.Checked ?
+ Settings.RawAccelSettings.AccelerationSettings :
+ DriverInterop.DefaultSettings;
+
+ ToggleButtonDelay();
+
+ SettingsManager.SendToDriver(settings);
+ Settings.ActiveAccel.UpdateFromSettings(settings);
+ RefreshOnRead(settings);
+ }
+
private void OnButtonTimerTick(object sender, EventArgs e)
{
ButtonTimer.Stop();
SetWriteButtonDefault();
+ SetToggleButtonDefault();
}
- private void WriteButtonDelay()
+ private void StartButtonTimer()
{
- SetWriteButtonDelay();
+ ButtonTimer.Interval = ButtonTimerInterval;
ButtonTimer.Start();
}
+ private void WriteButtonDelay()
+ {
+ WriteButton.Font = SmallButtonFont;
+ WriteButton.Text = $"{Constants.ButtonDelayText} : {ButtonTimerInterval} ms";
+ WriteButton.Enabled = false;
+ WriteButton.Update();
+
+ if (ToggleButton.Enabled)
+ {
+ LastToggleChecked = ToggleButton.Checked;
+ ToggleButton.Checked = false;
+ ToggleButton.Enabled = false;
+ ToggleButton.Update();
+ }
+ StartButtonTimer();
+ }
+
+ private void ToggleButtonDelay()
+ {
+ LastToggleChecked = ToggleButton.Checked;
+ ToggleButton.Checked = false;
+ ToggleButton.Enabled = false;
+ ToggleButton.Font = SmallButtonFont;
+ ToggleButton.Text = $"{Constants.ButtonDelayText} : {ButtonTimerInterval} ms";
+ ToggleButton.Update();
+
+ WriteButton.Enabled = false;
+ WriteButton.Update();
+
+ StartButtonTimer();
+ }
+
private void OnChartTimerTick(object sender, EventArgs e)
{
AccelCharts.DrawLastMovement();
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index 9f557f3..579e664 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -23,6 +23,7 @@ namespace grapher.Models
ComboBox accelTypeDropX,
ComboBox accelTypeDropY,
Button writeButton,
+ ButtonBase toggleButton,
ToolStripMenuItem showVelocityGainToolStripMenuItem,
ToolStripMenuItem showLastMouseMoveMenuItem,
ToolStripMenuItem wholeVectorToolStripMenuItem,
@@ -31,7 +32,6 @@ namespace grapher.Models
ToolStripMenuItem legacyCapToolStripMenuItem,
ToolStripMenuItem gainOffsetToolStripMenuItem,
ToolStripMenuItem legacyOffsetToolStripMenuItem,
- ToolStripMenuItem autoWriteMenuItem,
ToolStripMenuItem scaleMenuItem,
ToolStripTextBox dpiTextBox,
ToolStripTextBox pollRateTextBox,
@@ -326,7 +326,6 @@ namespace grapher.Models
activeAccel,
accelCalculator.DPI,
accelCalculator.PollRate,
- autoWriteMenuItem,
showLastMouseMoveMenuItem,
showVelocityGainToolStripMenuItem);
@@ -339,6 +338,7 @@ namespace grapher.Models
settings,
applyOptions,
writeButton,
+ toggleButton,
mouseWatcher,
scaleMenuItem);
}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index 7484a3a..9087b30 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -133,14 +133,14 @@ namespace grapher
{
ChartState.SetWidened();
UpdateFormWidth();
- AlignWriteButton();
+ //AlignWriteButton();
}
public void SetNarrowed()
{
ChartState.SetNarrowed();
UpdateFormWidth();
- AlignWriteButton();
+ //AlignWriteButton();
}
public void Redraw()
diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs
index 84e681b..f9e5755 100644
--- a/grapher/Models/Serialized/GUISettings.cs
+++ b/grapher/Models/Serialized/GUISettings.cs
@@ -10,32 +10,35 @@ namespace grapher.Models.Serialized
public GUISettings() {}
- public GUISettings(bool autoWrite, int dpi, int pollRate)
- {
- AutoWriteToDriverOnStartup = autoWrite;
- DPI = dpi;
- PollRate = pollRate;
- }
-
#endregion Constructors
#region Properties
- [JsonProperty(Order = 1)]
- public bool AutoWriteToDriverOnStartup { get; set; }
- [JsonProperty(Order = 2)]
+ [JsonProperty(Order = 1)]
public int DPI { get; set; }
- [JsonProperty(Order = 3)]
+ [JsonProperty(Order = 2)]
public int PollRate { get; set; }
- [JsonProperty(Order = 4)]
+ [JsonProperty(Order = 3)]
public bool ShowLastMouseMove { get; set; }
[JsonProperty(Order = 4)]
public bool ShowVelocityAndGain { get; set; }
#endregion Properties
+
+ #region Methods
+
+ public bool ValueEquals(GUISettings other)
+ {
+ return DPI == other.DPI &&
+ PollRate == other.PollRate &&
+ ShowLastMouseMove == other.ShowLastMouseMove &&
+ ShowVelocityAndGain == other.ShowVelocityAndGain;
+ }
+
+ #endregion Methods
}
}
diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs
index 6f48d44..e0362ff 100644
--- a/grapher/Models/Serialized/RawAccelSettings.cs
+++ b/grapher/Models/Serialized/RawAccelSettings.cs
@@ -115,6 +115,18 @@ namespace grapher.Models.Serialized
.AddFirst(new JProperty("### Mode Types ###", modes));
}
+ public bool IsDefaultEquivalent()
+ {
+ bool wholeOrNoY = AccelerationSettings.combineMagnitudes ||
+ AccelerationSettings.modes.y == AccelMode.noaccel;
+
+ return AccelerationSettings.sensitivity.x == 1 &&
+ AccelerationSettings.sensitivity.y == 1 &&
+ AccelerationSettings.rotation == 0 &&
+ AccelerationSettings.modes.x == AccelMode.noaccel &&
+ wholeOrNoY;
+ }
+
#endregion Methods
}
}
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index f53c9c9..8712c87 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -14,14 +14,12 @@ namespace grapher.Models.Serialized
ManagedAccel activeAccel,
Field dpiField,
Field pollRateField,
- ToolStripMenuItem autoWrite,
ToolStripMenuItem showLastMouseMove,
ToolStripMenuItem showVelocityAndGain)
{
ActiveAccel = activeAccel;
DpiField = dpiField;
PollRateField = pollRateField;
- AutoWriteMenuItem = autoWrite;
ShowLastMouseMoveMenuItem = showLastMouseMove;
ShowVelocityAndGainMoveMenuItem = showVelocityAndGain;
}
@@ -38,8 +36,6 @@ namespace grapher.Models.Serialized
private Field PollRateField { get; set; }
- private ToolStripMenuItem AutoWriteMenuItem { get; set; }
-
private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; }
private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; }
@@ -90,17 +86,20 @@ namespace grapher.Models.Serialized
return errors;
}
- public void UpdateActiveAccelFromFileSettings(DriverSettings settings)
+ public void UpdateFieldsFromGUISettings()
{
- TryUpdateAccel(settings);
-
DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI);
PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate);
- AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove;
ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain;
}
+ public void UpdateActiveAccelFromFileSettings(DriverSettings settings)
+ {
+ TryUpdateAccel(settings);
+ UpdateFieldsFromGUISettings();
+ }
+
public SettingsErrors TryUpdateAccel(DriverSettings settings)
{
var errors = SendToDriverSafe(settings);
@@ -124,7 +123,6 @@ namespace grapher.Models.Serialized
{
return new GUISettings
{
- AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked,
DPI = (int)DpiField.Data,
PollRate = (int)PollRateField.Data,
ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked,
@@ -139,10 +137,8 @@ namespace grapher.Models.Serialized
try
{
RawAccelSettings = RawAccelSettings.Load(() => MakeGUISettingsFromFields());
- if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup)
- {
- UpdateActiveAccelFromFileSettings(RawAccelSettings.AccelerationSettings);
- }
+ UpdateFieldsFromGUISettings();
+ UpdateActiveAccelFromFileSettings(RawAccelSettings.AccelerationSettings);
return;
}
catch (JsonException e)