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

Commit c9028ad

Browse files
committed
v.1.3 - allowing user to mute door events
1 parent 1d2d0b6 commit c9028ad

7 files changed

Lines changed: 127 additions & 52 deletions

File tree

PSpaceStatusChanger/Options.Designer.cs

Lines changed: 50 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSpaceStatusChanger/Options.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace PSpaceStatusChanger
1212
public partial class Options : Form
1313
{
1414
bool autorun_enabled = false;
15+
int silent = 0;
1516

1617
public Options()
1718
{
@@ -22,34 +23,35 @@ public Options()
2223
void Options_Load(object sender, EventArgs e)
2324
{
2425
autorun_enabled = Program.IsStartupItem();
26+
silent = Properties.Settings.Default.silent_mode;
2527

2628
if (autorun_enabled)
2729
{
2830
IsEnabledLbl.Text = "ENABLED";
2931
IsEnabledLbl.ForeColor = Color.DarkGreen;
30-
ToggleActionBtn.Text = "Disable Autorun";
32+
AutoRunChkBox.Checked = true;
3133
}
3234
else
3335
{
3436
IsEnabledLbl.Text = "DISABLED";
3537
IsEnabledLbl.ForeColor = Color.DarkRed;
36-
ToggleActionBtn.Text = "Enable Autorun";
38+
AutoRunChkBox.Checked = false;
3739
}
3840

39-
TimeIntTxt.Text = Properties.Settings.Default.refresh_interval.ToString();
40-
}
41-
42-
private void ToggleActionBtn_Click(object sender, EventArgs e)
43-
{
44-
if (autorun_enabled)
41+
if (silent==1)
4542
{
46-
Program.DisableAutoStartup();
43+
SilentIsEnabledLbl.Text = "ENABLED";
44+
SilentIsEnabledLbl.ForeColor = Color.DarkGreen;
45+
SilentChkBox.Checked = true;
4746
}
4847
else
4948
{
50-
Program.EnableAutoStartup();
49+
SilentIsEnabledLbl.Text = "DISABLED";
50+
SilentIsEnabledLbl.ForeColor = Color.DarkRed;
51+
SilentChkBox.Checked = false;
5152
}
52-
Options_Load(null, null);
53+
54+
TimeIntTxt.Text = Properties.Settings.Default.refresh_interval.ToString();
5355
}
5456

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

67-
Program.UpdateTime();
69+
Properties.Settings.Default.Save();
70+
71+
Program.UpdateTime();
72+
}
73+
74+
private void AutoRunChkBox_CheckedChanged(object sender, EventArgs e)
75+
{
76+
if (autorun_enabled)
77+
{
78+
Program.DisableAutoStartup();
79+
}
80+
else
81+
{
82+
Program.EnableAutoStartup();
83+
}
84+
Options_Load(null, null);
85+
}
6886

87+
private void SilentChkBox_CheckedChanged(object sender, EventArgs e)
88+
{
89+
if (silent==1)
90+
{
91+
Properties.Settings.Default.silent_mode = 0;
92+
}
93+
else
94+
{
95+
Properties.Settings.Default.silent_mode = 1;
96+
}
97+
Options_Load(null, null);
6998
Properties.Settings.Default.Save();
99+
Program.UpdateSilent();
70100
}
71101

72102
}

PSpaceStatusChanger/PSpaceStatusChanger.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<UpdateRequired>false</UpdateRequired>
2626
<MapFileExtensions>true</MapFileExtensions>
2727
<SupportUrl>http://www.p-space.gr</SupportUrl>
28-
<ApplicationRevision>0</ApplicationRevision>
28+
<ApplicationRevision>2</ApplicationRevision>
2929
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<CreateDesktopShortcut>true</CreateDesktopShortcut>

PSpaceStatusChanger/Program.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public static class Program
1212
static Timer tim;
1313
static int oldstatus = -5;
1414
static int olddate = 0;
15+
static int silent = 0;
1516

1617
static void Main()
1718
{
@@ -27,6 +28,7 @@ static void Main()
2728
System.Diagnostics.Process.GetCurrentProcess().Kill();
2829
}
2930

31+
silent = Properties.Settings.Default.silent_mode;
3032
pi = new TrayIcon();
3133
pi.Display();
3234
// Make sure the application runs!
@@ -57,14 +59,17 @@ static void tim_Tick(object sender, EventArgs e)
5759
oldstatus = newstatus;
5860
}
5961

60-
var lastevents = Requests.GetLastEvents(1);
61-
if (lastevents!=null && lastevents[0].t != olddate)
62+
if (silent!=1)
6263
{
63-
if (olddate!=0)
64+
var lastevents = Requests.GetLastEvents(1);
65+
if (lastevents != null && lastevents[0].t != olddate)
6466
{
65-
pi.ShowMessage("P-Space Door Event", lastevents[0].extra);
66-
}
67-
olddate = lastevents[0].t;
67+
if (olddate != 0)
68+
{
69+
pi.ShowMessage("P-Space Door Event", lastevents[0].extra);
70+
}
71+
olddate = lastevents[0].t;
72+
}
6873
}
6974
}
7075

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

81+
public static void UpdateSilent()
82+
{
83+
silent = Properties.Settings.Default.silent_mode;
84+
}
85+
7686
public static void EnableAutoStartup()
7787
{
7888
// The path to the key where Windows looks for startup applications

PSpaceStatusChanger/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSpaceStatusChanger/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
<Setting Name="refresh_interval" Type="System.Int32" Scope="User">
66
<Value Profile="(Default)">1</Value>
77
</Setting>
8+
<Setting Name="silent_mode" Type="System.Int32" Scope="User">
9+
<Value Profile="(Default)">0</Value>
10+
</Setting>
811
</Settings>
912
</SettingsFile>

PSpaceStatusChanger/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<setting name="refresh_interval" serializeAs="String">
1111
<value>1</value>
1212
</setting>
13+
<setting name="silent_mode" serializeAs="String">
14+
<value>0</value>
15+
</setting>
1316
</PSpaceStatusChanger.Properties.Settings>
1417
</userSettings>
1518
</configuration>

0 commit comments

Comments
 (0)