Changes ChatMessage.msg to Content, Fixed Xaml, removes stringTimeStamp
This commit is contained in:
@@ -30,8 +30,8 @@
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="0 0 8 0" Text="Connect to" Foreground="{ThemeResource SystemColorDisabledTextColor}"/>
|
||||
<TextBlock x:Name="ipAddress" Grid.Column="1"/>
|
||||
@@ -98,8 +98,8 @@
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:ChatMessage">
|
||||
<StackPanel x:Name="Message" Margin="0 4" Padding="16 8" CornerRadius="4" Background="{ThemeResource SystemAccentColor}">
|
||||
<TextBlock Text="{x:Bind Msg}"/>
|
||||
<TextBlock Text="{x:Bind StringTimeStamp}"/>
|
||||
<TextBlock Text="{x:Bind Content}"/>
|
||||
<TextBlock Text="{x:Bind Timestamp.ToShortDateString()}"/>
|
||||
<TextBlock Text="{x:Bind Foreign}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace PolyChat
|
||||
networkingController = new NetworkingController(this);
|
||||
|
||||
Partners = new ObservableCollection<ChatPartner>();
|
||||
//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
|
||||
));
|
||||
|
||||
@@ -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})";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user