83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using qtcnet_client.Properties;
|
|
using System.ComponentModel;
|
|
|
|
namespace qtcnet_client.Controls
|
|
{
|
|
public partial class CurrentProfileControl : UserControl
|
|
{
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
public string Username { get; set; } = "Username";
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
public int CurrencyCount { get; set; } = 0;
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
public Image ProfileImage { get; set; } = Resources.DefaultPfp;
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
public int SelectedStatus { get; set; } = 1;
|
|
|
|
public event EventHandler? OnEditProfileClicked;
|
|
public event EventHandler? OnSignOutClicked;
|
|
public event EventHandler? OnStatusChanged;
|
|
|
|
public CurrentProfileControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void CurrentProfileControl_Load(object sender, EventArgs e)
|
|
{
|
|
lblUsername.Text = $"Welcome, {Username}!";
|
|
lblCurrencyAmount.Text = CurrencyCount.ToString();
|
|
pbCurrentProfilePic.Image = ProfileImage;
|
|
}
|
|
|
|
public void RefreshInfo()
|
|
{
|
|
if (InvokeRequired)
|
|
{
|
|
Invoke(() =>
|
|
{
|
|
lblUsername.Text = $"Welcome, {Username}!";
|
|
lblCurrencyAmount.Text = CurrencyCount.ToString();
|
|
pbCurrentProfilePic.Image = ProfileImage;
|
|
});
|
|
}
|
|
else
|
|
{
|
|
lblUsername.Text = $"Welcome, {Username}!";
|
|
lblCurrencyAmount.Text = CurrencyCount.ToString();
|
|
pbCurrentProfilePic.Image = ProfileImage;
|
|
}
|
|
}
|
|
|
|
private void llblEditProfile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => OnEditProfileClicked?.Invoke(this, EventArgs.Empty);
|
|
|
|
private void llblSignOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => OnSignOutClicked?.Invoke(this, EventArgs.Empty);
|
|
|
|
private async void ctxStatus_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|
{
|
|
int status = 0;
|
|
if (e.ClickedItem?.Tag is string _statusTag)
|
|
{
|
|
switch (_statusTag)
|
|
{
|
|
case "Invisible":
|
|
status = 0;
|
|
break;
|
|
case "Online":
|
|
status = 1;
|
|
break;
|
|
case "Away":
|
|
status = 2;
|
|
break;
|
|
case "DoNotDisturb":
|
|
status = 3;
|
|
break;
|
|
}
|
|
|
|
SelectedStatus = status;
|
|
OnStatusChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|
|
}
|