Skip to content

Commit

Permalink
Adding Start with Windows option
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvidmar committed Nov 13, 2017
1 parent bb1b98e commit 4312417
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
25 changes: 25 additions & 0 deletions TinyCapture/Helpers/AutoRunHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.Win32;
using System.Reflection;

namespace TinyCapture.Helper
{
public class AutoRunHelper
{
static RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

public static bool Get()
{
return registryKey.GetValue(Assembly.GetEntryAssembly().GetName().Name) != null;
}

public static void Set()
{
registryKey.SetValue(Assembly.GetEntryAssembly().GetName().Name, Assembly.GetExecutingAssembly().Location);
}

public static void Clear()
{
registryKey.DeleteValue(Assembly.GetEntryAssembly().GetName().Name);
}
}
}
12 changes: 11 additions & 1 deletion TinyCapture/MainForm.Designer.cs

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

15 changes: 15 additions & 0 deletions TinyCapture/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using TinyCapture.Helper;

namespace TinyCapture
{
Expand Down Expand Up @@ -120,5 +121,19 @@ private void notifyIcon_Click(object sender, EventArgs e)
notifyIcon.ShowBalloonTip(100);
}

private void startWithWindowsToolStripMenuItem_Click(object sender, EventArgs e)
{
var menu = sender as ToolStripMenuItem;
if (AutoRunHelper.Get())
{
AutoRunHelper.Clear();
menu.Checked = false;
}
else
{
AutoRunHelper.Set();
menu.Checked = true;
}
}
}
}
1 change: 1 addition & 0 deletions TinyCapture/TinyCapture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\AutoRunHelper.cs" />
<Compile Include="KeyModifier.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
Expand Down

0 comments on commit 4312417

Please sign in to comment.