52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
|
using Avalonia.Media;
|
|||
|
using CollabVMSharp;
|
|||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace CollabVMClient.ViewModels
|
|||
|
{
|
|||
|
internal partial class UserViewModel : ViewModelBase
|
|||
|
{
|
|||
|
[ObservableProperty] private string username;
|
|||
|
private Rank rank;
|
|||
|
private TurnStatus turn;
|
|||
|
|
|||
|
public IBrush Foreground => rank switch
|
|||
|
{
|
|||
|
Rank.Unregistered => Brush.Parse("Black"),
|
|||
|
Rank.Moderator => Brush.Parse("Green"),
|
|||
|
Rank.Admin => Brush.Parse("Red"),
|
|||
|
};
|
|||
|
|
|||
|
[ObservableProperty] private IBrush background;
|
|||
|
|
|||
|
public void Rename(string newName)
|
|||
|
{
|
|||
|
Username = newName;
|
|||
|
}
|
|||
|
|
|||
|
public UserViewModel(string username, Rank rank)
|
|||
|
{
|
|||
|
Username = username;
|
|||
|
this.rank = rank;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void SetTurnStatus(TurnStatus turn)
|
|||
|
{
|
|||
|
this.turn = turn;
|
|||
|
Background = turn switch
|
|||
|
{
|
|||
|
TurnStatus.None => Brush.Parse("White"),
|
|||
|
TurnStatus.Waiting => Brush.Parse("Yellow"),
|
|||
|
TurnStatus.HasTurn => Brush.Parse("SkyBlue"),
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
}
|