Initial commit

This commit is contained in:
barelyprofessional
2024-03-25 20:11:49 +08:00
commit 9f92fc8e27
62 changed files with 17831 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using System;
using ReactiveUI;
namespace KfChatDotNetGui.ViewModels;
public class IdentitySettingsWindowViewModel : ViewModelBase
{
private Uri _wsUri = new ("wss://kiwifarms.net/chat.ws");
public Uri WsUri
{
get => _wsUri;
set => this.RaiseAndSetIfChanged(ref _wsUri, value);
}
private string _xfSessionToken;
public string XfSessionToken
{
get => _xfSessionToken;
set => this.RaiseAndSetIfChanged(ref _xfSessionToken, value);
}
private string _antiDdosPow;
public string AntiDdosPow
{
get => _antiDdosPow;
set => this.RaiseAndSetIfChanged(ref _antiDdosPow, value);
}
private string _username;
public string Username
{
get => _username;
set => this.RaiseAndSetIfChanged(ref _username, value);
}
private int _reconnectTimeout = 30;
public int ReconnectTimeout
{
get => _reconnectTimeout;
set => this.RaiseAndSetIfChanged(ref _reconnectTimeout, value);
}
}

View File

@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Avalonia.Media;
using JetBrains.Annotations;
using KfChatDotNetGui.Models;
using ReactiveUI;
namespace KfChatDotNetGui.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public class InnerMessageViewModel : INotifyPropertyChanged
{
private string _message;
public string Message
{
get => _message;
set
{
if (_message == value) return;
_message = value;
OnPropertyChanged();
}
}
private bool _isHighlighted = false;
public bool IsHighlighted
{
get => _isHighlighted;
set
{
if (_isHighlighted == value) return;
_isHighlighted = value;
OnPropertyChanged();
}
}
public int MessageId { get; set; }
public bool OwnMessage { get; set; }
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class MessageViewModel : INotifyPropertyChanged
{
private ObservableCollection<InnerMessageViewModel> _messages;
public ObservableCollection<InnerMessageViewModel> Messages
{
get => _messages;
set
{
if (_messages == value) return;
_messages = value;
OnPropertyChanged();
}
}
public DateTimeOffset PostedAt { get; set; }
public string Author { get; set; }
public int AuthorId { get; set; }
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class UserListViewModel
{
public string Name { get; set; }
public int Id { get; set; }
}
private string _statusText = "Not connected";
public string Status
{
get => _statusText;
set => this.RaiseAndSetIfChanged(ref _statusText, value);
}
private int _userId;
public int UserId
{
get => _userId;
set => this.RaiseAndSetIfChanged(ref _userId, value);
}
private List<RoomSettingsModel.RoomList> _roomList = new();
public List<RoomSettingsModel.RoomList> RoomList
{
get => _roomList;
set => this.RaiseAndSetIfChanged(ref _roomList, value);
}
private ObservableCollection<UserListViewModel> _userList = new();
public ObservableCollection<UserListViewModel> UserList
{
get => _userList;
set => this.RaiseAndSetIfChanged(ref _userList, value);
}
private ObservableCollection<MessageViewModel> _messages = new();
public ObservableCollection<MessageViewModel> Messages
{
get => _messages;
set => this.RaiseAndSetIfChanged(ref _messages, value);
}
}
}

View File

@@ -0,0 +1,20 @@
using System.Collections.ObjectModel;
using KfChatDotNetGui.Models;
using ReactiveUI;
namespace KfChatDotNetGui.ViewModels;
public class RoomSettingsWindowViewModel : ViewModelBase
{
private ObservableCollection<RoomSettingsModel.RoomList> _roomList = new()
{
new RoomSettingsModel.RoomList {Id = 1, Name = "General"}
};
public ObservableCollection<RoomSettingsModel.RoomList> RoomList
{
get => _roomList;
set => this.RaiseAndSetIfChanged(ref _roomList, value);
}
}

View File

@@ -0,0 +1,8 @@
using ReactiveUI;
namespace KfChatDotNetGui.ViewModels
{
public class ViewModelBase : ReactiveObject
{
}
}