Files
cms_thermo_active/Step.UI/ServerControlWindow.cs
T

82 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TeamDev.SDK;
using TeamDev.SDK.MVVM;
namespace Step.UI
{
public partial class ServerControlWindow : Form
{
public ServerControlWindow()
{
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 ()
{
ctrlwindow._closing = true;
ctrlwindow.Close();
ctrlwindow = null;
});
}
}
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();
}
}
}