Skip to content

Commit

Permalink
V0.4 30 June, 2012
Browse files Browse the repository at this point in the history
1. Complete reconstruction of UI
2. details now includes assigned port number parsed from applicationhost.config file.
  • Loading branch information
LordAmit committed Jun 30, 2012
1 parent 8672712 commit 3fa0444
Show file tree
Hide file tree
Showing 10 changed files with 1,350 additions and 177 deletions.
3 changes: 3 additions & 0 deletions IISExpressManager/FindOperatingSystemBasedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ namespace IISExpressManager
Written by lordamit
lordamit {at] gmail [dot} com
*/

internal class FindOperatingSystemBasedInfo
{

internal static string OperatingSystemSpecificIISLocation()
{
//Used to Find Integer Pointer Size. Size 8 = 64 bit, size 4 = 32 bit OS
int size = IntPtr.Size;

if (size == 8) return @"C:\Program Files (x86)\IIS Express\iisexpress.exe";
Expand Down
233 changes: 156 additions & 77 deletions IISExpressManager/Form1.Designer.cs

Large diffs are not rendered by default.

189 changes: 107 additions & 82 deletions IISExpressManager/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal bool ExitFromNotification {
public Form1()
{
InitializeComponent();

_iisExpressConfig = new IISExpressConfiguration();
SetStatusLabels();
ListViewPropertySetter();
Expand All @@ -37,7 +38,18 @@ private void ListViewInsertItems()
item.SubItems.Add(iisSite.SiteName);
item.SubItems.Add(iisSite.Status);
item.SubItems.Add(iisSite.ProcessId);
item.SubItems.Add(iisSite.Port);
listView1.Items.Add(item);
listView1.Items[listView1.Items.Count-1].UseItemStyleForSubItems = false;
if(iisSite.Status.Equals("Started"))
{
item.SubItems[2].ForeColor= Color.Green;
}else
{
item.SubItems[2].ForeColor = Color.Red;
}
//Console.WriteLine(/*String.Format("{0}, {1}, {2}, {3}"), */
// item.SubItems[0].Text+item.SubItems[1].Text+ item.SubItems[2].Text+ item.SubItems[3].Text);
}
}

Expand Down Expand Up @@ -106,26 +118,37 @@ private void ListViewCompleteReloadWithAssigningPID()

private void SetStatusLabels()
{
if (_iisExpressConfig.CheckIISExpressConfigExistence())
SetStatusForIISExpressConfigFileExistence();
SetStatusForIISExpressExistence();
}

#region Set Statuses
private void SetStatusForIISExpressExistence()
{
if (_iisExpressConfig.CheckIISExpressExistence())
{
lblIISConfigStatus.Text = "Found!";
lblIISConfigStatus.ForeColor = Color.Teal;
lblIISStatus.Text = "Found!";
lblIISStatus.ForeColor = Color.Teal;
}
else
{
DisableAllButtonsWhenIISError();
lblIISConfigStatus.ForeColor = Color.Red;
//DisableAllButtonsWhenIISError();
lblIISStatus.ForeColor = Color.Red;
textBox1.Text = "Please Install IIS Express";
}
if (_iisExpressConfig.CheckIISExpressExistence())
}

private void SetStatusForIISExpressConfigFileExistence()
{
if (_iisExpressConfig.CheckIISExpressConfigExistence())
{
lblIISStatus.Text = "Found!";
lblIISStatus.ForeColor = Color.Teal;
lblIISConfigStatus.Text = "Found!";
lblIISConfigStatus.ForeColor = Color.Teal;
}
else
{
DisableAllButtonsWhenIISError();
lblIISStatus.ForeColor = Color.Red;
//DisableAllButtonsWhenIISError();
lblIISConfigStatus.ForeColor = Color.Red;
textBox1.Text = "Please Install IIS Express";
}
}
Expand All @@ -135,12 +158,12 @@ private void UpdateBoxStatus(int selected)
textBox1.Text = "Site Name: " + _iisSites[selected].SiteName;
textBox1.Text += "\r\nStatus: " + _iisSites[selected].Status;
}
#endregion

private bool IsAnswerYes(DialogResult dialogResult)
{
if (dialogResult == DialogResult.Yes)
return true;

return false;
}

Expand Down Expand Up @@ -181,77 +204,6 @@ private void NotificationIconContextItem1Click(object sender, EventArgs e)

#endregion Notification Icon In System Tray

#region ButtonActions

private void DisableAllButtonsWhenIISError()
{
/*btnStart.Enabled = false;
btnStop.Enabled = false;*/
btnStopAll.Enabled = false;
btnResetAll.Enabled = false;
btnRefresh.Enabled = false;
}

private void btnRefresh_Click(object sender, EventArgs e)
{
ListViewCompleteReloadWithAssigningPID();
}

/*private void btnStart_Click(object sender, EventArgs e)
{
CheckAttemptToStartSelectedApp();
}
private void btnStop_Click(object sender, EventArgs e)
{
CheckAttemptToStopSelectedApp();
}*/

private void btnAbout_Click(object sender, EventArgs e)
{
if (
IsAnswerYes(
MessageBox.Show(
"Hi there!\nIISEM is a open source freeware initiated by Amit from Bangladesh." +
"\nIt is available in CodePlex.\nWant to check out the codeplex homepage?",
"About", MessageBoxButtons.YesNo, MessageBoxIcon.Information)))
{
const string target = "http://iisem.codeplex.com/";
Process.Start(target);
}
}

private void btnHelp_Click(object sender, EventArgs e)
{
MessageBox.Show("" +
"1. Double Click to Start/Stop any Application in the list!"
+ "\n2. Press the refresh button to sync it with IIS Express",
"IISEM Help", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}

private void btnResetAll_Click(object sender, EventArgs e)
{
if (
IsAnswerYes(
MessageBox.Show(
"Clicking this will:\n\n1. Stop all applications in IISExpress\n2. Refresh The list.\n\nAre you sure you want to do this?",
"Reset IIS Express Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Information)))
{
StopAllIISHostedApplications();
ListViewCompleteReloadMappedWithWebsiteList();
}
}

private void btnStopAll_Click(object sender, EventArgs e)
{
StopAllIISHostedApplications();
ListViewCompleteReloadMappedWithWebsiteList();
textBox1.Text = "Stopped all applications.";
}

#endregion ButtonActions

#region ApplicationManage

private void StartSelectedApplication(int selected)
Expand Down Expand Up @@ -335,5 +287,78 @@ private void CheckAttemptToStartSelectedApp()
/*ListViewReInsertItems();*/
}
}

#region MenuItemActions
private void helpToolStripMenuItem1_Click(object sender, EventArgs e)
{
MessageBox.Show("" +
"1. Double Click to Start/Stop any Application in the list!"
+ "\n2. Press F5 to sync it with IIS Express",
"IISEM Help", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
if (
IsAnswerYes(
MessageBox.Show(
"Hi there!\nIISEM is a open source freeware initiated by Amit from Bangladesh." +
"\nIt is available in CodePlex.\nWant to check out the codeplex homepage?",
"About", MessageBoxButtons.YesNo, MessageBoxIcon.Information)))
{
const string target = "http://iisem.codeplex.com/";
Process.Start(target);
}
}

private void resetToolStripMenuItem_Click(object sender, EventArgs e)
{
if (
IsAnswerYes(
MessageBox.Show(
"Clicking this will:\n" +
"\n1. Stop all applications in IISExpress" +
"\n2. Refresh The list." +
"\n\nAre you sure you want to do this?",
"Reset IIS Express Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Information)))
{
StopAllIISHostedApplications();
ListViewCompleteReloadMappedWithWebsiteList();
}
}

private void stopAllToolStripMenuItem_Click(object sender, EventArgs e)
{
StopAllIISHostedApplications();
ListViewCompleteReloadMappedWithWebsiteList();
textBox1.Text = "Stopped all applications.";
}

private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
{
ListViewCompleteReloadWithAssigningPID();
}

private void runSiteToolStripMenuItem_Click(object sender, EventArgs e)
{
SayOops();
}

private void editSiteToolStripMenuItem_Click(object sender, EventArgs e)
{
SayOops();
}

#endregion


private static void SayOops()
{
MessageBox.Show("Looks like it is not implemented yet.",
"Oops", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}

}
}
3 changes: 3 additions & 0 deletions IISExpressManager/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@
gAAAB//////wAAD///////4Af/////////////////////////8=
</value>
</data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>285, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAQEAAAAEAIAAoQgAAFgAAACgAAABAAAAAgAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Expand Down
37 changes: 34 additions & 3 deletions IISExpressManager/IISConfigReader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace IISExpressManager
Expand All @@ -16,21 +17,51 @@ Written by lordamit
internal static List<IISSites> ReadXmlFromConfig(IISExpressConfiguration iisExConfig)
{
_iisSites = new List<IISSites>();
var output = new StringBuilder();


if (!iisExConfig.CheckIISExpressConfigExistence()) return null;

string contents = File.ReadAllText(iisExConfig.IISExpressConfigAddress);

var document = new XmlDocument();
document.LoadXml(contents);
XmlNodeList siteList = document.GetElementsByTagName("site");
XmlNodeList bindingNodes = document.SelectNodes("/configuration/system.applicationHost/sites/site/bindings");
int counter=0;
foreach (object node in siteList)
{
var xmlElement = (XmlElement)node;
_iisSites.Add(new IISSites(xmlElement.Attributes["name"].Value, xmlElement.Attributes["id"].Value));
var portNumber = FindPort(bindingNodes.Item(counter).InnerXml);
_iisSites.Add(new IISSites(xmlElement.Attributes["name"].Value, xmlElement.Attributes["id"].Value, portNumber));
counter++;
}

return _iisSites;
}

private static string FindPort(string innerXmlString)
{
//<binding protocol=\"http\" bindingInformation=\":8080:localhost\" />
//<binding protocol=\"http\" bindingInformation=\"*:1038:localhost\" />

int indexOfLastColon;
string portNumber;
int portIndex = innerXmlString.IndexOf("=\":");

if(portIndex==-1)
{
portIndex = innerXmlString.IndexOf("*");
portNumber = innerXmlString.Substring(portIndex + 2);
indexOfLastColon= portNumber.IndexOf(":");

portNumber = portNumber.Substring(0, indexOfLastColon);
return portNumber;
}
portNumber = innerXmlString.Substring(portIndex+3);
indexOfLastColon = portNumber.IndexOf(":");

portNumber = portNumber.Substring(0, indexOfLastColon);
return portNumber;

}
}
}
2 changes: 1 addition & 1 deletion IISExpressManager/IISExpressManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="IISManagerSingleton.cs" />
<Compile Include="IISSites.cs" />
<Compile Include="IISProcessManager.cs" />
<Compile Include="ProcessCommandLineFinder.cs" />
Expand Down Expand Up @@ -113,6 +112,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="IISEM.ico" />
<Content Include="sample.xml" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
Expand Down
11 changes: 0 additions & 11 deletions IISExpressManager/IISManagerSingleton.cs

This file was deleted.

4 changes: 3 additions & 1 deletion IISExpressManager/IISSites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ public class IISSites
Written by lordamit
lordamit {at] gmail [dot} com
*/
public IISSites(string siteName, string id)
public IISSites(string siteName, string id, string portNumber)
{
SiteName = siteName;
Id = id;
Status = "Stopped";
ProcessId = "Not Found";
Port = portNumber;
}

public string ProcessId { get; set; }
public string Status { get; set; }
public string Id { get; set; }
public string SiteName { get; set; }
public string Port { get; set; }
}
}
4 changes: 2 additions & 2 deletions IISExpressManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
[assembly: AssemblyDescription("IIS Express Manager is a simple utility program to manage IIS Express configured applications.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IISExpressManager V0.31B")]
[assembly: AssemblyCopyright("Licensed under MS-RL")]
[assembly: AssemblyProduct("IISExpressManager V0.4B")]
[assembly: AssemblyCopyright("Licensed under MS-RL by Amit Seal Ami")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Loading

0 comments on commit 3fa0444

Please sign in to comment.