mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 12:32:03 -04:00
Initial commit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
126
KfChatDotNetGui/ViewModels/MainWindowViewModel.cs
Normal file
126
KfChatDotNetGui/ViewModels/MainWindowViewModel.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
KfChatDotNetGui/ViewModels/RoomSettingsWindowViewModel.cs
Normal file
20
KfChatDotNetGui/ViewModels/RoomSettingsWindowViewModel.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
8
KfChatDotNetGui/ViewModels/ViewModelBase.cs
Normal file
8
KfChatDotNetGui/ViewModels/ViewModelBase.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace KfChatDotNetGui.ViewModels
|
||||
{
|
||||
public class ViewModelBase : ReactiveObject
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user