From a8d48325d5e6fe0466502b865c82317b6f7410a2 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 6 Sep 2021 23:24:51 -0400 Subject: get grapher building --- grapher/Models/AccelGUI.cs | 59 ++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 4ce6ed8..e4f924a 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -24,8 +24,7 @@ namespace grapher Button writeButton, ButtonBase resetButton, MouseWatcher mouseWatcher, - ToolStripMenuItem scaleMenuItem, - DeviceIDManager deviceIDManager) + ToolStripMenuItem scaleMenuItem) { AccelForm = accelForm; AccelCalculator = accelCalculator; @@ -38,14 +37,13 @@ namespace grapher DefaultButtonFont = WriteButton.Font; SmallButtonFont = new Font(WriteButton.Font.Name, WriteButton.Font.Size * Constants.SmallButtonSizeFactor); MouseWatcher = mouseWatcher; - DeviceIDManager = deviceIDManager; ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick); WriteButton.Click += new System.EventHandler(OnWriteButtonClick); ResetButton.Click += new System.EventHandler(ResetDriverEventHandler); AccelForm.FormClosing += new FormClosingEventHandler(SaveGUISettingsOnClose); - ButtonTimerInterval = Convert.ToInt32(DriverSettings.WriteDelayMs); + ButtonTimerInterval = Convert.ToInt32(DriverConfig.WriteDelayMs); ButtonTimer = new Timer(); ButtonTimer.Tick += new System.EventHandler(OnButtonTimerTick); @@ -85,8 +83,6 @@ namespace grapher public ToolStripMenuItem ScaleMenuItem { get; } - public DeviceIDManager DeviceIDManager { get; } - private Timer ChartRefresh { get; } private Font SmallButtonFont { get; } @@ -112,21 +108,23 @@ namespace grapher } } - public DriverSettings MakeSettingsFromFields() + public Profile MakeSettingsFromFields() { - var settings = new DriverSettings(); + var settings = new Profile(); settings.rotation = ApplyOptions.Rotation.Field.Data; - settings.sensitivity = new Vec2 - { - x = ApplyOptions.Sensitivity.Fields.X, - y = ApplyOptions.Sensitivity.Fields.Y - }; + settings.sensitivity = ApplyOptions.Sensitivity.Fields.X; + + // TODO - separate sensitivity fields, add new label for ratio + settings.yxSensRatio = ApplyOptions.Sensitivity.Fields.Y; settings.combineMagnitudes = ApplyOptions.IsWhole; - ApplyOptions.SetArgs(ref settings.args); - settings.domainArgs = ApplyOptions.Directionality.GetDomainArgs(); + ApplyOptions.SetArgs(ref settings.argsX, ref settings.argsY); + + var (domWeights, lpNorm) = ApplyOptions.Directionality.GetDomainArgs(); + settings.domainXY = domWeights; + settings.lpNorm = lpNorm; + settings.rangeXY = ApplyOptions.Directionality.GetRangeXY(); - settings.deviceID = DeviceIDManager.ID; Settings.SetHiddenOptions(settings); @@ -141,16 +139,15 @@ namespace grapher { ButtonDelay(WriteButton); - var settings = MakeSettingsFromFields(); - SettingsErrors errors = Settings.TryActivate(settings); - if (errors.Empty()) + var cfg = DriverConfig.FromProfile(MakeSettingsFromFields()); + if (!Settings.TryActivate(cfg, out string errors)) { - RefreshActive(); - return; + error_message = errors.ToString(); } else { - error_message = errors.ToString(); + RefreshActive(); + return; } } catch (ApplicationException e) @@ -161,34 +158,24 @@ namespace grapher new MessageDialog(error_message, "bad input").ShowDialog(); } - - public void UpdateInputManagers() - { - MouseWatcher.UpdateHandles(Settings.ActiveSettings.baseSettings.deviceID); - DeviceIDManager.Update(Settings.ActiveSettings.baseSettings.deviceID); - } - public void RefreshActive() { - UpdateShownActiveValues(Settings.UserSettings); + UpdateShownActiveValues(Settings.ActiveProfile); UpdateGraph(); - UpdateInputManagers(); } public void RefreshUser() { - UpdateShownActiveValues(Settings.UserSettings); + UpdateShownActiveValues(Settings.UserProfile); } public void UpdateGraph() { - AccelCharts.Calculate( - Settings.ActiveAccel, - Settings.ActiveSettings.baseSettings); + AccelCharts.Calculate(Settings.ActiveAccel, Settings.ActiveProfile); AccelCharts.Bind(); } - public void UpdateShownActiveValues(DriverSettings args) + public void UpdateShownActiveValues(Profile args) { AccelForm.ResetAutoScroll(); AccelCharts.ShowActive(args); -- cgit v1.2.3 From 00d39102b469b459c5803fe1a20e52d8217add08 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Tue, 7 Sep 2021 19:53:00 -0400 Subject: update SettingsManager load active config from driver only when necessary ignore devices that aren't running the active profile (in mousewatcher) --- grapher/Models/AccelGUI.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e4f924a..6ad57d9 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -139,8 +139,7 @@ namespace grapher { ButtonDelay(WriteButton); - var cfg = DriverConfig.FromProfile(MakeSettingsFromFields()); - if (!Settings.TryActivate(cfg, out string errors)) + if (!Settings.TryActivate(MakeSettingsFromFields(), out string errors)) { error_message = errors.ToString(); } -- cgit v1.2.3 From 2b568ff5a9c64c549a6d15a19aab0ca4d3a22c11 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Fri, 10 Sep 2021 23:07:02 -0700 Subject: Add y\x ratio to gui --- grapher/Models/AccelGUI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 6ad57d9..801fd8d 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -113,12 +113,12 @@ namespace grapher var settings = new Profile(); settings.rotation = ApplyOptions.Rotation.Field.Data; - settings.sensitivity = ApplyOptions.Sensitivity.Fields.X; + settings.sensitivity = ApplyOptions.Sensitivity.Field.Data; // TODO - separate sensitivity fields, add new label for ratio settings.yxSensRatio = ApplyOptions.Sensitivity.Fields.Y; settings.combineMagnitudes = ApplyOptions.IsWhole; - ApplyOptions.SetArgs(ref settings.argsX, ref settings.argsY); + ApplyOptions.SetArgsFromActiveValues(ref settings.argsX, ref settings.argsY); var (domWeights, lpNorm) = ApplyOptions.Directionality.GetDomainArgs(); settings.domainXY = domWeights; -- cgit v1.2.3 From affc97b1ef41437e7caba31be8e9b9212805182e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sat, 11 Sep 2021 17:38:59 -0700 Subject: YToXRatio fully works --- grapher/Models/AccelGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 801fd8d..e15aba9 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -116,7 +116,7 @@ namespace grapher settings.sensitivity = ApplyOptions.Sensitivity.Field.Data; // TODO - separate sensitivity fields, add new label for ratio - settings.yxSensRatio = ApplyOptions.Sensitivity.Fields.Y; + settings.yxSensRatio = ApplyOptions.YToXRatio.Value; settings.combineMagnitudes = ApplyOptions.IsWhole; ApplyOptions.SetArgsFromActiveValues(ref settings.argsX, ref settings.argsY); -- cgit v1.2.3 From 138ddb54e42e71a384e059afe69e4e8172935d6d Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 13 Sep 2021 23:00:53 -0400 Subject: fix potential leaks forms displayed with ShowDialog are only hidden when closed; Dispose must be called manually --- grapher/Models/AccelGUI.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e15aba9..1836b65 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -154,7 +154,10 @@ namespace grapher error_message = e.Message; } - new MessageDialog(error_message, "bad input").ShowDialog(); + using (var form = new MessageDialog(error_message, "bad input")) + { + form.ShowDialog(); + } } public void RefreshActive() -- cgit v1.2.3 From 7c0305ae2c99c191baf61eb920025826057d5753 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Wed, 15 Sep 2021 06:41:57 -0400 Subject: add device menu --- grapher/Models/AccelGUI.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 1836b65..51e31a6 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -4,6 +4,7 @@ using grapher.Models.Mouse; using grapher.Models.Options; using grapher.Models.Serialized; using System; +using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -24,7 +25,8 @@ namespace grapher Button writeButton, ButtonBase resetButton, MouseWatcher mouseWatcher, - ToolStripMenuItem scaleMenuItem) + ToolStripMenuItem scaleMenuItem, + ToolStripMenuItem deviceMenuItem) { AccelForm = accelForm; AccelCalculator = accelCalculator; @@ -33,11 +35,13 @@ namespace grapher WriteButton = writeButton; ResetButton = (CheckBox)resetButton; ScaleMenuItem = scaleMenuItem; + DeviceMenuItem = deviceMenuItem; Settings = settings; DefaultButtonFont = WriteButton.Font; SmallButtonFont = new Font(WriteButton.Font.Name, WriteButton.Font.Size * Constants.SmallButtonSizeFactor); MouseWatcher = mouseWatcher; + DeviceMenuItem.Click += DeviceMenuItemClick; ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick); WriteButton.Click += new System.EventHandler(OnWriteButtonClick); ResetButton.Click += new System.EventHandler(ResetDriverEventHandler); @@ -83,6 +87,8 @@ namespace grapher public ToolStripMenuItem ScaleMenuItem { get; } + public ToolStripMenuItem DeviceMenuItem { get; } + private Timer ChartRefresh { get; } private Font SmallButtonFont { get; } @@ -146,6 +152,7 @@ namespace grapher else { RefreshActive(); + Settings.SetActiveHandles(); return; } } @@ -240,10 +247,12 @@ namespace grapher { ButtonTimer.Stop(); SetButtonDefaults(); + DeviceMenuItem.Enabled = true; } private void StartButtonTimer() { + DeviceMenuItem.Enabled = false; ButtonTimer.Interval = ButtonTimerInterval; ButtonTimer.Start(); } @@ -268,6 +277,18 @@ namespace grapher MouseWatcher.UpdateLastMove(); } + private void DeviceMenuItemClick(object sender, EventArgs e) + { + using (var devMenu = new DeviceMenuForm(Settings)) + { + if (devMenu.ShowDialog() == DialogResult.OK) + { + Settings.Submit(devMenu.defaultConfig, devMenu.Items); + UpdateActiveSettingsFromFields(); + } + } + } + #endregion Methods } -- cgit v1.2.3 From fdab3cf830e1bf87bc0bd3b72339be14265c7338 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 20 Sep 2021 23:41:36 -0700 Subject: Change disable button to reset, update doc text --- grapher/Models/AccelGUI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher/Models/AccelGUI.cs') diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 51e31a6..23d5017 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -203,7 +203,7 @@ namespace grapher private void SetupButtons() { WriteButton.Top = Constants.SensitivityChartAloneHeight - Constants.ButtonVerticalOffset; - + ResetButton.Appearance = Appearance.Button; ResetButton.FlatStyle = FlatStyle.System; ResetButton.TextAlign = ContentAlignment.MiddleCenter; @@ -239,7 +239,7 @@ namespace grapher private void ResetDriverEventHandler(object sender, EventArgs e) { ButtonDelay(ResetButton); - Settings.DisableDriver(); + Settings.ResetDriver(); RefreshActive(); } -- cgit v1.2.3