first commit

This commit is contained in:
Digi
2025-02-23 20:09:12 +01:00
commit f3da4b9c3e
175 changed files with 2729 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using YapperClient.MVVM.Core;
using YapperClient.MVVM.Model;
using YapperClient.Net;
namespace YapperClient.MVVM.ViewModel
{
class MainViewModel
{
public ObservableCollection<UserModel> Users { get; set; }
public RelayCommand ConnectToServerCommand { get; set; }
public string UserName { get; set; }
private Server _server;
public MainViewModel() {
Users = new ObservableCollection<UserModel>();
_server = new Server();
_server.connectedEvent += UserConnected;
ConnectToServerCommand = new RelayCommand(o => _server.ConnectToServer(UserName), o => !string.IsNullOrEmpty(UserName));
}
private void UserConnected()
{
var user = new UserModel
{
UserName = _server.PacketReader.ReadMessage(),
UID = _server.PacketReader.ReadMessage(),
};
if (!Users.Any(x => x.UID == user.UID))
{
Application.Current.Dispatcher.Invoke(() => Users.Add(user));
}
}
}
}