diff --git a/Client/ViewModels/LoginViewModel.cs b/Client/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..f4ecee6 --- /dev/null +++ b/Client/ViewModels/LoginViewModel.cs @@ -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(); + }); + }; + } + } +} diff --git a/Eindproject/Client2/Client2.csproj b/Eindproject/Client2/Client2.csproj new file mode 100644 index 0000000..66fc7f5 --- /dev/null +++ b/Eindproject/Client2/Client2.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/Eindproject/Client2/Program.cs b/Eindproject/Client2/Program.cs new file mode 100644 index 0000000..85dba95 --- /dev/null +++ b/Eindproject/Client2/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace Client2 +{ + class Program + { + static void Main(string[] args) + { + Client.App app = new Client.App(); + app.Run(); + + } + } +} diff --git a/Eindproject/Tests/JSONConvertTest.cs b/Eindproject/Tests/JSONConvertTest.cs new file mode 100644 index 0000000..3f73db6 --- /dev/null +++ b/Eindproject/Tests/JSONConvertTest.cs @@ -0,0 +1,15 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SharedClientServer; +using Xunit.Sdk; + +namespace Tests +{ + [TestClass] + public class JSONConvertTest + { + [TestMethod] + public void TestMethod1() + { + } + } +} diff --git a/Eindproject/Tests/Tests.csproj b/Eindproject/Tests/Tests.csproj new file mode 100644 index 0000000..676c0ac --- /dev/null +++ b/Eindproject/Tests/Tests.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + +