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

Commit e9af6d6

Browse files
committedJan 19, 2014
initial commit, v1.0. changes and improvements will come soon!
1 parent 1657f4d commit e9af6d6

18 files changed

+653
-0
lines changed
 

‎PSpaceStatusChanger.sln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSpaceStatusChanger", "PSpaceStatusChanger\PSpaceStatusChanger.csproj", "{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|x86 = Debug|x86
9+
Release|x86 = Release|x86
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}.Debug|x86.ActiveCfg = Debug|x86
13+
{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}.Debug|x86.Build.0 = Debug|x86
14+
{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}.Release|x86.ActiveCfg = Release|x86
15+
{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}.Release|x86.Build.0 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

‎PSpaceStatusChanger/ContextMenu.cs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Diagnostics;
6+
using System.Windows.Forms;
7+
using PSpaceStatusChanger.Properties;
8+
9+
namespace PSpaceStatusChanger
10+
{
11+
class ContextMenu
12+
{
13+
14+
public ContextMenuStrip Create()
15+
{
16+
// Add the default menu options.
17+
ContextMenuStrip menu = new ContextMenuStrip();
18+
ToolStripMenuItem item;
19+
ToolStripSeparator sep;
20+
21+
// Open.
22+
item = new ToolStripMenuItem();
23+
item.Image = Resources.Shop_Open_32;
24+
item.Text = "P-Space open";
25+
item.Click += new EventHandler(open_Click);
26+
menu.Items.Add(item);
27+
28+
// Separator.
29+
sep = new ToolStripSeparator();
30+
menu.Items.Add(sep);
31+
32+
// Closed.
33+
item = new ToolStripMenuItem();
34+
item.Image = Resources.Shop_Closed_32;
35+
item.Text = "P-Space closed";
36+
item.Click += new EventHandler(closed_Click);
37+
menu.Items.Add(item);
38+
39+
// Separator.
40+
sep = new ToolStripSeparator();
41+
menu.Items.Add(sep);
42+
43+
// Exit.
44+
item = new ToolStripMenuItem();
45+
item.Text = "Exit";
46+
item.Click += new System.EventHandler(Exit_Click);
47+
item.Image = Resources.exit_32;
48+
menu.Items.Add(item);
49+
50+
return menu;
51+
}
52+
53+
void open_Click(object sender, EventArgs e)
54+
{
55+
Requests.SetStatus(true);
56+
//Program.pi.SetOpen();
57+
}
58+
59+
void closed_Click(object sender, EventArgs e)
60+
{
61+
Requests.SetStatus(false);
62+
//Program.pi.SetClosed();
63+
}
64+
65+
void Exit_Click(object sender, EventArgs e)
66+
{
67+
// Quit without further ado.
68+
Application.Exit();
69+
}
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{E3CA99D4-35D8-4016-BB01-8182AFD3C6ED}</ProjectGuid>
9+
<OutputType>WinExe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>PSpaceStatusChanger</RootNamespace>
12+
<AssemblyName>PSpaceStatusChanger</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
<FileAlignment>512</FileAlignment>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<PlatformTarget>x86</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28+
<PlatformTarget>x86</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Deployment" />
44+
<Reference Include="System.Drawing" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="ContextMenu.cs" />
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
<Compile Include="Properties\Resources.Designer.cs">
53+
<AutoGen>True</AutoGen>
54+
<DesignTime>True</DesignTime>
55+
<DependentUpon>Resources.resx</DependentUpon>
56+
</Compile>
57+
<Compile Include="Requests.cs" />
58+
<Compile Include="TrayIcon.cs" />
59+
<EmbeddedResource Include="Properties\Resources.resx">
60+
<Generator>ResXFileCodeGenerator</Generator>
61+
<SubType>Designer</SubType>
62+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
63+
</EmbeddedResource>
64+
<None Include="Properties\Settings.settings">
65+
<Generator>SettingsSingleFileGenerator</Generator>
66+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
67+
</None>
68+
<Compile Include="Properties\Settings.Designer.cs">
69+
<AutoGen>True</AutoGen>
70+
<DependentUpon>Settings.settings</DependentUpon>
71+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
72+
</Compile>
73+
</ItemGroup>
74+
<ItemGroup>
75+
<None Include="Resources\closed.ico" />
76+
</ItemGroup>
77+
<ItemGroup>
78+
<None Include="Resources\open.ico" />
79+
</ItemGroup>
80+
<ItemGroup>
81+
<None Include="Resources\Shop-Closed-32.png" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<None Include="Resources\Shop-Open-32.png" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<None Include="Resources\exit-32.png" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<None Include="Resources\cube1.ico" />
91+
</ItemGroup>
92+
<ItemGroup>
93+
<None Include="Resources\cube2.ico" />
94+
</ItemGroup>
95+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
96+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
97+
Other similar extension points exist, see Microsoft.Common.targets.
98+
<Target Name="BeforeBuild">
99+
</Target>
100+
<Target Name="AfterBuild">
101+
</Target>
102+
-->
103+
</Project>

‎PSpaceStatusChanger/Program.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Windows.Forms;
5+
6+
namespace PSpaceStatusChanger
7+
{
8+
public static class Program
9+
{
10+
static TrayIcon pi;
11+
static Timer tim;
12+
static int oldstatus = -5;
13+
static void Main()
14+
{
15+
Application.EnableVisualStyles();
16+
Application.SetCompatibleTextRenderingDefault(false);
17+
18+
pi = new TrayIcon();
19+
pi.Display();
20+
// Make sure the application runs!
21+
22+
tim = new Timer();
23+
tim.Tick += new EventHandler(tim_Tick);
24+
tim.Interval = 1000;
25+
tim.Start();
26+
27+
Application.Run();
28+
}
29+
30+
static void tim_Tick(object sender, EventArgs e)
31+
{
32+
var newstatus = Requests.CheckStatus();
33+
if (newstatus != oldstatus)
34+
{
35+
if (newstatus == 1)
36+
{
37+
pi.ShowMessage("P-Space is now open!");
38+
pi.SetOpen();
39+
}
40+
else
41+
{
42+
pi.ShowMessage("P-Space is now closed!");
43+
pi.SetClosed();
44+
}
45+
oldstatus = newstatus;
46+
}
47+
}
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PSpaceStatusChanger")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PSpaceStatusChanger")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("aaabfc5a-13fd-4f4d-b129-68f2ef320e30")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎PSpaceStatusChanger/Properties/Resources.Designer.cs

+113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="closed" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\cube2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123+
</data>
124+
<data name="exit_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
125+
<value>..\Resources\exit-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126+
</data>
127+
<data name="open" type="System.Resources.ResXFileRef, System.Windows.Forms">
128+
<value>..\Resources\cube1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129+
</data>
130+
<data name="Shop_Closed_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
131+
<value>..\Resources\Shop-Closed-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
132+
</data>
133+
<data name="Shop_Open_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
134+
<value>..\Resources\Shop-Open-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
135+
</data>
136+
</root>

‎PSpaceStatusChanger/Properties/Settings.Designer.cs

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3+
<Profiles>
4+
<Profile Name="(Default)" />
5+
</Profiles>
6+
<Settings />
7+
</SettingsFile>

‎PSpaceStatusChanger/Requests.cs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Net;
6+
7+
namespace PSpaceStatusChanger
8+
{
9+
public static class Requests
10+
{
11+
public static void SetStatus(bool IsOpen)
12+
{
13+
WebClient wc = new WebClient();
14+
if(IsOpen==true)
15+
{
16+
wc.DownloadString("http://www.p-space.gr/status/set.php?open");
17+
}
18+
else
19+
{
20+
wc.DownloadString("http://www.p-space.gr/status/set.php?close");
21+
}
22+
}
23+
24+
public static int CheckStatus()
25+
{
26+
WebClient wc = new WebClient();
27+
string str = wc.DownloadString("http://www.p-space.gr/status/");
28+
int status = -1;
29+
if (Int32.TryParse(str, out status))
30+
{
31+
return status;
32+
}
33+
else
34+
return -1;
35+
}
36+
}
37+
}
4.47 KB
Loading
4.46 KB
Loading
1.74 KB
Binary file not shown.
1.12 KB
Binary file not shown.
1.12 KB
Binary file not shown.
1.97 KB
Loading
1.74 KB
Binary file not shown.

‎PSpaceStatusChanger/TrayIcon.cs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows.Forms;
6+
using PSpaceStatusChanger.Properties;
7+
8+
namespace PSpaceStatusChanger
9+
{
10+
class TrayIcon : IDisposable
11+
{
12+
NotifyIcon nIc;
13+
14+
public TrayIcon()
15+
{
16+
nIc = new NotifyIcon();
17+
}
18+
19+
public void Display()
20+
{
21+
// Put the icon in the system tray and allow it react to mouse clicks.
22+
//nIc.MouseClick += new MouseEventHandler(ni_MouseClick);
23+
nIc.Icon = Resources.closed;
24+
nIc.Text = "P-Space Notifier";
25+
nIc.Visible = true;
26+
27+
// Attach a context menu.
28+
nIc.ContextMenuStrip = new ContextMenu().Create();
29+
}
30+
31+
public void SetOpen()
32+
{
33+
nIc.Icon = Resources.open;
34+
}
35+
36+
public void ShowMessage(string msg)
37+
{
38+
nIc.ShowBalloonTip(3000, "P-Space Status Changed", msg, ToolTipIcon.Info);
39+
}
40+
41+
public void SetClosed()
42+
{
43+
nIc.Icon = Resources.closed;
44+
}
45+
46+
public void Dispose()
47+
{
48+
nIc.Dispose();
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)
This repository has been archived.