Basic framework - server loader, plugin manager, chat interface

This commit is contained in:
John Michael Gross
2016-09-16 19:57:18 -07:00
parent c0a41d6a67
commit f2ec79a286
35 changed files with 1758 additions and 22 deletions

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace PistonServer
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private DateTime startTime;
private Timer uiUpdate = new Timer
{
Interval = 1000,
AutoReset = true,
};
public MainWindow()
{
InitializeComponent();
startTime = DateTime.Now;
uiUpdate.Elapsed += UiUpdate_Elapsed;
TabControl.Items.Add(new TabItem());
}
private void UiUpdate_Elapsed(object sender, ElapsedEventArgs e)
{
UpdateUptime();
}
private void UpdateUptime()
{
var currentTime = DateTime.Now;
var uptime = currentTime - startTime;
Dispatcher.Invoke(() => LabelUptime.Content = $"Uptime: {uptime.Days}d {uptime.Hours}h {uptime.Minutes}m");
}
private void BtnStart_Click(object sender, RoutedEventArgs e)
{
startTime = DateTime.Now;
Chat.IsEnabled = true;
Players.IsEnabled = true;
((Button) sender).IsEnabled = false;
BtnStop.IsEnabled = true;
uiUpdate.Start();
ServerManager.Static.StartServerThread();
}
private void BtnStop_Click(object sender, RoutedEventArgs e)
{
Chat.IsEnabled = false;
Players.IsEnabled = false;
((Button) sender).IsEnabled = false;
//HACK: Uncomment when restarting is possible.
//BtnStart.IsEnabled = true;
uiUpdate.Stop();
ServerManager.Static.StopServer();
}
}
}