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; namespace QtCNETAPI.Dtos.User
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Dtos.User
{ {
public class UserPasswordResetDto public class UserPasswordResetDto
{ {

View File

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

View File

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

View File

@ -1,16 +1,11 @@
using QtCNETAPI.Dtos.User; using QtCNETAPI.Dtos.User;
using QtCNETAPI.Models; using QtCNETAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QtCNETAPI.Events namespace QtCNETAPI.Events
{ {
public class DirectMessageEventArgs : EventArgs public class DirectMessageEventArgs : EventArgs
{ {
public required Message Message { get; set; } public required Message Message { get; set; }
public required UserInformationDto User { get; set; } public required UserInformationDto User { get; set; }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ namespace QtCNETAPI.Services.GatewayService
HubConnection.On("RefreshContactsList", () => OnRefreshContactsListReceived?.Invoke(this, EventArgs.Empty)); HubConnection.On("RefreshContactsList", () => OnRefreshContactsListReceived?.Invoke(this, EventArgs.Empty));
HubConnection.On<ServerConfig>("ReceiveServerConfig", (serverConfig) => OnServerConfigReceived?.Invoke(this, new ServerConfigEventArgs { ServerConfig = serverConfig })); HubConnection.On<ServerConfig>("ReceiveServerConfig", (serverConfig) => OnServerConfigReceived?.Invoke(this, new ServerConfigEventArgs { ServerConfig = serverConfig }));
HubConnection.On<Room, List<User>>("RoomUserList", (room, userList) => OnRoomUserListReceived?.Invoke(this, new RoomListEventArgs { Room = room, UserList = userList })); HubConnection.On<Room, List<User>>("RoomUserList", (room, userList) => OnRoomUserListReceived?.Invoke(this, new RoomListEventArgs { Room = room, UserList = userList }));
HubConnection.On<string>("GuestJoin", (username) => OnGuestUserJoin?.Invoke(this, new GuestUserJoinEventArgs { Username = username })); HubConnection.On<string>("GuestJoin", (username) => OnGuestUserJoin?.Invoke(this, new GuestUserJoinEventArgs { Username = username }));
HubConnection.On("RoomDeleted", () => OnRoomDeleted?.Invoke(this, EventArgs.Empty)); HubConnection.On("RoomDeleted", () => OnRoomDeleted?.Invoke(this, EventArgs.Empty));
HubConnection.On("ForceSignOut", () => OnUserForceLogout?.Invoke(this, EventArgs.Empty)); HubConnection.On("ForceSignOut", () => OnUserForceLogout?.Invoke(this, EventArgs.Empty));
HubConnection.On("UpdateCurrentUser", async () => await _apiService.SetCurrentUser()); HubConnection.On("UpdateCurrentUser", async () => await _apiService.SetCurrentUser());

View File

@ -1,12 +1,6 @@
using Microsoft.AspNetCore.SignalR.Client; using Microsoft.AspNetCore.SignalR.Client;
using QtCNETAPI.Dtos.User; using QtCNETAPI.Dtos.User;
using QtCNETAPI.Models; 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 namespace QtCNETAPI.Services.GatewayService
{ {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,4 @@
using Krypton.Toolkit; 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 namespace qtcnet_client.Controls
{ {

View File

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

View File

@ -1,12 +1,4 @@
using Krypton.Toolkit; 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 namespace qtcnet_client.Controls
{ {
@ -32,7 +24,7 @@ namespace qtcnet_client.Controls
private void btnRegister_Click(object sender, EventArgs e) private void btnRegister_Click(object sender, EventArgs e)
{ {
if(ValidateForm()) if (ValidateForm())
{ {
ToggleControls(false); ToggleControls(false);
@ -64,9 +56,9 @@ namespace qtcnet_client.Controls
private bool ValidateForm() private bool ValidateForm()
{ {
return !string.IsNullOrEmpty(txtEmail.Text) && return !string.IsNullOrEmpty(txtEmail.Text) &&
!string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtPassword.Text) &&
(txtConfirmEmail.Text == txtEmail.Text) && (txtConfirmEmail.Text == txtEmail.Text) &&
(txtConfirmPassword.Text == txtPassword.Text) && (txtConfirmPassword.Text == txtPassword.Text) &&
cbTOSAgree.Checked; cbTOSAgree.Checked;
} }

View File

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

View File

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

View File

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

View File

@ -1,14 +1,5 @@
using Krypton.Toolkit; using Krypton.Toolkit;
using QtCNETAPI.Models;
using QtCNETAPI.Services.ApiService; 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 namespace qtcnet_client.Forms
{ {
@ -78,9 +69,9 @@ namespace qtcnet_client.Forms
private async void dgUsers_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) 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"); KryptonMessageBox.Show("lol why would you delete yourself", "what");
e.Cancel = true; e.Cancel = true;
@ -95,7 +86,7 @@ namespace qtcnet_client.Forms
{ {
// delete the user // delete the user
var _apiRes = await _apiService.DeleteUserById(userId); var _apiRes = await _apiService.DeleteUserById(userId);
if(_apiRes.Success) if (_apiRes.Success)
AdminPanelForm_Load(sender, e); // refresh data AdminPanelForm_Load(sender, e); // refresh data
} }

View File

@ -1,14 +1,10 @@
using qtcnet_client.Controls; using qtcnet_client.Controls;
using qtcnet_client.Factories; using qtcnet_client.Factories;
using QtCNETAPI.Dtos.User; using QtCNETAPI.Dtos.User;
using QtCNETAPI.Events;
using QtCNETAPI.Models; using QtCNETAPI.Models;
using QtCNETAPI.Services.ApiService; using QtCNETAPI.Services.ApiService;
using QtCNETAPI.Services.GatewayService; using QtCNETAPI.Services.GatewayService;
using System.ComponentModel; using System.ComponentModel;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace qtcnet_client.Forms namespace qtcnet_client.Forms
{ {
public partial class ChatRoomForm : Form public partial class ChatRoomForm : Form
@ -18,7 +14,7 @@ namespace qtcnet_client.Forms
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string RoomName { get; set; } = "Room"; public string RoomName { get; set; } = "Room";
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Dictionary<string, Bitmap> UserProfileImages { get; set; } = []; public Dictionary<string, Bitmap> UserProfileImages { get; set; } = [];
public string SentMessage { get; private set; } = string.Empty; public string SentMessage { get; private set; } = string.Empty;
public event EventHandler? OnSend; public event EventHandler? OnSend;
@ -72,7 +68,7 @@ namespace qtcnet_client.Forms
public void AddUsersToRoomList(List<User> users) public void AddUsersToRoomList(List<User> users)
{ {
if(lvUsers.InvokeRequired) if (lvUsers.InvokeRequired)
{ {
lvUsers.Invoke(() => lvUsers.Invoke(() =>
{ {
@ -156,7 +152,7 @@ namespace qtcnet_client.Forms
private async Task<Bitmap?> AddUserProfileImageToDictionary(User user) 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; return image;
else else
{ {
@ -171,14 +167,15 @@ namespace qtcnet_client.Forms
messageCtrl.Width = flpMessages.ClientSize.Width - 10; messageCtrl.Width = flpMessages.ClientSize.Width - 10;
messageCtrl.Margin = new Padding(0, 0, 0, 6); messageCtrl.Margin = new Padding(0, 0, 0, 6);
if(flpMessages.InvokeRequired) if (flpMessages.InvokeRequired)
{ {
Invoke(() => Invoke(() =>
{ {
flpMessages.Controls.Add(messageCtrl); flpMessages.Controls.Add(messageCtrl);
flpMessages.ScrollControlIntoView(messageCtrl); flpMessages.ScrollControlIntoView(messageCtrl);
}); });
} else }
else
{ {
flpMessages.Controls.Add(messageCtrl); flpMessages.Controls.Add(messageCtrl);
flpMessages.ScrollControlIntoView(messageCtrl); flpMessages.ScrollControlIntoView(messageCtrl);

View File

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

View File

@ -1,15 +1,5 @@
using qtcnet_client.Services; using qtcnet_client.Services;
using QtCNETAPI.Services.ApiService; 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 namespace qtcnet_client.Forms.Games
{ {
@ -30,16 +20,16 @@ namespace qtcnet_client.Forms.Games
private async void btnGuess_Click(object sender, EventArgs e) private async void btnGuess_Click(object sender, EventArgs e)
{ {
if(nudNumberGuess.Value > 0) if (nudNumberGuess.Value > 0)
{ {
btnGuess.Enabled = false; btnGuess.Enabled = false;
int guess = int.Parse(nudNumberGuess.Value.ToString()); int guess = int.Parse(nudNumberGuess.Value.ToString());
var result = await _apiService.GuessRandomNumber(_number, guess); 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: case QtCNETAPI.Enums.NumberGuessResult.Higher:
lblResult.Text = "Your Guess Was Higher By 10! You've Earned A Jackpot Spin!"; 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 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 namespace qtcnet_client.Forms.Games
{ {
@ -63,7 +54,7 @@ namespace qtcnet_client.Forms.Games
private async void btnSell_Click(object sender, EventArgs e) private async void btnSell_Click(object sender, EventArgs e)
{ {
if(nudStockBuySellAmount.Value > 0) if (nudStockBuySellAmount.Value > 0)
{ {
nudStockBuySellAmount.Enabled = false; nudStockBuySellAmount.Enabled = false;
btnBuy.Enabled = false; btnBuy.Enabled = false;
@ -86,7 +77,8 @@ namespace qtcnet_client.Forms.Games
btnBuy.Enabled = true; btnBuy.Enabled = true;
btnSell.Enabled = true; btnSell.Enabled = true;
btnRefresh.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); 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; nudStockBuySellAmount.Enabled = true;

View File

@ -1,12 +1,9 @@
using Microsoft.AspNetCore.SignalR.Client; using Microsoft.AspNetCore.SignalR.Client;
using qtcnet_client.Forms; using qtcnet_client.Model;
using qtcnet_client.Services; using qtcnet_client.Services;
using QtCNETAPI.Enums; using QtCNETAPI.Enums;
using QtCNETAPI.Models;
using QtCNETAPI.Schema; using QtCNETAPI.Schema;
using QtCNETAPI.Services.ApiService; using QtCNETAPI.Services.ApiService;
using System.Threading.Tasks;
using qtcnet_client.Model;
namespace qtcnet_client.Forms.Games namespace qtcnet_client.Forms.Games
{ {
@ -103,8 +100,8 @@ namespace qtcnet_client.Forms.Games
} }
case GameStatus.P2Win: case GameStatus.P2Win:
{ {
if (_apiService.CurrentUser?.Id == room.Player2?.Id) if (_apiService.CurrentUser?.Id == room.Player2?.Id)
{ {
lblLoadStatus.Text = "You Won!"; lblLoadStatus.Text = "You Won!";
WinCount++; WinCount++;
@ -233,7 +230,7 @@ namespace qtcnet_client.Forms.Games
GameHubConnection.On<string>("ReceiveMessage", (msg) => GameHubConnection.On<string>("ReceiveMessage", (msg) =>
{ {
AddChatMessage(msg); AddChatMessage(msg);
if (msg.Split('[')[1] != _apiService.CurrentUser?.Username) if (msg.Split('[')[1] != _apiService.CurrentUser?.Username)
_audioService.PlaySoundEffect("sndMessage"); _audioService.PlaySoundEffect("sndMessage");
}); });
@ -252,7 +249,7 @@ namespace qtcnet_client.Forms.Games
{ {
if (GameHubConnection != null && GameHubConnection.State == HubConnectionState.Connected) if (GameHubConnection != null && GameHubConnection.State == HubConnectionState.Connected)
{ {
if(JackpotWon) if (JackpotWon)
{ {
// start a jackpot spin // start a jackpot spin
Random rnd = new(); Random rnd = new();
@ -345,7 +342,7 @@ namespace qtcnet_client.Forms.Games
private void rtxtChatbox_KeyDown(object sender, KeyEventArgs e) private void rtxtChatbox_KeyDown(object sender, KeyEventArgs e)
{ {
if(e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)
btnSend_Click(sender, e); btnSend_Click(sender, e);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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