2025-01-22 19:09:32 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Controls.Primitives;
|
|
|
|
using Avalonia.Input;
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Chapplication.Models;
|
|
|
|
|
|
|
|
namespace Chapplication;
|
|
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
{
|
|
|
|
|
|
|
|
private ObservableCollection<string> _messages = new();
|
|
|
|
|
|
|
|
public MainWindow()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
ChatBox.ItemsSource = _messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SubmitButton_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
SendMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ChatInputBox_OnKeyDown(object? sender, KeyEventArgs e)
|
|
|
|
{
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
{
|
|
|
|
SendMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SendMessage()
|
|
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(ChatInputBox.Text))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-01-22 19:20:45 +00:00
|
|
|
_messages.Add(ChatInputBox.Text);
|
|
|
|
ChatInputBox.Text = string.Empty;
|
|
|
|
ChatInputBox.Focus();
|
2025-01-22 19:09:32 +00:00
|
|
|
}
|
|
|
|
}
|