Changes ChatMessage.msg to Content, Fixed Xaml, removes stringTimeStamp
This commit is contained in:
@@ -30,8 +30,8 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="auto"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Margin="0 0 8 0" Text="Connect to" Foreground="{ThemeResource SystemColorDisabledTextColor}"/>
|
<TextBlock Margin="0 0 8 0" Text="Connect to" Foreground="{ThemeResource SystemColorDisabledTextColor}"/>
|
||||||
<TextBlock x:Name="ipAddress" Grid.Column="1"/>
|
<TextBlock x:Name="ipAddress" Grid.Column="1"/>
|
||||||
@@ -98,8 +98,8 @@
|
|||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="models:ChatMessage">
|
<DataTemplate x:DataType="models:ChatMessage">
|
||||||
<StackPanel x:Name="Message" Margin="0 4" Padding="16 8" CornerRadius="4" Background="{ThemeResource SystemAccentColor}">
|
<StackPanel x:Name="Message" Margin="0 4" Padding="16 8" CornerRadius="4" Background="{ThemeResource SystemAccentColor}">
|
||||||
<TextBlock Text="{x:Bind Msg}"/>
|
<TextBlock Text="{x:Bind Content}"/>
|
||||||
<TextBlock Text="{x:Bind StringTimeStamp}"/>
|
<TextBlock Text="{x:Bind Timestamp.ToShortDateString()}"/>
|
||||||
<TextBlock Text="{x:Bind Foreign}"/>
|
<TextBlock Text="{x:Bind Foreign}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace PolyChat
|
|||||||
networkingController = new NetworkingController(this);
|
networkingController = new NetworkingController(this);
|
||||||
|
|
||||||
Partners = new ObservableCollection<ChatPartner>();
|
Partners = new ObservableCollection<ChatPartner>();
|
||||||
//ipAddress.Text = IP.GetCodeFromIP(Controller.GetIP());
|
ipAddress.Text = IP.GetCodeFromIP(networkingController.getIP().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnChatPartnerSelected(object sender, RoutedEventArgs e)
|
public void OnChatPartnerSelected(object sender, RoutedEventArgs e)
|
||||||
@@ -58,7 +58,7 @@ namespace PolyChat
|
|||||||
string ip = dialog.getValue();
|
string ip = dialog.getValue();
|
||||||
if (IP.ValidateIP(ip))
|
if (IP.ValidateIP(ip))
|
||||||
{
|
{
|
||||||
Controller.Connect(ip);
|
networkingController.connectNewClient(ip);
|
||||||
Partners.Add(new ChatPartner(
|
Partners.Add(new ChatPartner(
|
||||||
"Connecting...",
|
"Connecting...",
|
||||||
ip
|
ip
|
||||||
@@ -83,7 +83,7 @@ namespace PolyChat
|
|||||||
{
|
{
|
||||||
ChatPartner sendingPartner = Partners.First(p => p.Code == message.Ip);
|
ChatPartner sendingPartner = Partners.First(p => p.Code == message.Ip);
|
||||||
sendingPartner.AddMessage(new ChatMessage(
|
sendingPartner.AddMessage(new ChatMessage(
|
||||||
message.Msg,
|
message.Content,
|
||||||
true,
|
true,
|
||||||
message.Sender
|
message.Sender
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -6,17 +6,15 @@ namespace PolyChat.Models
|
|||||||
{
|
{
|
||||||
public readonly string Sender;
|
public readonly string Sender;
|
||||||
public readonly DateTime Timestamp = new DateTime(1970, 01, 01);
|
public readonly DateTime Timestamp = new DateTime(1970, 01, 01);
|
||||||
public readonly string Msg = "empty";
|
public readonly string Content;
|
||||||
public readonly string Ip;
|
public readonly string Ip;
|
||||||
public readonly bool Foreign;
|
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.Sender = Sender;
|
||||||
this.Timestamp = DateTime.Now;
|
this.Timestamp = DateTime.Now;
|
||||||
StringTimeStamp = Timestamp.ToString();
|
this.Content = Content;
|
||||||
this.Msg = Msg;
|
|
||||||
this.Foreign = Foreign;
|
this.Foreign = Foreign;
|
||||||
this.Ip = Ip;
|
this.Ip = Ip;
|
||||||
}
|
}
|
||||||
@@ -25,7 +23,7 @@ namespace PolyChat.Models
|
|||||||
public string ToString()
|
public string ToString()
|
||||||
{
|
{
|
||||||
string prefix = Foreign ? "Other" : "Me";
|
string prefix = Foreign ? "Other" : "Me";
|
||||||
return $"{prefix}: {Msg}({Sender})";
|
return $"{prefix}: {Content}({Sender})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user