Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
v.1.3 - allowing user to mute door events
Browse files Browse the repository at this point in the history
  • Loading branch information
eparon committed Feb 22, 2014
1 parent 1d2d0b6 commit c9028ad
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 52 deletions.
83 changes: 50 additions & 33 deletions PSpaceStatusChanger/Options.Designer.cs

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

54 changes: 42 additions & 12 deletions PSpaceStatusChanger/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace PSpaceStatusChanger
public partial class Options : Form
{
bool autorun_enabled = false;
int silent = 0;

public Options()
{
Expand All @@ -22,34 +23,35 @@ public Options()
void Options_Load(object sender, EventArgs e)
{
autorun_enabled = Program.IsStartupItem();
silent = Properties.Settings.Default.silent_mode;

if (autorun_enabled)
{
IsEnabledLbl.Text = "ENABLED";
IsEnabledLbl.ForeColor = Color.DarkGreen;
ToggleActionBtn.Text = "Disable Autorun";
AutoRunChkBox.Checked = true;
}
else
{
IsEnabledLbl.Text = "DISABLED";
IsEnabledLbl.ForeColor = Color.DarkRed;
ToggleActionBtn.Text = "Enable Autorun";
AutoRunChkBox.Checked = false;
}

TimeIntTxt.Text = Properties.Settings.Default.refresh_interval.ToString();
}

private void ToggleActionBtn_Click(object sender, EventArgs e)
{
if (autorun_enabled)
if (silent==1)
{
Program.DisableAutoStartup();
SilentIsEnabledLbl.Text = "ENABLED";
SilentIsEnabledLbl.ForeColor = Color.DarkGreen;
SilentChkBox.Checked = true;
}
else
{
Program.EnableAutoStartup();
SilentIsEnabledLbl.Text = "DISABLED";
SilentIsEnabledLbl.ForeColor = Color.DarkRed;
SilentChkBox.Checked = false;
}
Options_Load(null, null);

TimeIntTxt.Text = Properties.Settings.Default.refresh_interval.ToString();
}

private void SetTimeBtn_Click(object sender, EventArgs e)
Expand All @@ -64,9 +66,37 @@ private void SetTimeBtn_Click(object sender, EventArgs e)
SetTimeBtn.Text = "Done!";
SetTimeBtn.Enabled = false;

Program.UpdateTime();
Properties.Settings.Default.Save();

Program.UpdateTime();
}

private void AutoRunChkBox_CheckedChanged(object sender, EventArgs e)
{
if (autorun_enabled)
{
Program.DisableAutoStartup();
}
else
{
Program.EnableAutoStartup();
}
Options_Load(null, null);
}

private void SilentChkBox_CheckedChanged(object sender, EventArgs e)
{
if (silent==1)
{
Properties.Settings.Default.silent_mode = 0;
}
else
{
Properties.Settings.Default.silent_mode = 1;
}
Options_Load(null, null);
Properties.Settings.Default.Save();
Program.UpdateSilent();
}

}
Expand Down
2 changes: 1 addition & 1 deletion PSpaceStatusChanger/PSpaceStatusChanger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<SupportUrl>http://www.p-space.gr</SupportUrl>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
Expand Down
22 changes: 16 additions & 6 deletions PSpaceStatusChanger/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static class Program
static Timer tim;
static int oldstatus = -5;
static int olddate = 0;
static int silent = 0;

static void Main()
{
Expand All @@ -27,6 +28,7 @@ static void Main()
System.Diagnostics.Process.GetCurrentProcess().Kill();
}

silent = Properties.Settings.Default.silent_mode;
pi = new TrayIcon();
pi.Display();
// Make sure the application runs!
Expand Down Expand Up @@ -57,14 +59,17 @@ static void tim_Tick(object sender, EventArgs e)
oldstatus = newstatus;
}

var lastevents = Requests.GetLastEvents(1);
if (lastevents!=null && lastevents[0].t != olddate)
if (silent!=1)
{
if (olddate!=0)
var lastevents = Requests.GetLastEvents(1);
if (lastevents != null && lastevents[0].t != olddate)
{
pi.ShowMessage("P-Space Door Event", lastevents[0].extra);
}
olddate = lastevents[0].t;
if (olddate != 0)
{
pi.ShowMessage("P-Space Door Event", lastevents[0].extra);
}
olddate = lastevents[0].t;
}
}
}

Expand All @@ -73,6 +78,11 @@ public static void UpdateTime()
tim.Interval = Properties.Settings.Default.refresh_interval * 1000;
}

public static void UpdateSilent()
{
silent = Properties.Settings.Default.silent_mode;
}

public static void EnableAutoStartup()
{
// The path to the key where Windows looks for startup applications
Expand Down
12 changes: 12 additions & 0 deletions PSpaceStatusChanger/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions PSpaceStatusChanger/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<Setting Name="refresh_interval" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="silent_mode" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 3 additions & 0 deletions PSpaceStatusChanger/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<setting name="refresh_interval" serializeAs="String">
<value>1</value>
</setting>
<setting name="silent_mode" serializeAs="String">
<value>0</value>
</setting>
</PSpaceStatusChanger.Properties.Settings>
</userSettings>
</configuration>

0 comments on commit c9028ad

Please sign in to comment.