Enter hinzugefügt
Enter in Chatleiste hinzugefügt und Button entfernt
This commit is contained in:
parent
696e4eeb03
commit
5197504128
@ -112,8 +112,7 @@
|
||||
Margin="244,642,154,10"
|
||||
Background="#FF323134"
|
||||
Foreground="White"
|
||||
SelectionBrush="#FF6332A0"/>
|
||||
<Button x:Name="weiterbutton" Click="send_Click" Content="Weiter" Foreground="White" Background="#FF6332A0" BorderThickness="0" Margin="831,642,44,10" BorderBrush="{x:Null}" Style="{StaticResource NoHoverButtonStyle}" RenderTransformOrigin="0.279,0.633"/>
|
||||
SelectionBrush="#FF6332A0" KeyDown="messageBOX_KeyDown"/>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
@ -82,32 +82,6 @@ namespace bib_talk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void send_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(messageBOX.Text))
|
||||
{
|
||||
var message = new MessageDto
|
||||
{
|
||||
Username = loggedinUser,
|
||||
Message = messageBOX.Text,
|
||||
Timestamp = DateTime.Now,
|
||||
};
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(message);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
messageBOX.Clear();
|
||||
LoadMessages(); // Reload messages after sending
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private async void LogoutUser()
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
@ -120,7 +94,7 @@ namespace bib_talk
|
||||
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
this.Close();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
private async void LoadOnlineUsers()
|
||||
@ -136,31 +110,60 @@ namespace bib_talk
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Message
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Text { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
private async void messageBOX_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(messageBOX.Text))
|
||||
{
|
||||
var message = new MessageDto
|
||||
{
|
||||
Username = loggedinUser,
|
||||
Message = messageBOX.Text,
|
||||
Timestamp = DateTime.Now,
|
||||
};
|
||||
|
||||
public class MessageDto
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Birthday { get; set; }
|
||||
public string IsOnline { get; set; }
|
||||
}
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(message);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
messageBOX.Clear();
|
||||
LoadMessages(); // Reload messages after sending
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Message
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Text { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
|
||||
public class MessageDto
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Birthday { get; set; }
|
||||
public string IsOnline { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user