Implement Daily Jackpot Spin
Fix Profile Form Not Resizing With Username Length
This commit is contained in:
parent
4e3a057177
commit
1e220a23a1
@ -414,63 +414,7 @@ namespace qtcnet_client
|
||||
KryptonMessageBox.Show("The Server Has Logged You Out. Please Try Signing In Again.", "Uh Oh.",
|
||||
KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.Error);
|
||||
|
||||
var _res = await _apiService.LogoutAsync();
|
||||
if(_res)
|
||||
{
|
||||
_credentialService.DeleteAccessToken();
|
||||
|
||||
SuspendLayout();
|
||||
|
||||
// remove controls
|
||||
Controls.Remove(MainTabControl);
|
||||
Controls.Remove(CurrentProfileControl);
|
||||
|
||||
// dispose of them
|
||||
MainTabControl?.Dispose();
|
||||
MainTabControl = null;
|
||||
CurrentProfileControl?.Dispose();
|
||||
CurrentProfileControl = null;
|
||||
|
||||
// readd login control and branding
|
||||
Size = LoggedOutSize;
|
||||
|
||||
// unsub from gateway events
|
||||
|
||||
_gatewayService.OnServerReconnecting -= _gatewayService_OnServerReconnecting;
|
||||
_gatewayService.OnServerReconnected -= _gatewayService_OnServerReconnected;
|
||||
_gatewayService.OnServerDisconnect -= _gatewayService_OnServerDisconnect;
|
||||
//_gatewayService.OnDirectMessageReceived -= _gatewayService_OnDirectMessageReceived;
|
||||
_gatewayService.OnRoomMessageReceived -= _gatewayService_OnRoomMessageReceived;
|
||||
_gatewayService.OnRoomUserListReceived -= _gatewayService_OnRoomUserListReceived;
|
||||
_gatewayService.OnRefreshUserListsReceived -= _gatewayService_OnRefreshUserListReceived;
|
||||
_gatewayService.OnRefreshRoomListReceived -= _gatewayService_OnRefreshRoomListReceived;
|
||||
_gatewayService.OnRefreshContactsListReceived -= _gatewayService_OnRefreshContactsListReceived;
|
||||
_gatewayService.OnServerConfigReceived -= _gatewayService_OnServerConfigReceived;
|
||||
_gatewayService.OnUserForceLogout -= _gatewayService_OnUserForceLogout;
|
||||
|
||||
// stop gateway connection
|
||||
await _gatewayService.StopAsync();
|
||||
|
||||
// add branding control
|
||||
BrandingControl = new()
|
||||
{
|
||||
Location = new(-2, -17),
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Left
|
||||
};
|
||||
|
||||
// add login control
|
||||
LoginControl = new()
|
||||
{
|
||||
Location = new(12, 233)
|
||||
};
|
||||
LoginControl.OnSuccessfulLogin += LoginControl_OnSuccessfulLogin;
|
||||
LoginControl.OnRegisterPressed += LoginControl_OnRegisterPressed;
|
||||
|
||||
Controls.Add(BrandingControl);
|
||||
Controls.Add(LoginControl);
|
||||
|
||||
ResumeLayout(true);
|
||||
}
|
||||
LogoutAsync();
|
||||
}
|
||||
|
||||
private void _gatewayService_OnServerConfigReceived(object? sender, EventArgs e)
|
||||
@ -688,6 +632,30 @@ namespace qtcnet_client
|
||||
Controls.Add(MainTabControl);
|
||||
|
||||
ResumeLayout(true);
|
||||
|
||||
// check for daily spin eligibility
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
var lastSpin = _apiService.CurrentUser.LastCurrencySpin;
|
||||
if(lastSpin.Date < now.Date)
|
||||
{
|
||||
Random rnd = new();
|
||||
|
||||
JackpotSpinForm _jackpotSpin = new()
|
||||
{
|
||||
CurrencyWon = rnd.Next(0, 500)
|
||||
};
|
||||
var _dialogRes = _jackpotSpin.ShowDialog();
|
||||
if(_dialogRes == DialogResult.OK)
|
||||
{
|
||||
// claim
|
||||
var _apiRes = await _apiService.AddCurrencyToCurrentUser(_jackpotSpin.CurrencyWon, true);
|
||||
if (_apiRes.Success)
|
||||
_jackpotSpin.Dispose();
|
||||
else
|
||||
KryptonMessageBox.Show("We Couldn't Claim Your Prize At This Time. You Should Be Able To Spin Again Next Restart.", "Uh Oh.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -698,16 +666,11 @@ namespace qtcnet_client
|
||||
}
|
||||
}
|
||||
|
||||
private async void CurrentProfileControl_OnSignOutClicked(object? sender, EventArgs e)
|
||||
{
|
||||
var _dialogRes = KryptonMessageBox.Show("Doing This Will Sign You Out. Are You Sure?", "are you sure...?",
|
||||
KryptonMessageBoxButtons.YesNo, KryptonMessageBoxIcon.Question);
|
||||
|
||||
if (_dialogRes == DialogResult.Yes)
|
||||
private async void LogoutAsync()
|
||||
{
|
||||
var _res = await _apiService.LogoutAsync();
|
||||
|
||||
if(_res)
|
||||
if (_res)
|
||||
{
|
||||
_credentialService.DeleteAccessToken();
|
||||
|
||||
@ -764,6 +727,14 @@ namespace qtcnet_client
|
||||
ResumeLayout(true);
|
||||
}
|
||||
}
|
||||
|
||||
private async void CurrentProfileControl_OnSignOutClicked(object? sender, EventArgs e)
|
||||
{
|
||||
var _dialogRes = KryptonMessageBox.Show("Doing This Will Sign You Out. Are You Sure?", "are you sure...?",
|
||||
KryptonMessageBoxButtons.YesNo, KryptonMessageBoxIcon.Question);
|
||||
|
||||
if (_dialogRes == DialogResult.Yes)
|
||||
LogoutAsync();
|
||||
}
|
||||
|
||||
private async void CurrentProfileControl_OnEditProfileClicked(object? sender, EventArgs e)
|
||||
|
||||
10
qtcnet-client/Forms/ProfileForm.Designer.cs
generated
10
qtcnet-client/Forms/ProfileForm.Designer.cs
generated
@ -119,16 +119,17 @@
|
||||
// tlpUsernameTags
|
||||
//
|
||||
tlpUsernameTags.AutoSize = true;
|
||||
tlpUsernameTags.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
tlpUsernameTags.ColumnCount = 2;
|
||||
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
||||
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle());
|
||||
tlpUsernameTags.ColumnStyles.Add(new ColumnStyle());
|
||||
tlpUsernameTags.Controls.Add(lblUsername, 0, 0);
|
||||
tlpUsernameTags.Controls.Add(tlpTagIcons, 1, 0);
|
||||
tlpUsernameTags.Location = new Point(115, 11);
|
||||
tlpUsernameTags.Name = "tlpUsernameTags";
|
||||
tlpUsernameTags.RowCount = 1;
|
||||
tlpUsernameTags.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
|
||||
tlpUsernameTags.Size = new Size(304, 55);
|
||||
tlpUsernameTags.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tlpUsernameTags.Size = new Size(303, 55);
|
||||
tlpUsernameTags.TabIndex = 6;
|
||||
//
|
||||
// lblUsername
|
||||
@ -184,6 +185,7 @@
|
||||
Controls.Add(rtxtBio);
|
||||
Controls.Add(lblStatus);
|
||||
Controls.Add(pbProfileImage);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
Name = "ProfileForm";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
|
||||
@ -49,6 +49,8 @@ namespace qtcnet_client.Forms
|
||||
rtxtBio.Text = Bio;
|
||||
pbProfileImage.Image = ProfileImage;
|
||||
|
||||
ResizeFormToUsername();
|
||||
|
||||
if (Status == 0) lblStatus.Visible = false;
|
||||
|
||||
if (UserId == _apiService.CurrentUser?.Id)
|
||||
@ -202,7 +204,7 @@ namespace qtcnet_client.Forms
|
||||
{
|
||||
Text = lblUsername.Text,
|
||||
Font = lblUsername.Font,
|
||||
MaxLength = 16,
|
||||
MaxLength = 25,
|
||||
Dock = lblUsername.Dock,
|
||||
Location = lblUsername.Location,
|
||||
Size = lblUsername.Size,
|
||||
@ -220,6 +222,7 @@ namespace qtcnet_client.Forms
|
||||
lblUsername.Text = txtUsernameEdit.Text;
|
||||
tlpUsernameTags.Controls.Remove(txtUsernameEdit);
|
||||
txtUsernameEdit.Dispose();
|
||||
ResizeFormToUsername();
|
||||
lblUsername.Visible = true;
|
||||
}
|
||||
}
|
||||
@ -294,5 +297,15 @@ namespace qtcnet_client.Forms
|
||||
pbProfileImage.Cursor = Cursors.Default;
|
||||
pbProfileImage.Invalidate();
|
||||
}
|
||||
|
||||
private void ResizeFormToUsername()
|
||||
{
|
||||
int padding = 40;
|
||||
int minWidth = 445;
|
||||
int newWidth = lblUsername.Right + padding;
|
||||
|
||||
if (newWidth > minWidth)
|
||||
Width = newWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user