From f154e937d8b2f31667ee3b47ffdc3109f62feca9 Mon Sep 17 00:00:00 2001 From: Moonbase Date: Sun, 14 Dec 2025 13:50:14 -0800 Subject: [PATCH] Code Cleanup :D --- QtCNETAPI/Dtos/User/UserPasswordResetDto.cs | 8 +-- QtCNETAPI/Enums/NumberGuessResult.cs | 8 +-- QtCNETAPI/Events/ClientFunctionEventArgs.cs | 8 +-- QtCNETAPI/Events/DirectMessageEventArgs.cs | 7 +-- QtCNETAPI/Events/GuestUserJoinEventArgs.cs | 8 +-- QtCNETAPI/Events/RoomListEventArgs.cs | 5 -- QtCNETAPI/Events/ServerConfigEventArgs.cs | 5 -- .../Events/ServerConnectionClosedEventArgs.cs | 8 +-- .../ServerConnectionReconnectingEventArgs.cs | 8 +-- .../Events/UserStatusUpdatedEventArgs.cs | 5 -- QtCNETAPI/Services/ApiService/ApiService.cs | 62 ++++++++++++------- QtCNETAPI/Services/ApiService/IApiService.cs | 10 +-- .../Services/GatewayService/GatewayService.cs | 2 +- .../GatewayService/IGatewayService.cs | 6 -- QtCNETAPI/Services/LoggingService.cs | 17 +++-- qtcnet-client/Controls/BrandingControl.cs | 10 +-- qtcnet-client/Controls/ContactControl.cs | 6 -- .../Controls/CurrentProfileControl.cs | 15 ++--- qtcnet-client/Controls/LoginControl.cs | 8 --- qtcnet-client/Controls/MainTabControl.cs | 10 +-- qtcnet-client/Controls/RegisterControl.cs | 16 ++--- qtcnet-client/Controls/RoomControl.cs | 9 +-- qtcnet-client/Factories/ImageFactory.cs | 16 +++-- qtcnet-client/Forms/AddRoomForm.cs | 12 +--- qtcnet-client/Forms/AdminPanelForm.cs | 15 +---- qtcnet-client/Forms/ChatRoomForm.cs | 15 ++--- qtcnet-client/Forms/DirectMessageForm.cs | 7 --- qtcnet-client/Forms/Games/GuessTheNumber.cs | 16 +---- qtcnet-client/Forms/Games/StockMarketGame.cs | 14 +---- qtcnet-client/Forms/Games/TicTacToeGame.cs | 15 ++--- qtcnet-client/Forms/JackpotSpinForm.cs | 2 - qtcnet-client/Forms/MainForm.cs | 21 +++---- qtcnet-client/Forms/ProfileForm.cs | 7 --- qtcnet-client/Forms/StoreItemForm.cs | 9 +-- qtcnet-client/Model/ClientConfig.cs | 5 +- qtcnet-client/Model/ClientUpdateInfo.cs | 5 +- qtcnet-client/Services/UpdateService.cs | 7 +-- 37 files changed, 112 insertions(+), 295 deletions(-) diff --git a/QtCNETAPI/Dtos/User/UserPasswordResetDto.cs b/QtCNETAPI/Dtos/User/UserPasswordResetDto.cs index 3436077..68c9651 100644 --- a/QtCNETAPI/Dtos/User/UserPasswordResetDto.cs +++ b/QtCNETAPI/Dtos/User/UserPasswordResetDto.cs @@ -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 { diff --git a/QtCNETAPI/Enums/NumberGuessResult.cs b/QtCNETAPI/Enums/NumberGuessResult.cs index 6fa3d20..8574d50 100644 --- a/QtCNETAPI/Enums/NumberGuessResult.cs +++ b/QtCNETAPI/Enums/NumberGuessResult.cs @@ -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 { diff --git a/QtCNETAPI/Events/ClientFunctionEventArgs.cs b/QtCNETAPI/Events/ClientFunctionEventArgs.cs index 53847ff..95c52d8 100644 --- a/QtCNETAPI/Events/ClientFunctionEventArgs.cs +++ b/QtCNETAPI/Events/ClientFunctionEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/DirectMessageEventArgs.cs b/QtCNETAPI/Events/DirectMessageEventArgs.cs index 581aef7..066d144 100644 --- a/QtCNETAPI/Events/DirectMessageEventArgs.cs +++ b/QtCNETAPI/Events/DirectMessageEventArgs.cs @@ -1,16 +1,11 @@ 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 { public class DirectMessageEventArgs : EventArgs { public required Message Message { get; set; } - public required UserInformationDto User { get; set; } + public required UserInformationDto User { get; set; } } } diff --git a/QtCNETAPI/Events/GuestUserJoinEventArgs.cs b/QtCNETAPI/Events/GuestUserJoinEventArgs.cs index 3318a50..cfe7490 100644 --- a/QtCNETAPI/Events/GuestUserJoinEventArgs.cs +++ b/QtCNETAPI/Events/GuestUserJoinEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/RoomListEventArgs.cs b/QtCNETAPI/Events/RoomListEventArgs.cs index b8b680c..d9e83f7 100644 --- a/QtCNETAPI/Events/RoomListEventArgs.cs +++ b/QtCNETAPI/Events/RoomListEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/ServerConfigEventArgs.cs b/QtCNETAPI/Events/ServerConfigEventArgs.cs index 862d443..8df6357 100644 --- a/QtCNETAPI/Events/ServerConfigEventArgs.cs +++ b/QtCNETAPI/Events/ServerConfigEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/ServerConnectionClosedEventArgs.cs b/QtCNETAPI/Events/ServerConnectionClosedEventArgs.cs index 0c25439..bda282f 100644 --- a/QtCNETAPI/Events/ServerConnectionClosedEventArgs.cs +++ b/QtCNETAPI/Events/ServerConnectionClosedEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/ServerConnectionReconnectingEventArgs.cs b/QtCNETAPI/Events/ServerConnectionReconnectingEventArgs.cs index dd43f65..be5e5f5 100644 --- a/QtCNETAPI/Events/ServerConnectionReconnectingEventArgs.cs +++ b/QtCNETAPI/Events/ServerConnectionReconnectingEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Events/UserStatusUpdatedEventArgs.cs b/QtCNETAPI/Events/UserStatusUpdatedEventArgs.cs index 3343d5f..28de0be 100644 --- a/QtCNETAPI/Events/UserStatusUpdatedEventArgs.cs +++ b/QtCNETAPI/Events/UserStatusUpdatedEventArgs.cs @@ -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 { diff --git a/QtCNETAPI/Services/ApiService/ApiService.cs b/QtCNETAPI/Services/ApiService/ApiService.cs index 72ba014..5cc6a56 100644 --- a/QtCNETAPI/Services/ApiService/ApiService.cs +++ b/QtCNETAPI/Services/ApiService/ApiService.cs @@ -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,12 +58,13 @@ 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; } - + return serviceResponse; } @@ -106,11 +106,12 @@ namespace QtCNETAPI.Services.ApiService .AddHeader("Authorization", $"Bearer {SessionToken}"); var response = await _client.GetAsync>>(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 didn't respond with online users."; @@ -132,11 +133,12 @@ namespace QtCNETAPI.Services.ApiService .AddQueryParameter("id", id); var response = await _client.GetAsync>(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>(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 { Success = false, Message = "Session Expired." }; // logging in again should overwrite old token - } else return new ServiceResponse { Success = true, Data = refToken }; - } else return new ServiceResponse { Success = true, Data = refToken }; + } + else return new ServiceResponse { Success = true, Data = refToken }; + } + else return new ServiceResponse { Success = true, Data = refToken }; } public async Task> 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>(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>(); - 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(); - 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."; diff --git a/QtCNETAPI/Services/ApiService/IApiService.cs b/QtCNETAPI/Services/ApiService/IApiService.cs index 1003e85..7dc8ebb 100644 --- a/QtCNETAPI/Services/ApiService/IApiService.cs +++ b/QtCNETAPI/Services/ApiService/IApiService.cs @@ -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 diff --git a/QtCNETAPI/Services/GatewayService/GatewayService.cs b/QtCNETAPI/Services/GatewayService/GatewayService.cs index 70d0b0a..c636bb7 100644 --- a/QtCNETAPI/Services/GatewayService/GatewayService.cs +++ b/QtCNETAPI/Services/GatewayService/GatewayService.cs @@ -71,7 +71,7 @@ namespace QtCNETAPI.Services.GatewayService HubConnection.On("RefreshContactsList", () => OnRefreshContactsListReceived?.Invoke(this, EventArgs.Empty)); HubConnection.On("ReceiveServerConfig", (serverConfig) => OnServerConfigReceived?.Invoke(this, new ServerConfigEventArgs { ServerConfig = serverConfig })); HubConnection.On>("RoomUserList", (room, userList) => OnRoomUserListReceived?.Invoke(this, new RoomListEventArgs { Room = room, UserList = userList })); - HubConnection.On("GuestJoin", (username) => OnGuestUserJoin?.Invoke(this, new GuestUserJoinEventArgs { Username = username })); + HubConnection.On("GuestJoin", (username) => OnGuestUserJoin?.Invoke(this, new GuestUserJoinEventArgs { Username = username })); HubConnection.On("RoomDeleted", () => OnRoomDeleted?.Invoke(this, EventArgs.Empty)); HubConnection.On("ForceSignOut", () => OnUserForceLogout?.Invoke(this, EventArgs.Empty)); HubConnection.On("UpdateCurrentUser", async () => await _apiService.SetCurrentUser()); diff --git a/QtCNETAPI/Services/GatewayService/IGatewayService.cs b/QtCNETAPI/Services/GatewayService/IGatewayService.cs index 233ec21..15931df 100644 --- a/QtCNETAPI/Services/GatewayService/IGatewayService.cs +++ b/QtCNETAPI/Services/GatewayService/IGatewayService.cs @@ -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 { diff --git a/QtCNETAPI/Services/LoggingService.cs b/QtCNETAPI/Services/LoggingService.cs index 4ae7c88..decafa4 100644 --- a/QtCNETAPI/Services/LoggingService.cs +++ b/QtCNETAPI/Services/LoggingService.cs @@ -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) { } } diff --git a/qtcnet-client/Controls/BrandingControl.cs b/qtcnet-client/Controls/BrandingControl.cs index b4b8c19..b6b5780 100644 --- a/qtcnet-client/Controls/BrandingControl.cs +++ b/qtcnet-client/Controls/BrandingControl.cs @@ -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 { diff --git a/qtcnet-client/Controls/ContactControl.cs b/qtcnet-client/Controls/ContactControl.cs index 0c96187..02f277a 100644 --- a/qtcnet-client/Controls/ContactControl.cs +++ b/qtcnet-client/Controls/ContactControl.cs @@ -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 { diff --git a/qtcnet-client/Controls/CurrentProfileControl.cs b/qtcnet-client/Controls/CurrentProfileControl.cs index 1b7d19d..75a35ab 100644 --- a/qtcnet-client/Controls/CurrentProfileControl.cs +++ b/qtcnet-client/Controls/CurrentProfileControl.cs @@ -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; @@ -72,7 +67,7 @@ namespace qtcnet_client.Controls status = 1; break; case "Away": - status = 2; + status = 2; break; case "DoNotDisturb": status = 3; diff --git a/qtcnet-client/Controls/LoginControl.cs b/qtcnet-client/Controls/LoginControl.cs index ecb607f..e8ceb61 100644 --- a/qtcnet-client/Controls/LoginControl.cs +++ b/qtcnet-client/Controls/LoginControl.cs @@ -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 { diff --git a/qtcnet-client/Controls/MainTabControl.cs b/qtcnet-client/Controls/MainTabControl.cs index f7fe2cb..e5ba9e6 100644 --- a/qtcnet-client/Controls/MainTabControl.cs +++ b/qtcnet-client/Controls/MainTabControl.cs @@ -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 { diff --git a/qtcnet-client/Controls/RegisterControl.cs b/qtcnet-client/Controls/RegisterControl.cs index f631456..9a2e37d 100644 --- a/qtcnet-client/Controls/RegisterControl.cs +++ b/qtcnet-client/Controls/RegisterControl.cs @@ -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); @@ -64,9 +56,9 @@ namespace qtcnet_client.Controls private bool ValidateForm() { - return !string.IsNullOrEmpty(txtEmail.Text) && - !string.IsNullOrEmpty(txtPassword.Text) && - (txtConfirmEmail.Text == txtEmail.Text) && + return !string.IsNullOrEmpty(txtEmail.Text) && + !string.IsNullOrEmpty(txtPassword.Text) && + (txtConfirmEmail.Text == txtEmail.Text) && (txtConfirmPassword.Text == txtPassword.Text) && cbTOSAgree.Checked; } diff --git a/qtcnet-client/Controls/RoomControl.cs b/qtcnet-client/Controls/RoomControl.cs index 4f63800..d52bcc4 100644 --- a/qtcnet-client/Controls/RoomControl.cs +++ b/qtcnet-client/Controls/RoomControl.cs @@ -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 { diff --git a/qtcnet-client/Factories/ImageFactory.cs b/qtcnet-client/Factories/ImageFactory.cs index f0990ae..41c7dd2 100644 --- a/qtcnet-client/Factories/ImageFactory.cs +++ b/qtcnet-client/Factories/ImageFactory.cs @@ -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); @@ -82,14 +80,14 @@ namespace qtcnet_client.Factories g.CompositingMode = CompositingMode.SourceOver; 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); diff --git a/qtcnet-client/Forms/AddRoomForm.cs b/qtcnet-client/Forms/AddRoomForm.cs index 2862df5..1663130 100644 --- a/qtcnet-client/Forms/AddRoomForm.cs +++ b/qtcnet-client/Forms/AddRoomForm.cs @@ -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; diff --git a/qtcnet-client/Forms/AdminPanelForm.cs b/qtcnet-client/Forms/AdminPanelForm.cs index 25c4a2b..8361dbf 100644 --- a/qtcnet-client/Forms/AdminPanelForm.cs +++ b/qtcnet-client/Forms/AdminPanelForm.cs @@ -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 } diff --git a/qtcnet-client/Forms/ChatRoomForm.cs b/qtcnet-client/Forms/ChatRoomForm.cs index 4c263e1..cebca67 100644 --- a/qtcnet-client/Forms/ChatRoomForm.cs +++ b/qtcnet-client/Forms/ChatRoomForm.cs @@ -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 @@ -18,7 +14,7 @@ namespace qtcnet_client.Forms [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string RoomName { get; set; } = "Room"; [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Dictionary UserProfileImages { get; set; } = []; + public Dictionary UserProfileImages { get; set; } = []; public string SentMessage { get; private set; } = string.Empty; public event EventHandler? OnSend; @@ -72,7 +68,7 @@ namespace qtcnet_client.Forms public void AddUsersToRoomList(List users) { - if(lvUsers.InvokeRequired) + if (lvUsers.InvokeRequired) { lvUsers.Invoke(() => { @@ -156,7 +152,7 @@ namespace qtcnet_client.Forms private async Task 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); diff --git a/qtcnet-client/Forms/DirectMessageForm.cs b/qtcnet-client/Forms/DirectMessageForm.cs index 004279e..f5c1e80 100644 --- a/qtcnet-client/Forms/DirectMessageForm.cs +++ b/qtcnet-client/Forms/DirectMessageForm.cs @@ -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 { diff --git a/qtcnet-client/Forms/Games/GuessTheNumber.cs b/qtcnet-client/Forms/Games/GuessTheNumber.cs index 6c82262..0ffa749 100644 --- a/qtcnet-client/Forms/Games/GuessTheNumber.cs +++ b/qtcnet-client/Forms/Games/GuessTheNumber.cs @@ -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!"; diff --git a/qtcnet-client/Forms/Games/StockMarketGame.cs b/qtcnet-client/Forms/Games/StockMarketGame.cs index f305638..2ff1247 100644 --- a/qtcnet-client/Forms/Games/StockMarketGame.cs +++ b/qtcnet-client/Forms/Games/StockMarketGame.cs @@ -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; diff --git a/qtcnet-client/Forms/Games/TicTacToeGame.cs b/qtcnet-client/Forms/Games/TicTacToeGame.cs index 8f92b00..268b80d 100644 --- a/qtcnet-client/Forms/Games/TicTacToeGame.cs +++ b/qtcnet-client/Forms/Games/TicTacToeGame.cs @@ -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 { @@ -103,8 +100,8 @@ namespace qtcnet_client.Forms.Games } case GameStatus.P2Win: { - if (_apiService.CurrentUser?.Id == room.Player2?.Id) - { + if (_apiService.CurrentUser?.Id == room.Player2?.Id) + { lblLoadStatus.Text = "You Won!"; WinCount++; @@ -233,7 +230,7 @@ namespace qtcnet_client.Forms.Games GameHubConnection.On("ReceiveMessage", (msg) => { AddChatMessage(msg); - if (msg.Split('[')[1] != _apiService.CurrentUser?.Username) + if (msg.Split('[')[1] != _apiService.CurrentUser?.Username) _audioService.PlaySoundEffect("sndMessage"); }); @@ -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); } diff --git a/qtcnet-client/Forms/JackpotSpinForm.cs b/qtcnet-client/Forms/JackpotSpinForm.cs index 58966c1..e897f3f 100644 --- a/qtcnet-client/Forms/JackpotSpinForm.cs +++ b/qtcnet-client/Forms/JackpotSpinForm.cs @@ -1,7 +1,5 @@ using qtcnet_client.Services; -using System; using System.ComponentModel; -using System.Windows.Forms; namespace qtcnet_client.Forms { diff --git a/qtcnet-client/Forms/MainForm.cs b/qtcnet-client/Forms/MainForm.cs index 30933be..cd8368e 100644 --- a/qtcnet-client/Forms/MainForm.cs +++ b/qtcnet-client/Forms/MainForm.cs @@ -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; diff --git a/qtcnet-client/Forms/ProfileForm.cs b/qtcnet-client/Forms/ProfileForm.cs index 3c54e8d..1dc8db0 100644 --- a/qtcnet-client/Forms/ProfileForm.cs +++ b/qtcnet-client/Forms/ProfileForm.cs @@ -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 { diff --git a/qtcnet-client/Forms/StoreItemForm.cs b/qtcnet-client/Forms/StoreItemForm.cs index 62c5d40..b5ec733 100644 --- a/qtcnet-client/Forms/StoreItemForm.cs +++ b/qtcnet-client/Forms/StoreItemForm.cs @@ -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"; diff --git a/qtcnet-client/Model/ClientConfig.cs b/qtcnet-client/Model/ClientConfig.cs index 6d938dc..dda7b15 100644 --- a/qtcnet-client/Model/ClientConfig.cs +++ b/qtcnet-client/Model/ClientConfig.cs @@ -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 { diff --git a/qtcnet-client/Model/ClientUpdateInfo.cs b/qtcnet-client/Model/ClientUpdateInfo.cs index abbf817..30cf50c 100644 --- a/qtcnet-client/Model/ClientUpdateInfo.cs +++ b/qtcnet-client/Model/ClientUpdateInfo.cs @@ -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 { diff --git a/qtcnet-client/Services/UpdateService.cs b/qtcnet-client/Services/UpdateService.cs index a92d1f3..dd4ab54 100644 --- a/qtcnet-client/Services/UpdateService.cs +++ b/qtcnet-client/Services/UpdateService.cs @@ -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