From 3d381ae843a8a9ce964815405a55ea3178befb83 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 12 Oct 2020 13:46:41 +0200 Subject: [PATCH 01/61] [ADDED] client and server project (both are WPF projects)) --- Client/App.xaml | 9 +++++++++ Client/App.xaml.cs | 17 +++++++++++++++++ Client/AssemblyInfo.cs | 10 ++++++++++ Client/Client.csproj | 9 +++++++++ Client/MainWindow.xaml | 12 ++++++++++++ Client/MainWindow.xaml.cs | 28 ++++++++++++++++++++++++++++ Eindproject/Eindproject.sln | 14 +++++++++++++- Server/App.xaml | 9 +++++++++ Server/App.xaml.cs | 17 +++++++++++++++++ Server/AssemblyInfo.cs | 10 ++++++++++ Server/MainWindow.xaml | 12 ++++++++++++ Server/MainWindow.xaml.cs | 28 ++++++++++++++++++++++++++++ Server/Server.csproj | 9 +++++++++ 13 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 Client/App.xaml create mode 100644 Client/App.xaml.cs create mode 100644 Client/AssemblyInfo.cs create mode 100644 Client/Client.csproj create mode 100644 Client/MainWindow.xaml create mode 100644 Client/MainWindow.xaml.cs create mode 100644 Server/App.xaml create mode 100644 Server/App.xaml.cs create mode 100644 Server/AssemblyInfo.cs create mode 100644 Server/MainWindow.xaml create mode 100644 Server/MainWindow.xaml.cs create mode 100644 Server/Server.csproj diff --git a/Client/App.xaml b/Client/App.xaml new file mode 100644 index 0000000..ab673d9 --- /dev/null +++ b/Client/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Client/App.xaml.cs b/Client/App.xaml.cs new file mode 100644 index 0000000..1d01910 --- /dev/null +++ b/Client/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Client +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Client/AssemblyInfo.cs b/Client/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/Client/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Client/Client.csproj b/Client/Client.csproj new file mode 100644 index 0000000..6c68d0e --- /dev/null +++ b/Client/Client.csproj @@ -0,0 +1,9 @@ + + + + WinExe + netcoreapp3.1 + true + + + \ No newline at end of file diff --git a/Client/MainWindow.xaml b/Client/MainWindow.xaml new file mode 100644 index 0000000..0a31cd2 --- /dev/null +++ b/Client/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Client/MainWindow.xaml.cs b/Client/MainWindow.xaml.cs new file mode 100644 index 0000000..87700ee --- /dev/null +++ b/Client/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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 Client +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/Eindproject/Eindproject.sln b/Eindproject/Eindproject.sln index a84d6d9..69d95ea 100644 --- a/Eindproject/Eindproject.sln +++ b/Eindproject/Eindproject.sln @@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30517.126 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eindproject", "Eindproject.csproj", "{F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Eindproject", "Eindproject.csproj", "{F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "..\Server\Server.csproj", "{67A9BF1A-D317-47CA-9F07-C3480D1360FF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "..\Client\Client.csproj", "{83768EDB-097E-4089-A5DE-208CB252D1A0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +19,14 @@ Global {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Debug|Any CPU.Build.0 = Debug|Any CPU {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Release|Any CPU.ActiveCfg = Release|Any CPU {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Release|Any CPU.Build.0 = Release|Any CPU + {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Release|Any CPU.Build.0 = Release|Any CPU + {83768EDB-097E-4089-A5DE-208CB252D1A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Server/App.xaml b/Server/App.xaml new file mode 100644 index 0000000..4bfff38 --- /dev/null +++ b/Server/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Server/App.xaml.cs b/Server/App.xaml.cs new file mode 100644 index 0000000..df4e1b1 --- /dev/null +++ b/Server/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Server +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Server/AssemblyInfo.cs b/Server/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/Server/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Server/MainWindow.xaml b/Server/MainWindow.xaml new file mode 100644 index 0000000..c42cb70 --- /dev/null +++ b/Server/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Server/MainWindow.xaml.cs b/Server/MainWindow.xaml.cs new file mode 100644 index 0000000..58bc2c8 --- /dev/null +++ b/Server/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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 Server +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/Server/Server.csproj b/Server/Server.csproj new file mode 100644 index 0000000..6c68d0e --- /dev/null +++ b/Server/Server.csproj @@ -0,0 +1,9 @@ + + + + WinExe + netcoreapp3.1 + true + + + \ No newline at end of file From 9bf58f8339858536b2db7232139dd1e10da6484c Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 12 Oct 2020 13:54:13 +0200 Subject: [PATCH 02/61] [Removed] An old project. [ADDED] shared project for the client and serv --- SharedClientServer/ClientServerUtil.cs | 10 ++++++++++ SharedClientServer/SharedClientServer.projitems | 13 +++++++++++++ SharedClientServer/SharedClientServer.shproj | 13 +++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 SharedClientServer/ClientServerUtil.cs create mode 100644 SharedClientServer/SharedClientServer.projitems create mode 100644 SharedClientServer/SharedClientServer.shproj diff --git a/SharedClientServer/ClientServerUtil.cs b/SharedClientServer/ClientServerUtil.cs new file mode 100644 index 0000000..815df9b --- /dev/null +++ b/SharedClientServer/ClientServerUtil.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SharedClientServer +{ + class ClientServerUtil + { + } +} diff --git a/SharedClientServer/SharedClientServer.projitems b/SharedClientServer/SharedClientServer.projitems new file mode 100644 index 0000000..3dd68ef --- /dev/null +++ b/SharedClientServer/SharedClientServer.projitems @@ -0,0 +1,13 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 6d26f969-9cb1-414f-ac3e-7253d449ac5a + + + SharedClientServer + + + + diff --git a/SharedClientServer/SharedClientServer.shproj b/SharedClientServer/SharedClientServer.shproj new file mode 100644 index 0000000..68327bb --- /dev/null +++ b/SharedClientServer/SharedClientServer.shproj @@ -0,0 +1,13 @@ + + + + 6d26f969-9cb1-414f-ac3e-7253d449ac5a + 14.0 + + + + + + + + From 1827cc6f214ec00a4ad919cc18a937a84be2d2de Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 12 Oct 2020 13:59:36 +0200 Subject: [PATCH 03/61] Filled up the client server util --- SharedClientServer/ClientServerUtil.cs | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/SharedClientServer/ClientServerUtil.cs b/SharedClientServer/ClientServerUtil.cs index 815df9b..5bd3281 100644 --- a/SharedClientServer/ClientServerUtil.cs +++ b/SharedClientServer/ClientServerUtil.cs @@ -1,10 +1,70 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Net.Sockets; using System.Text; namespace SharedClientServer { class ClientServerUtil { + + public static Encoding encoding = Encoding.UTF8; + + public static string ReadTextMessage(NetworkStream networkStream) + { + var stream = new StreamReader(networkStream, encoding); + { + return stream.ReadLine(); + } + } + + public static void WriteTextMessage(NetworkStream networkStream, string message) + { + using (var stream = new StreamWriter(networkStream, encoding, -1, true)) + { + stream.WriteLine(message); + stream.Flush(); + } + } + + + public static string ReadMessage(NetworkStream networkStream) + { + byte[] lengthBytes = new byte[4]; + + networkStream.Read(lengthBytes, 0, 4); + Console.WriteLine("read message.."); + + int length = BitConverter.ToInt32(lengthBytes); + + byte[] buffer = new byte[length]; + int totalRead = 0; + + + do + { + int read = networkStream.Read(buffer, totalRead, buffer.Length - totalRead); + totalRead += read; + } while (totalRead < length); + + return Encoding.UTF8.GetString(buffer, 0, totalRead); + + } + + public static void SendMessage(NetworkStream networkStream, string message) + { + byte[] data = Encoding.ASCII.GetBytes(message); + + byte[] res = new byte[data.Length + 4]; + + Array.Copy(BitConverter.GetBytes(data.Length), 0, res, 0, 4); + Array.Copy(data, 0, res, 4, data.Length); + + networkStream.Write(res); + } + + + } } From 419c03970a643f6e8aa2f9c9f19b8a8900d09a97 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Mon, 12 Oct 2020 14:01:55 +0200 Subject: [PATCH 04/61] weird stuff --- Eindproject/Eindproject.sln | 13 ++++++------- Server/App.xaml.cs | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Eindproject/Eindproject.sln b/Eindproject/Eindproject.sln index 69d95ea..fc7fc0d 100644 --- a/Eindproject/Eindproject.sln +++ b/Eindproject/Eindproject.sln @@ -3,22 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30517.126 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Eindproject", "Eindproject.csproj", "{F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "..\Server\Server.csproj", "{67A9BF1A-D317-47CA-9F07-C3480D1360FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "..\Server\Server.csproj", "{67A9BF1A-D317-47CA-9F07-C3480D1360FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "..\Client\Client.csproj", "{83768EDB-097E-4089-A5DE-208CB252D1A0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "..\Client\Client.csproj", "{83768EDB-097E-4089-A5DE-208CB252D1A0}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedClientServer", "..\SharedClientServer\SharedClientServer.shproj", "{6D26F969-9CB1-414F-AC3E-7253D449AC5A}" EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\SharedClientServer\SharedClientServer.projitems*{6d26f969-9cb1-414f-ac3e-7253d449ac5a}*SharedItemsImports = 13 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9D948F4-BD6F-4E5A-B7D1-59C6AA04B308}.Release|Any CPU.Build.0 = Release|Any CPU {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {67A9BF1A-D317-47CA-9F07-C3480D1360FF}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Server/App.xaml.cs b/Server/App.xaml.cs index df4e1b1..008245b 100644 --- a/Server/App.xaml.cs +++ b/Server/App.xaml.cs @@ -13,5 +13,6 @@ namespace Server /// public partial class App : Application { + } } From de0b12267b0d36ddbe44bcecbc38f831b213ad7f Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 12 Oct 2020 14:03:13 +0200 Subject: [PATCH 05/61] removed client server util --- SharedClientServer/ClientServerUtil.cs | 57 -------------------------- 1 file changed, 57 deletions(-) diff --git a/SharedClientServer/ClientServerUtil.cs b/SharedClientServer/ClientServerUtil.cs index 5bd3281..ba4a894 100644 --- a/SharedClientServer/ClientServerUtil.cs +++ b/SharedClientServer/ClientServerUtil.cs @@ -9,62 +9,5 @@ namespace SharedClientServer class ClientServerUtil { - public static Encoding encoding = Encoding.UTF8; - - public static string ReadTextMessage(NetworkStream networkStream) - { - var stream = new StreamReader(networkStream, encoding); - { - return stream.ReadLine(); - } - } - - public static void WriteTextMessage(NetworkStream networkStream, string message) - { - using (var stream = new StreamWriter(networkStream, encoding, -1, true)) - { - stream.WriteLine(message); - stream.Flush(); - } - } - - - public static string ReadMessage(NetworkStream networkStream) - { - byte[] lengthBytes = new byte[4]; - - networkStream.Read(lengthBytes, 0, 4); - Console.WriteLine("read message.."); - - int length = BitConverter.ToInt32(lengthBytes); - - byte[] buffer = new byte[length]; - int totalRead = 0; - - - do - { - int read = networkStream.Read(buffer, totalRead, buffer.Length - totalRead); - totalRead += read; - } while (totalRead < length); - - return Encoding.UTF8.GetString(buffer, 0, totalRead); - - } - - public static void SendMessage(NetworkStream networkStream, string message) - { - byte[] data = Encoding.ASCII.GetBytes(message); - - byte[] res = new byte[data.Length + 4]; - - Array.Copy(BitConverter.GetBytes(data.Length), 0, res, 0, 4); - Array.Copy(data, 0, res, 4, data.Length); - - networkStream.Write(res); - } - - - } } From fd4b3d179a05b9ca39bce78655a2113465a2edba Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Mon, 12 Oct 2020 14:12:29 +0200 Subject: [PATCH 06/61] added clientserverutil? --- SharedClientServer/SharedClientServer.projitems | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SharedClientServer/SharedClientServer.projitems b/SharedClientServer/SharedClientServer.projitems index 3dd68ef..6f9a254 100644 --- a/SharedClientServer/SharedClientServer.projitems +++ b/SharedClientServer/SharedClientServer.projitems @@ -9,5 +9,6 @@ SharedClientServer + - + \ No newline at end of file From 6967fb625da94b205de55fb1f283c9a065a07d80 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Mon, 12 Oct 2020 14:39:09 +0200 Subject: [PATCH 07/61] moved mainwindow to views folder --- Server/App.xaml | 2 +- Server/{ => Views}/MainWindow.xaml | 3 +++ Server/{ => Views}/MainWindow.xaml.cs | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) rename Server/{ => Views}/MainWindow.xaml (53%) rename Server/{ => Views}/MainWindow.xaml.cs (82%) diff --git a/Server/App.xaml b/Server/App.xaml index 4bfff38..8ef660c 100644 --- a/Server/App.xaml +++ b/Server/App.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Server" - StartupUri="MainWindow.xaml"> + StartupUri="Views/MainWindow.xaml"> diff --git a/Server/MainWindow.xaml b/Server/Views/MainWindow.xaml similarity index 53% rename from Server/MainWindow.xaml rename to Server/Views/MainWindow.xaml index c42cb70..45eec7f 100644 --- a/Server/MainWindow.xaml +++ b/Server/Views/MainWindow.xaml @@ -7,6 +7,9 @@ mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> + +