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())
|
||||
@ -136,6 +110,34 @@ namespace bib_talk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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
|
||||
@ -163,4 +165,5 @@ namespace bib_talk
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user