Skip to content

Commit

Permalink
autostart support
Browse files Browse the repository at this point in the history
  • Loading branch information
LONELY-WOLF committed Apr 26, 2017
1 parent 5d63149 commit eb4806c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions WatchDogeSync/Form1.Designer.cs

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

35 changes: 34 additions & 1 deletion WatchDogeSync/Form1.cs
Expand Up @@ -13,7 +13,7 @@ namespace WatchDogeSync
{
public partial class Form1 : Form
{
private bool exit = false;
private bool exit = false, hide = false;

public Form1()
{
Expand Down Expand Up @@ -134,5 +134,38 @@ private void toolStripMenuItem2_Click(object sender, EventArgs e)
exit = true;
Close();
}

private void Form1_Shown(object sender, EventArgs e)
{
if(hide)
{
Hide();
hide = false;
}
}

private void Form1_Load(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
textPort.Text = args[1];
SetTime(0, 0, 0);
System.Threading.Thread.Sleep(2000);
if (SetTime(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) == 0)
{
labelStatus.Text = "Time set at app start";
checkBoxSync.Checked = true;
hide = true;
}
else
{
MessageBox.Show("Cannot sync time. Application will be shut down.", "WatchDogeSync", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
Top = Screen.PrimaryScreen.WorkingArea.Height - Height;
Left = Screen.PrimaryScreen.WorkingArea.Width - Width;
}
}
}

0 comments on commit eb4806c

Please sign in to comment.