Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lars
2020-10-23 21:07:27 +02:00
7 changed files with 106 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
using SharedClientServer;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace Client.ViewModels
{
class LoginViewModel
{
ClientData data = ClientData.Instance;
private Window window;
public LoginViewModel(Window window)
{
this.window = window;
}
public void UsernameEntered(string name) {
User user = new User(name);
Client client = new Client(user.Username);
client.OnSuccessfullConnect = () =>
{
// because we need to start the main window on a UI thread, we need to let the dispatcher handle it, which will execute the code on the ui thread
Application.Current.Dispatcher.Invoke(delegate {
data.User = user;
data.Client = client;
client.SendMessage(JSONConvert.ConstructLobbyRequestMessage());
MainWindow startWindow = new MainWindow();
startWindow.Show();
window.Close();
});
};
}
}
}

View File

@@ -9,7 +9,7 @@ using System.Diagnostics;
using System.Timers;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media;
using System.Windows.Shapes;
namespace Client.ViewModels
@@ -34,6 +34,7 @@ namespace Client.ViewModels
public string _username;
public string _message;
public string Message
{