Let's just get this merged instead of having a massive PR

Original PR: tgstation/tgstation#26534
This commit is contained in:
Jordan Brown
2017-06-01 13:06:42 +12:00
committed by oranges
parent 3e2f7329b1
commit 8c6d31f394
72 changed files with 15890 additions and 1 deletions
+63
View File
@@ -0,0 +1,63 @@
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using TGServiceInterface;
namespace TGControlPanel
{
static class Program
{
[STAThread]
static void Main(string [] args)
{
try
{
var res = Server.VerifyConnection();
if (res != null)
{
MessageBox.Show("Unable to connect to service! Error: " + res);
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
return;
}
catch (Exception e)
{
ServiceDisconnectException(e);
}
finally
{
Properties.Settings.Default.Save();
}
}
public static void ServiceDisconnectException(Exception e)
{
MessageBox.Show("An unhandled exception occurred. This usually means we lost connection to the service. Error" + e.ToString());
}
public static string TextPrompt(string caption, string text)
{
Form prompt = new Form()
{
Width = 500,
Height = 150,
FormBorderStyle = FormBorderStyle.FixedDialog,
Text = caption,
StartPosition = FormStartPosition.CenterScreen
};
Label textLabel = new Label() { Left = 50, Top = 20, Text = text, AutoSize = true };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK };
confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.AcceptButton = confirmation;
return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : null;
}
}
}