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/Client/ViewModels/ViewModelGame.cs b/Client/ViewModels/ViewModelGame.cs index 48b36a0..37f3508 100644 --- a/Client/ViewModels/ViewModelGame.cs +++ b/Client/ViewModels/ViewModelGame.cs @@ -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 { 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/Eindproject.sln b/Eindproject/Eindproject.sln index 4c7629c..d1522f0 100644 --- a/Eindproject/Eindproject.sln +++ b/Eindproject/Eindproject.sln @@ -9,8 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "..\Client\Client. EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedClientServer", "..\SharedClientServer\SharedClientServer.shproj", "{6D26F969-9CB1-414F-AC3E-7253D449AC5A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{4CB2CD76-07D9-44D0-A559-A7A301621D30}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\SharedClientServer\SharedClientServer.projitems*{4cb2cd76-07d9-44d0-a559-a7a301621d30}*SharedItemsImports = 5 ..\SharedClientServer\SharedClientServer.projitems*{67a9bf1a-d317-47ca-9f07-c3480d1360ff}*SharedItemsImports = 5 ..\SharedClientServer\SharedClientServer.projitems*{6d26f969-9cb1-414f-ac3e-7253d449ac5a}*SharedItemsImports = 13 ..\SharedClientServer\SharedClientServer.projitems*{83768edb-097e-4089-a5de-208cb252d1a0}*SharedItemsImports = 5 @@ -28,6 +31,10 @@ Global {83768EDB-097E-4089-A5DE-208CB252D1A0}.Debug|Any CPU.Build.0 = Debug|Any CPU {83768EDB-097E-4089-A5DE-208CB252D1A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {83768EDB-097E-4089-A5DE-208CB252D1A0}.Release|Any CPU.Build.0 = Release|Any CPU + {4CB2CD76-07D9-44D0-A559-A7A301621D30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4CB2CD76-07D9-44D0-A559-A7A301621D30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4CB2CD76-07D9-44D0-A559-A7A301621D30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4CB2CD76-07D9-44D0-A559-A7A301621D30}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE 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 + + + + + + + + + + + + +