mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
|
|
namespace Remotely.Desktop.UI.Views;
|
|
|
|
public partial class ChatWindow : Window
|
|
{
|
|
public ChatWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Closed += ChatWindow_Closed;
|
|
Opened += ChatWindow_Opened;
|
|
|
|
InputTextBox.KeyUp += ChatWindow_KeyUp;
|
|
MessagesListBox.Loaded += MessageListBox_Loaded;
|
|
}
|
|
|
|
private void ChatWindow_Closed(object? sender, EventArgs e)
|
|
{
|
|
Environment.Exit(0);
|
|
}
|
|
|
|
private async void ChatWindow_KeyUp(object? sender, Avalonia.Input.KeyEventArgs e)
|
|
{
|
|
if (e.Key == Avalonia.Input.Key.Enter &&
|
|
DataContext is ChatWindowViewModel viewModel)
|
|
{
|
|
await viewModel.SendChatMessage();
|
|
}
|
|
}
|
|
|
|
|
|
private void ChatWindow_Opened(object? sender, EventArgs e)
|
|
{
|
|
Topmost = false;
|
|
}
|
|
|
|
private async void MessageListBox_Loaded(object? sender, RoutedEventArgs e)
|
|
{
|
|
// Allows listbox height to adjust to content before scrolling the scrollviewer.
|
|
await Task.Delay(1);
|
|
MessagesScrollViewer.ScrollToEnd();
|
|
}
|
|
}
|