Code Cleanup :D

This commit is contained in:
Alan Moon 2025-12-14 13:50:14 -08:00
parent 7899e1b091
commit f154e937d8
37 changed files with 112 additions and 295 deletions

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Dtos.User
namespace QtCNETAPI.Dtos.User
{
public class UserPasswordResetDto
{

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Enums
namespace QtCNETAPI.Enums
{
public enum NumberGuessResult
{

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
namespace QtCNETAPI.Events
{
public class ClientFunctionEventArgs : EventArgs
{

View File

@ -1,10 +1,5 @@
using QtCNETAPI.Dtos.User;
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
{

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
namespace QtCNETAPI.Events
{
public class GuestUserJoinEventArgs : EventArgs
{

View File

@ -1,9 +1,4 @@
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
{

View File

@ -1,9 +1,4 @@
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
{

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
namespace QtCNETAPI.Events
{
public class ServerConnectionClosedEventArgs : EventArgs
{

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
namespace QtCNETAPI.Events
{
public class ServerConnectionReconnectingEventArgs : EventArgs
{

View File

@ -1,9 +1,4 @@
using QtCNETAPI.Dtos.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events
{

View File

@ -4,7 +4,6 @@ using QtCNETAPI.Enums;
using QtCNETAPI.Models;
using QtCNETAPI.Schema;
using RestSharp;
using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;
using System.Text.Json;
@ -59,7 +58,8 @@ namespace QtCNETAPI.Services.ApiService
else serviceResponse.Success = true;
}
else serviceResponse.Success = false;
} catch (HttpRequestException ex)
}
catch (HttpRequestException ex)
{
serviceResponse.Success = false;
serviceResponse.Message = ex.Message;
@ -110,7 +110,8 @@ namespace QtCNETAPI.Services.ApiService
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API didn't respond with online users.";
@ -132,11 +133,12 @@ namespace QtCNETAPI.Services.ApiService
.AddQueryParameter("id", id);
var response = await _client.GetAsync<ServiceResponse<UserInformationDto>>(request);
if(response != null || response!.Data != null)
if (response != null || response!.Data != null)
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API did not return user information.";
@ -156,11 +158,12 @@ namespace QtCNETAPI.Services.ApiService
.AddHeader("Authorization", $"Bearer {SessionToken}");
var response = await _client.PutAsync<ServiceResponse<UserInformationDto>>(restRequest);
if(response != null || response!.Data != null)
if (response != null || response!.Data != null)
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API never responded.";
@ -191,11 +194,13 @@ namespace QtCNETAPI.Services.ApiService
serviceResponse.Success = false;
serviceResponse.Data = "Upload Failed.";
}
} catch (JsonException)
}
catch (JsonException)
{
serviceResponse.Success = false;
serviceResponse.Message = "Profile Pictures Can Only Be Less Then 3 MB In Size.";
} catch (HttpRequestException ex)
}
catch (HttpRequestException ex)
{
serviceResponse.Success = false;
serviceResponse.Data = ex.Message;
@ -225,7 +230,8 @@ namespace QtCNETAPI.Services.ApiService
}
return serviceResponse;
} catch (HttpRequestException ex)
}
catch (HttpRequestException ex)
{
serviceResponse.Success = false;
serviceResponse.Message = ex.Message;
@ -297,7 +303,8 @@ namespace QtCNETAPI.Services.ApiService
serviceResponse.Message = response.Message;
}
}
} catch (Exception ex)
}
catch (Exception ex)
{
serviceResponse.Success = false;
serviceResponse.Message = ex.Message;
@ -395,7 +402,8 @@ namespace QtCNETAPI.Services.ApiService
OnCurrentUserUpdate?.Invoke(this, EventArgs.Empty);
return userResponse.Data;
} else
}
else
{
throw new NullReferenceException("Current User could not be set.");
}
@ -437,7 +445,8 @@ namespace QtCNETAPI.Services.ApiService
serviceResponse.Success = false;
serviceResponse.Message = "API didn't respond with a session token.";
}
} catch (Exception ex)
}
catch (Exception ex)
{
serviceResponse.Success = false;
serviceResponse.Message = ex.Message;
@ -459,15 +468,17 @@ namespace QtCNETAPI.Services.ApiService
JwtSecurityToken token = tokenHandler.ReadJwtToken(SessionToken);
if(DateTime.Compare(DateTime.UtcNow, token.ValidTo) > 0)
if (DateTime.Compare(DateTime.UtcNow, token.ValidTo) > 0)
{
var result = await RefreshLogin(refToken);
if (result == null || result.Success == false)
{
return new ServiceResponse<string> { Success = false, Message = "Session Expired." }; // logging in again should overwrite old token
} else return new ServiceResponse<string> { Success = true, Data = refToken };
} else return new ServiceResponse<string> { Success = true, Data = refToken };
}
else return new ServiceResponse<string> { Success = true, Data = refToken };
}
else return new ServiceResponse<string> { Success = true, Data = refToken };
}
public async Task<ServiceResponse<User>> RegisterAsync(UserDto userDto)
@ -488,7 +499,8 @@ namespace QtCNETAPI.Services.ApiService
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API never responded with created user.";
@ -510,11 +522,12 @@ namespace QtCNETAPI.Services.ApiService
.AddHeader("Authorization", $"Bearer {SessionToken}");
var response = await _client.PostAsync<ServiceResponse<Room>>(restRequest);
if(response != null || response!.Data != null)
if (response != null || response!.Data != null)
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API never responded with created room.";
@ -529,7 +542,7 @@ namespace QtCNETAPI.Services.ApiService
var serviceResponse = new ServiceResponse<List<Room>>();
if(SessionToken == null) throw new NullReferenceException("Function Was Called Before A Session Was Made.");
if (SessionToken == null) throw new NullReferenceException("Function Was Called Before A Session Was Made.");
var request = new RestRequest("rooms/get-all-rooms")
.AddHeader("Authorization", $"Bearer {SessionToken}");
@ -555,7 +568,7 @@ namespace QtCNETAPI.Services.ApiService
var serviceResponse = new ServiceResponse<Room>();
if(SessionToken == null) throw new NullReferenceException("Function Was Called Before A Session Was Made.");
if (SessionToken == null) throw new NullReferenceException("Function Was Called Before A Session Was Made.");
var request = new RestRequest($"rooms/delete-room?roomId={roomId}")
.AddHeader("Authorization", $"Bearer {SessionToken}");
@ -565,7 +578,8 @@ namespace QtCNETAPI.Services.ApiService
{
serviceResponse.Success = true;
serviceResponse.Data = response.Data;
} else
}
else
{
serviceResponse.Success = false;
serviceResponse.Message = "API never responded.";

View File

@ -1,13 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using QtCNETAPI.Dtos.Room;
using QtCNETAPI.Dtos.User;
using QtCNETAPI.Dtos.Room;
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QtCNETAPI.Enums;
using QtCNETAPI.Models;
using QtCNETAPI.Schema;
namespace QtCNETAPI.Services.ApiService

View File

@ -1,12 +1,6 @@
using Microsoft.AspNetCore.SignalR.Client;
using QtCNETAPI.Dtos.User;
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Services.GatewayService
{

View File

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using System.Diagnostics;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Abstractions;
namespace QtCNETAPI.Services
{
@ -34,7 +28,8 @@ namespace QtCNETAPI.Services
{
Debug.WriteLine($"({DateTime.Now.ToLocalTime():hh:mm}) {message}");
LogFile.WriteLine($"({DateTime.Now.ToLocalTime():hh:mm}) {message}");
} catch (ObjectDisposedException)
}
catch (ObjectDisposedException)
{
}
}
@ -49,7 +44,8 @@ namespace QtCNETAPI.Services
// log it
Debug.WriteLine($"({DateTime.Now.ToLocalTime():hh:mm}) {modelSerialized}");
LogFile.WriteLine($"({DateTime.Now.ToLocalTime():hh:mm}) {modelSerialized}");
} catch (ObjectDisposedException)
}
catch (ObjectDisposedException)
{
}
}
@ -71,7 +67,8 @@ namespace QtCNETAPI.Services
// log it
Debug.WriteLine(message);
LogFile.WriteLine(message);
} catch (ObjectDisposedException)
}
catch (ObjectDisposedException)
{
}
}

View File

@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
namespace qtcnet_client.Controls
{
public partial class BrandingControl : UserControl
{

View File

@ -1,12 +1,6 @@
using qtcnet_client.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
{

View File

@ -1,11 +1,5 @@
using qtcnet_client.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
{
@ -46,7 +40,8 @@ namespace qtcnet_client.Controls
lblCurrencyAmount.Text = CurrencyCount.ToString();
pbCurrentProfilePic.Image = ProfileImage;
});
} else
}
else
{
lblUsername.Text = $"Welcome, {Username}!";
lblCurrencyAmount.Text = CurrencyCount.ToString();
@ -61,9 +56,9 @@ namespace qtcnet_client.Controls
private async void ctxStatus_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
int status = 0;
if(e.ClickedItem?.Tag is string _statusTag)
if (e.ClickedItem?.Tag is string _statusTag)
{
switch(_statusTag)
switch (_statusTag)
{
case "Invisible":
status = 0;

View File

@ -1,12 +1,4 @@
using Krypton.Toolkit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
{

View File

@ -1,14 +1,6 @@
using Krypton.Toolkit;
using qtcnet_client.Factories;
using qtcnet_client.Forms.Games;
using qtcnet_client.Factories;
using QtCNETAPI.Schema;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
{

View File

@ -1,12 +1,4 @@
using Krypton.Toolkit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Formats.Cbor;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Controls
{
@ -32,7 +24,7 @@ namespace qtcnet_client.Controls
private void btnRegister_Click(object sender, EventArgs e)
{
if(ValidateForm())
if (ValidateForm())
{
ToggleControls(false);

View File

@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace qtcnet_client.Controls
{

View File

@ -1,6 +1,4 @@
using qtcnet_client.Properties;
using QtCNETAPI.Models;
using QtCNETAPI.Schema;
using QtCNETAPI.Services.ApiService;
using System.Drawing.Drawing2D;
@ -23,7 +21,7 @@ namespace qtcnet_client.Factories
Bitmap img1 = Resources.DefaultPfp;
var _pfpTask = Task.Run(() => _apiService.GetUserProfilePic(userId));
var _pfpRes = _pfpTask.Result;
if(_pfpRes.Success && _pfpRes.Data != null)
if (_pfpRes.Success && _pfpRes.Data != null)
{
using var ms = new MemoryStream(_pfpRes.Data);
img1 = new Bitmap(ms);
@ -33,7 +31,7 @@ namespace qtcnet_client.Factories
Bitmap? img2 = null;
var _storeItemTask = Task.Run(() => _apiService.GetStoreItem(cosmeticStoreId));
var _storeItem = _storeItemTask.Result;
if(_storeItem.Success && _storeItem.Data != null)
if (_storeItem.Success && _storeItem.Data != null)
{
var _webTask = Task.Run(() => _http.GetAsync(_storeItem.Data.AssetUrl));
using var _webRes = _webTask.Result;
@ -43,7 +41,7 @@ namespace qtcnet_client.Factories
// status
Bitmap? img3 = null;
if(!int.IsNegative(status))
if (!int.IsNegative(status))
{
img3 = status switch
{
@ -62,7 +60,7 @@ namespace qtcnet_client.Factories
{
// get store item
var _item = await _apiService.GetStoreItem(id);
if(_item.Success && _item.Data != null)
if (_item.Success && _item.Data != null)
{
using var _http = new HttpClient();
using var _res = await _http.GetAsync(_item.Data.ThumbnailUrl);
@ -83,13 +81,13 @@ namespace qtcnet_client.Factories
g.DrawImage(img1, 4, 6, 128, 128);
if(img2 != null)
if (img2 != null)
{
img2.MakeTransparent();
g.DrawImage(img2, 0, 0, 139, 138);
}
if(img3 != null)
if (img3 != null)
{
img3.MakeTransparent();
g.DrawImage(img3, 104, 0, 35, 35);

View File

@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Forms
namespace qtcnet_client.Forms
{
public partial class AddRoomForm : Form
{
@ -18,7 +10,7 @@ namespace qtcnet_client.Forms
private void btnCreate_Click(object sender, EventArgs e)
{
if(!string.IsNullOrWhiteSpace(txtRoomName.Text))
if (!string.IsNullOrWhiteSpace(txtRoomName.Text))
{
RoomName = txtRoomName.Text;
DialogResult = DialogResult.OK;

View File

@ -1,14 +1,5 @@
using Krypton.Toolkit;
using QtCNETAPI.Models;
using QtCNETAPI.Services.ApiService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace qtcnet_client.Forms
{
@ -78,9 +69,9 @@ namespace qtcnet_client.Forms
private async void dgUsers_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
if(dgUsers.CurrentCell?.Value is string userId)
if (dgUsers.CurrentCell?.Value is string userId)
{
if(_apiService.CurrentUser?.Id == userId)
if (_apiService.CurrentUser?.Id == userId)
{
KryptonMessageBox.Show("lol why would you delete yourself", "what");
e.Cancel = true;
@ -95,7 +86,7 @@ namespace qtcnet_client.Forms
{
// delete the user
var _apiRes = await _apiService.DeleteUserById(userId);
if(_apiRes.Success)
if (_apiRes.Success)
AdminPanelForm_Load(sender, e); // refresh data
}

View File

@ -1,14 +1,10 @@
using qtcnet_client.Controls;
using qtcnet_client.Factories;
using QtCNETAPI.Dtos.User;
using QtCNETAPI.Events;
using QtCNETAPI.Models;
using QtCNETAPI.Services.ApiService;
using QtCNETAPI.Services.GatewayService;
using System.ComponentModel;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace qtcnet_client.Forms
{
public partial class ChatRoomForm : Form
@ -72,7 +68,7 @@ namespace qtcnet_client.Forms
public void AddUsersToRoomList(List<User> users)
{
if(lvUsers.InvokeRequired)
if (lvUsers.InvokeRequired)
{
lvUsers.Invoke(() =>
{
@ -156,7 +152,7 @@ namespace qtcnet_client.Forms
private async Task<Bitmap?> AddUserProfileImageToDictionary(User user)
{
if(UserProfileImages.TryGetValue(user.Id, out var image))
if (UserProfileImages.TryGetValue(user.Id, out var image))
return image;
else
{
@ -171,14 +167,15 @@ namespace qtcnet_client.Forms
messageCtrl.Width = flpMessages.ClientSize.Width - 10;
messageCtrl.Margin = new Padding(0, 0, 0, 6);
if(flpMessages.InvokeRequired)
if (flpMessages.InvokeRequired)
{
Invoke(() =>
{
flpMessages.Controls.Add(messageCtrl);
flpMessages.ScrollControlIntoView(messageCtrl);
});
} else
}
else
{
flpMessages.Controls.Add(messageCtrl);
flpMessages.ScrollControlIntoView(messageCtrl);

View File

@ -2,14 +2,7 @@
using qtcnet_client.Factories;
using qtcnet_client.Properties;
using QtCNETAPI.Dtos.User;
using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace qtcnet_client.Forms
{

View File

@ -1,15 +1,5 @@
using qtcnet_client.Services;
using QtCNETAPI.Services.ApiService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace qtcnet_client.Forms.Games
{
@ -30,16 +20,16 @@ namespace qtcnet_client.Forms.Games
private async void btnGuess_Click(object sender, EventArgs e)
{
if(nudNumberGuess.Value > 0)
if (nudNumberGuess.Value > 0)
{
btnGuess.Enabled = false;
int guess = int.Parse(nudNumberGuess.Value.ToString());
var result = await _apiService.GuessRandomNumber(_number, guess);
if(result != null && result.Success)
if (result != null && result.Success)
{
switch(result.Data)
switch (result.Data)
{
case QtCNETAPI.Enums.NumberGuessResult.Higher:
lblResult.Text = "Your Guess Was Higher By 10! You've Earned A Jackpot Spin!";

View File

@ -1,13 +1,4 @@
using QtCNETAPI.Services.ApiService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace qtcnet_client.Forms.Games
{
@ -63,7 +54,7 @@ namespace qtcnet_client.Forms.Games
private async void btnSell_Click(object sender, EventArgs e)
{
if(nudStockBuySellAmount.Value > 0)
if (nudStockBuySellAmount.Value > 0)
{
nudStockBuySellAmount.Enabled = false;
btnBuy.Enabled = false;
@ -86,7 +77,8 @@ namespace qtcnet_client.Forms.Games
btnBuy.Enabled = true;
btnSell.Enabled = true;
btnRefresh.Enabled = true;
} else
}
else
{
MessageBox.Show("Sell Failed. Either You Don't Have Enough Stock Or A Server Side Error Occured.", "Oops.", MessageBoxButtons.OK, MessageBoxIcon.Error);
nudStockBuySellAmount.Enabled = true;

View File

@ -1,12 +1,9 @@
using Microsoft.AspNetCore.SignalR.Client;
using qtcnet_client.Forms;
using qtcnet_client.Model;
using qtcnet_client.Services;
using QtCNETAPI.Enums;
using QtCNETAPI.Models;
using QtCNETAPI.Schema;
using QtCNETAPI.Services.ApiService;
using System.Threading.Tasks;
using qtcnet_client.Model;
namespace qtcnet_client.Forms.Games
{
@ -252,7 +249,7 @@ namespace qtcnet_client.Forms.Games
{
if (GameHubConnection != null && GameHubConnection.State == HubConnectionState.Connected)
{
if(JackpotWon)
if (JackpotWon)
{
// start a jackpot spin
Random rnd = new();
@ -345,7 +342,7 @@ namespace qtcnet_client.Forms.Games
private void rtxtChatbox_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
if (e.KeyCode == Keys.Enter)
btnSend_Click(sender, e);
}

View File

@ -1,7 +1,5 @@
using qtcnet_client.Services;
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace qtcnet_client.Forms
{

View File

@ -12,7 +12,6 @@ using QtCNETAPI.Services;
using QtCNETAPI.Services.ApiService;
using QtCNETAPI.Services.GatewayService;
using System.Drawing.Drawing2D;
using System.Threading.Tasks;
namespace qtcnet_client
{
@ -354,10 +353,10 @@ namespace qtcnet_client
private async void ProfileForm_OnMessageClicked(object? sender, EventArgs e)
{
if(sender is ProfileForm _profileForm)
if (sender is ProfileForm _profileForm)
{
var _userInfo = await _apiService.GetUserInformationAsync(_profileForm.UserId);
if(_userInfo.Success && _userInfo.Data != null)
if (_userInfo.Success && _userInfo.Data != null)
{
// create dm form
DirectMessageForm _dmForm = new(_imgFactory)
@ -543,7 +542,7 @@ namespace qtcnet_client
private void _gatewayService_OnServerReconnecting(object? sender, EventArgs e)
{
// disable interactive controls
if(InvokeRequired)
if (InvokeRequired)
{
Invoke(() =>
{
@ -560,7 +559,7 @@ namespace qtcnet_client
private async void _gatewayService_OnDirectMessageReceived(object? sender, EventArgs e)
{
if(e is DirectMessageEventArgs _args)
if (e is DirectMessageEventArgs _args)
{
// check for existing open form
var _existingForm = OpenDirectMessagesForms.FirstOrDefault(e => e.UserId == _args.User.Id);
@ -617,11 +616,11 @@ namespace qtcnet_client
private async void DirectMessage_OnSend(object? sender, EventArgs e)
{
if(sender is DirectMessageForm _dmForm)
if (sender is DirectMessageForm _dmForm)
{
// send message to user
var _userInfo = await _apiService.GetUserInformationAsync(_dmForm.UserId);
if(_userInfo.Success && _userInfo.Data != null)
if (_userInfo.Success && _userInfo.Data != null)
{
await _gatewayService.SendDirectMessageAsync(_userInfo.Data, new QtCNETAPI.Models.Message { Content = _dmForm.SentMessage });
@ -770,7 +769,7 @@ namespace qtcnet_client
Controls.Add(CurrentProfileControl);
Controls.Add(MainTabControl);
if(_apiService.CurrentUser.Role == "Admin")
if (_apiService.CurrentUser.Role == "Admin")
{
// create a link label that opens the admin panel when clicked
LinkLabel llblAdminPanel = new()
@ -835,7 +834,7 @@ namespace qtcnet_client
private async void _gatewayService_OnUserStatusUpdated(object? sender, EventArgs e)
{
if(e is UserStatusUpdatedEventArgs _args)
if (e is UserStatusUpdatedEventArgs _args)
{
CurrentProfileControl?.ProfileImage = _imgFactory.GetAndCreateProfileImage(_apiService.CurrentUser!.Id, _args.StatusDto!.Status, _apiService.CurrentUser!.ActiveProfileCosmetic);
}
@ -843,7 +842,7 @@ namespace qtcnet_client
private async void CurrentProfileControl_OnStatusChanged(object? sender, EventArgs e)
{
if(sender is CurrentProfileControl _ctrl)
if (sender is CurrentProfileControl _ctrl)
{
// set status based on selected
await _gatewayService.UpdateStatus(_ctrl.SelectedStatus);
@ -852,7 +851,7 @@ namespace qtcnet_client
private void MainTabControl_OnGameItemDoubleClicked(object? sender, EventArgs e)
{
if(sender is MainTabControl _ctrl)
if (sender is MainTabControl _ctrl)
{
string? gameSelected = (string?)_ctrl.SelectedGameItem?.Tag;

View File

@ -3,14 +3,7 @@ using qtcnet_client.Factories;
using qtcnet_client.Properties;
using QtCNETAPI.Models;
using QtCNETAPI.Services.ApiService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace qtcnet_client.Forms
{

View File

@ -1,13 +1,6 @@
using qtcnet_client.Properties;
using QtCNETAPI.Services.ApiService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace qtcnet_client.Forms
{
@ -39,7 +32,7 @@ namespace qtcnet_client.Forms
// check if user has item
var _res = await _apiService.GetOwnedStoreItem(ItemId);
if(_res.Success)
if (_res.Success)
{
btnBuy.Enabled = false;
btnBuy.Text = "Bought";

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
namespace qtcnet_client.Model
{

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
namespace qtcnet_client.Model
{

View File

@ -1,10 +1,7 @@
using qtcnet_client.Properties;
using qtcnet_client.Model;
using System;
using System.Collections.Generic;
using qtcnet_client.Model;
using qtcnet_client.Properties;
using System.Diagnostics;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
namespace qtcnet_client.Services