Project refactor and added comments

This commit is contained in:
CMS4390\marantalu
2017-11-23 16:56:17 +01:00
parent 7a6e75ffd5
commit 9b6b3194e4
8 changed files with 172 additions and 152 deletions
+62 -61
View File
@@ -14,68 +14,69 @@ using TeamDev.SDK.MVVM;
namespace Step.UI
{
public partial class ServerControlWindow : Form
{
public ServerControlWindow()
public partial class ServerControlWindow : Form
{
InitializeComponent();
}
private static ServerControlWindow ctrlwindow = null;
public static void Start()
{
Thread th = new Thread(() =>
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ctrlwindow = new ServerControlWindow();
Application.Run(ctrlwindow);
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
public static void Stop()
{
if (ctrlwindow != null)
{
ctrlwindow.Invoke((ThreadStart)delegate ()
public ServerControlWindow()
{
ctrlwindow._closing = true;
ctrlwindow.Close();
ctrlwindow = null;
});
}
InitializeComponent();
}
private static ServerControlWindow ctrlwindow = null;
public static void Start()
{ // Open WinForm
Thread th = new Thread(() =>
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ctrlwindow = new ServerControlWindow();
Application.Run(ctrlwindow);
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
public static void Stop()
{ // Close WinForm
if (ctrlwindow != null)
{
ctrlwindow.Invoke((ThreadStart)delegate ()
{
ctrlwindow._closing = true;
ctrlwindow.Close();
ctrlwindow = null;
});
}
}
private bool _closing = false;
// Avoid closing the window
protected override void OnClosing(CancelEventArgs e)
{
if (!_closing)
{
e.Cancel = true;
this.Hide();
}
}
private void OpenUiButton_Click(object sender, EventArgs e)
{
Process.Start("http://localhost:9000/index.html");
}
private void StopServerButton_Click(object sender, EventArgs e)
{
// Send message to listeners and close server
MessageServices.Current.Publish("StopServer");
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Show();
}
}
private bool _closing = false;
// Evito di chiudere la finestra
protected override void OnClosing(CancelEventArgs e)
{
if (!_closing)
{
e.Cancel = true;
this.Hide();
}
}
private void button2_Click(object sender, EventArgs e)
{
Process.Start("http://localhost:9000");
}
private void button1_Click(object sender, EventArgs e)
{
MessageServices.Current.Publish("StopServer");
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Show();
}
}
}