diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index d6311ccb..1671b894 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -206,6 +206,7 @@ private void InitializeComponent() this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showLastMouseMoveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AutoLoadStartupItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DeviceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.chartsPanel = new System.Windows.Forms.Panel(); @@ -1689,15 +1690,16 @@ private void InitializeComponent() // advancedToolStripMenuItem // this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AutoLoadStartupItem, this.AutoWriteMenuItem, - this.DeviceMenuItem}); + this.DeviceMenuItem}); this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem"; this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20); this.advancedToolStripMenuItem.Text = "Advanced"; // // AutoWriteMenuItem // - this.AutoWriteMenuItem.Checked = true; + this.AutoWriteMenuItem.Checked = false; this.AutoWriteMenuItem.CheckOnClick = true; this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; @@ -1709,6 +1711,19 @@ private void InitializeComponent() this.DeviceMenuItem.Name = "DeviceMenuItem"; this.DeviceMenuItem.Size = new System.Drawing.Size(257, 22); this.DeviceMenuItem.Text = "Device Menu"; + // + // AutoLoadStartupItem + // + this.AutoLoadStartupItem.Checked = false; + this.AutoLoadStartupItem.CheckOnClick = true; + this.AutoLoadStartupItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AutoLoadStartupItem.Name = "AutoLoadStartupItem"; + this.AutoLoadStartupItem.Size = new System.Drawing.Size(257, 22); + this.AutoLoadStartupItem.Text = "Load GUI On Windows Startup"; + + + + // // chartsPanel // @@ -2492,6 +2507,7 @@ private void InitializeComponent() private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChart; private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem; + private System.Windows.Forms.ToolStripMenuItem AutoLoadStartupItem; private System.Windows.Forms.Panel DirectionalityPanel; private System.Windows.Forms.Label DirectionalityRangeLabel; private System.Windows.Forms.Label DirectionalDomainLabel; diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 44b8acd2..a10dc535 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -22,6 +22,7 @@ public RawAcceleration() { InitializeComponent(); + Version driverVersion = VersionHelper.ValidOrThrow(); ToolStripMenuItem HelpMenuItem = new ToolStripMenuItem("&Help"); @@ -37,6 +38,17 @@ public RawAcceleration() }) }); + // + // load on startup addition + // + var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup); + var shortcutPath = Path.Combine(startupFolder, "rawaccel.lnk"); + AutoLoadStartupItem.Checked = File.Exists(shortcutPath); + + AutoLoadStartupItem.Click += AutoLoadStartupItem_Click; + + + var schemes = ColorSchemeManager.LoadSchemes().ToList(); var themeMenuItem = new ToolStripMenuItem("&Themes"); @@ -89,6 +101,7 @@ public RawAcceleration() showLastMouseMoveToolStripMenuItem, AutoWriteMenuItem, DeviceMenuItem, + ScaleMenuItem, themeMenuItem, DPITextBox, @@ -363,6 +376,10 @@ static void MakeStartupShortcut(bool gui) { if (!gui) lnk.Arguments = Constants.DefaultSettingsFileName; lnk.TargetPath = $@"{Application.StartupPath}\{name}.exe"; + + // Set "start in" directory to the application path + lnk.WorkingDirectory = Application.StartupPath; + lnk.Save(); } finally @@ -377,6 +394,17 @@ static void MakeStartupShortcut(bool gui) } } + private void RemoveStartupShortcut() + { + var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup); + var shortcutPath = Path.Combine(startupFolder, "rawaccel.lnk"); + + if (File.Exists(shortcutPath)) + { + File.Delete(shortcutPath); + } + } + private void RawAcceleration_FormClosing(object sender, FormClosingEventArgs e) { Properties.Settings.Default.Size = Size; @@ -414,5 +442,26 @@ private void RawAcceleration_Shown(object sender, EventArgs e) this.EndInvoke(result); } } + + private void AutoLoadStartupItem_Click(object sender, EventArgs e) + { + try + { + // Toggle shortcut creation/removal based on check box + if (AutoLoadStartupItem.Checked) + { + MakeStartupShortcut(true); + } + else + { + RemoveStartupShortcut(); + } + + } + catch (Exception ex) + { + MessageBox.Show($"Failed To Update Startup Shortcut: {ex.Message}","ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } }