From 4948d32a5892c27b9feca43294af22ae86bed257 Mon Sep 17 00:00:00 2001 From: Patrick Hellebrand Date: Tue, 21 Sep 2021 11:17:52 +0200 Subject: [PATCH] Changes ChatMessage.msg to Content, Fixed Xaml, removes stringTimeStamp --- PolyChat/MainPage.xaml | 6 +++--- PolyChat/MainPage.xaml.cs | 6 +++--- PolyChat/Models/ChatMessage.cs | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/PolyChat/MainPage.xaml b/PolyChat/MainPage.xaml index 4fdf466..e56eae1 100644 --- a/PolyChat/MainPage.xaml +++ b/PolyChat/MainPage.xaml @@ -30,8 +30,8 @@ - + @@ -98,8 +98,8 @@ - - + + diff --git a/PolyChat/MainPage.xaml.cs b/PolyChat/MainPage.xaml.cs index bbc53e8..f3905e7 100644 --- a/PolyChat/MainPage.xaml.cs +++ b/PolyChat/MainPage.xaml.cs @@ -27,7 +27,7 @@ namespace PolyChat networkingController = new NetworkingController(this); Partners = new ObservableCollection(); - //ipAddress.Text = IP.GetCodeFromIP(Controller.GetIP()); + ipAddress.Text = IP.GetCodeFromIP(networkingController.getIP().ToString()); } public void OnChatPartnerSelected(object sender, RoutedEventArgs e) @@ -58,7 +58,7 @@ namespace PolyChat string ip = dialog.getValue(); if (IP.ValidateIP(ip)) { - Controller.Connect(ip); + networkingController.connectNewClient(ip); Partners.Add(new ChatPartner( "Connecting...", ip @@ -83,7 +83,7 @@ namespace PolyChat { ChatPartner sendingPartner = Partners.First(p => p.Code == message.Ip); sendingPartner.AddMessage(new ChatMessage( - message.Msg, + message.Content, true, message.Sender )); diff --git a/PolyChat/Models/ChatMessage.cs b/PolyChat/Models/ChatMessage.cs index 60cb6d0..28cf47c 100644 --- a/PolyChat/Models/ChatMessage.cs +++ b/PolyChat/Models/ChatMessage.cs @@ -6,17 +6,15 @@ namespace PolyChat.Models { public readonly string Sender; public readonly DateTime Timestamp = new DateTime(1970, 01, 01); - public readonly string Msg = "empty"; + public readonly string Content; public readonly string Ip; public readonly bool Foreign; - public readonly string StringTimeStamp; - public ChatMessage(string Msg = "", bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1") + public ChatMessage(string Content = "", bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1") { this.Sender = Sender; this.Timestamp = DateTime.Now; - StringTimeStamp = Timestamp.ToString(); - this.Msg = Msg; + this.Content = Content; this.Foreign = Foreign; this.Ip = Ip; } @@ -25,7 +23,7 @@ namespace PolyChat.Models public string ToString() { string prefix = Foreign ? "Other" : "Me"; - return $"{prefix}: {Msg}({Sender})"; + return $"{prefix}: {Content}({Sender})"; } } } \ No newline at end of file