Project refactor and added comments
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user