Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions grapher/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions grapher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public RawAcceleration()
{
InitializeComponent();


Version driverVersion = VersionHelper.ValidOrThrow();

ToolStripMenuItem HelpMenuItem = new ToolStripMenuItem("&Help");
Expand All @@ -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");

Expand Down Expand Up @@ -89,6 +101,7 @@ public RawAcceleration()
showLastMouseMoveToolStripMenuItem,
AutoWriteMenuItem,
DeviceMenuItem,

ScaleMenuItem,
themeMenuItem,
DPITextBox,
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}