From 0b1b7826b52cb9961b70ac6fb73429824c9dd3b0 Mon Sep 17 00:00:00 2001 From: Moonbase Date: Sun, 14 Dec 2025 13:21:54 -0800 Subject: [PATCH] Implement Tags Implement Text Status Rename Windows To Not Have Service Name --- QtCNETAPI/Dtos/User/UserInformationDto.cs | 2 + .../Dtos/User/UserUpdateInformationDto.cs | 1 + QtCNETAPI/Models/User.cs | 2 + QtCNETAPI/Services/ApiService/ApiService.cs | 31 +++++ QtCNETAPI/Services/ApiService/IApiService.cs | 1 + qtcnet-client/Controls/ContactControl.cs | 4 +- .../Forms/AdminPanelForm.Designer.cs | 2 +- qtcnet-client/Forms/AdminPanelForm.resx | 30 ++--- qtcnet-client/Forms/ChatRoomForm.cs | 2 +- qtcnet-client/Forms/DirectMessageForm.cs | 1 + .../Forms/Games/GuessTheNumber.Designer.cs | 2 +- .../Forms/Games/StockMarketGame.Designer.cs | 2 +- .../Forms/Games/TicTacToeGame.Designer.cs | 2 +- qtcnet-client/Forms/MainForm.cs | 22 ++-- qtcnet-client/Forms/ProfileForm.Designer.cs | 109 +++++++++--------- qtcnet-client/Forms/ProfileForm.cs | 95 ++++++++++++++- qtcnet-client/Forms/StoreItemForm.Designer.cs | 2 +- 17 files changed, 222 insertions(+), 88 deletions(-) diff --git a/QtCNETAPI/Dtos/User/UserInformationDto.cs b/QtCNETAPI/Dtos/User/UserInformationDto.cs index d6c93a6..41a8cda 100644 --- a/QtCNETAPI/Dtos/User/UserInformationDto.cs +++ b/QtCNETAPI/Dtos/User/UserInformationDto.cs @@ -13,5 +13,7 @@ public int Status { get; set; } = 0; public int CurrencyAmount { get; set; } = 0; public int ProfileCosmeticId { get; set; } = 0; + public string TextStatus { get; set; } = string.Empty; + public string[] Tags { get; set; } = []; } } diff --git a/QtCNETAPI/Dtos/User/UserUpdateInformationDto.cs b/QtCNETAPI/Dtos/User/UserUpdateInformationDto.cs index ac0ab53..e927518 100644 --- a/QtCNETAPI/Dtos/User/UserUpdateInformationDto.cs +++ b/QtCNETAPI/Dtos/User/UserUpdateInformationDto.cs @@ -7,5 +7,6 @@ public string Bio { get; set; } = string.Empty; public DateTime DateOfBirth { get; set; } = new DateTime(); public int ProfileCosmeticId { get; set; } = 0; + public string TextStatus { get; set; } = string.Empty; } } diff --git a/QtCNETAPI/Models/User.cs b/QtCNETAPI/Models/User.cs index 21cd0cc..95cd314 100644 --- a/QtCNETAPI/Models/User.cs +++ b/QtCNETAPI/Models/User.cs @@ -19,6 +19,8 @@ public int ActiveProfileCosmetic { get; set; } = 0; public string CurrentRoomId { get; set; } = string.Empty; public DateTime LastLogin { get; set; } + public string TextStatus { get; set; } = string.Empty; + public string[] Tags { get; set; } = []; public virtual IEnumerable? RefreshTokens { get; } public virtual IEnumerable? ContactsMade { get; } diff --git a/QtCNETAPI/Services/ApiService/ApiService.cs b/QtCNETAPI/Services/ApiService/ApiService.cs index 12b9f4e..72ba014 100644 --- a/QtCNETAPI/Services/ApiService/ApiService.cs +++ b/QtCNETAPI/Services/ApiService/ApiService.cs @@ -4,6 +4,7 @@ using QtCNETAPI.Enums; using QtCNETAPI.Models; using QtCNETAPI.Schema; using RestSharp; +using System.Diagnostics; using System.IdentityModel.Tokens.Jwt; using System.Text.Json; @@ -232,6 +233,36 @@ namespace QtCNETAPI.Services.ApiService } } + public async Task> GetTagPic(string tag) + { + var serviceResponse = new ServiceResponse(); + try + { + var restRequest = new RestRequest($"tags/{tag}") + .AddHeader("Authorization", $"Bearer {SessionToken}"); + var response = await _client.GetAsync(restRequest); + + if (response != null) + { + serviceResponse.Success = true; + serviceResponse.Data = response.RawBytes; + } + else + { + serviceResponse.Success = false; + serviceResponse.Message = "No Tag Picture Received."; + } + + return serviceResponse; + } + catch (HttpRequestException ex) + { + serviceResponse.Success = false; + serviceResponse.Message = ex.Message; + return serviceResponse; + } + } + public async Task> LoginAsync(UserLoginDto userLoginDto) { var serviceResponse = new ServiceResponse(); diff --git a/QtCNETAPI/Services/ApiService/IApiService.cs b/QtCNETAPI/Services/ApiService/IApiService.cs index 41aa316..1003e85 100644 --- a/QtCNETAPI/Services/ApiService/IApiService.cs +++ b/QtCNETAPI/Services/ApiService/IApiService.cs @@ -37,6 +37,7 @@ namespace QtCNETAPI.Services.ApiService public Task> UpdateUserInformationAsync(UserUpdateInformationDto request); public Task> UpdateUserProfilePic(string filePath); public Task> GetUserProfilePic(string userId); + public Task> GetTagPic(string tag); public Task> CreateRoomAsync(RoomDto request); public Task> DeleteRoomAsync(string roomId); public Task>> GetAllRoomsAsync(); diff --git a/qtcnet-client/Controls/ContactControl.cs b/qtcnet-client/Controls/ContactControl.cs index cef184d..0c96187 100644 --- a/qtcnet-client/Controls/ContactControl.cs +++ b/qtcnet-client/Controls/ContactControl.cs @@ -17,7 +17,7 @@ namespace qtcnet_client.Controls [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string Username { get; set; } = "Username"; [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] - public string TextStatus { get; set; } = "Status"; + public string TextStatus { get; set; } = string.Empty; [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public int Status { get; set; } = 0; [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] @@ -64,7 +64,7 @@ namespace qtcnet_client.Controls lblStatus.Text = $"'{TextStatus}'"; pbProfilePic.Image = ProfilePic; - if (Status == 0) + if (Status == 0 || string.IsNullOrEmpty(TextStatus)) { lblStatus.Visible = false; lblUsername.Location = new(44, 15); diff --git a/qtcnet-client/Forms/AdminPanelForm.Designer.cs b/qtcnet-client/Forms/AdminPanelForm.Designer.cs index 6c0c1a3..df6969c 100644 --- a/qtcnet-client/Forms/AdminPanelForm.Designer.cs +++ b/qtcnet-client/Forms/AdminPanelForm.Designer.cs @@ -314,7 +314,7 @@ MinimizeBox = false; Name = "AdminPanelForm"; StartPosition = FormStartPosition.CenterScreen; - Text = "QtC.NET Server Admin Panel"; + Text = "Server Admin Panel"; Load += AdminPanelForm_Load; ((System.ComponentModel.ISupportInitialize)pbLogo).EndInit(); tcMain.ResumeLayout(false); diff --git a/qtcnet-client/Forms/AdminPanelForm.resx b/qtcnet-client/Forms/AdminPanelForm.resx index aecfd58..ab01f75 100644 --- a/qtcnet-client/Forms/AdminPanelForm.resx +++ b/qtcnet-client/Forms/AdminPanelForm.resx @@ -133,8 +133,8 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu - SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA2hgAAAJNU0Z0AUkBTAIBAQUB - AAFwAQEBcAEBARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAASADAAEBAQABIAYAASAa + SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA2BgAAAJNU0Z0AUkBTAIBAQUB + AAF4AQEBeAEBARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAASADAAEBAQABIAYAASAa AAM3AVoDWAG4A2MB3wJjAV0B3wFiAl0B3wNdAd8DXQHfAWECXQHfA2MB3wNjAd8DVQGsAzABS8wAAzsB YgNdAcUDaAH0AZ8BZQExAf8BlwFTARcB/wGWAUsBCQH/AZMBRgEBAf8BjAFDAQMB/wF9AUABCwH/AWsB QAEaAf8BbgFQATYB/wNoAfADWgG3AzQBVMQAAzUBVQNdAccCbgFaAfUBuAFlARsB/wG5AVgBAgH/AckB @@ -155,10 +155,10 @@ /wFjAWEBXQHfwAAB/wHMAZ8C/wGsAWMC/wGTATMC/wGBAREC/wF5AQIC/wGCARYC/wGaAUsC/wGuAXgC /wGlAVcC/wGBARcC/wF5AQQC/wF4AQAC/wF4AQAB/wHwAXEBAAH/AdUBcQEXAf8CYwFdAd/AAAH/AekB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Ad0BmwH/AZQCgAH+AmUBXgHiAz0BaAQBCAADBgEIAzEBTANQAZsDZQHsA30B + +gOBAf8DgQH/A4EB/wOBAf8DgQH/A4EB/wOBAf8DfQH6A2oB7QNQAZsDLwFJBAADQgFyA2MB1QF1AWsB + agH5Af8ByQGZAv8BvAF/Av8BrgFmAv8BpAFTAv8BnwFKAv8BnwFLAv8BowFRAv8BpwFYAf8DfAH4A10B + xwM7AWIEAED/EAADDwETA0cBggNkAdsCfgFvAfwDZwHqA1QBqAMoATscAAMFAQYDEgEXAzoBYANRAZ8D + XwHTA2cB7wNjAfYDYgHuA14B0gNRAZ4DOQFfAxEBFgMFAQYMAAM8AWUDXgHSAf8B7wHgAv8B3AG8Av8B + zQGfAv8BwQGKAv8BuwF/Av8BvwGGAv8BzQGhAv8B6QHWAf8DXAHEAzUBVQgAAUIBTQE+BwABPgMAASgD + AAFAAwABIAMAAQEBAAEBBgABARYAA/8BAAHAAQMGAAGAAQFmAAGAAQEGAAHAAQMIAAH/AfwCAAHAAQMC + AAH/AfwCAAGAAQECAAH/AfkGAAH/AfkGAAHwARMGAAHAAQMGAAGAAQEC/wQAAYABAQHAAQEFAAEBAYAG + AAEBBwABAQcAAQEHAAEBBgABgAEBBgABwAEDAgABgAEBAgAB8AEfAcABAQHAAQML \ No newline at end of file diff --git a/qtcnet-client/Forms/ChatRoomForm.cs b/qtcnet-client/Forms/ChatRoomForm.cs index bbcb1da..4c263e1 100644 --- a/qtcnet-client/Forms/ChatRoomForm.cs +++ b/qtcnet-client/Forms/ChatRoomForm.cs @@ -38,7 +38,7 @@ namespace qtcnet_client.Forms private void ChatRoomForm_Load(object sender, EventArgs e) { - Text = $"QtC.NET Chat Room - {RoomName}"; + Text = $"Chat Room - {RoomName}"; lblRoomName.Text = RoomName; } diff --git a/qtcnet-client/Forms/DirectMessageForm.cs b/qtcnet-client/Forms/DirectMessageForm.cs index c837930..004279e 100644 --- a/qtcnet-client/Forms/DirectMessageForm.cs +++ b/qtcnet-client/Forms/DirectMessageForm.cs @@ -38,6 +38,7 @@ namespace qtcnet_client.Forms private void DirectMessageForm_Load(object sender, EventArgs e) { + Text = $"Direct Message With {Username}"; lblUsername.Text = Username; pbProfileImage.Image = ProfileImage; } diff --git a/qtcnet-client/Forms/Games/GuessTheNumber.Designer.cs b/qtcnet-client/Forms/Games/GuessTheNumber.Designer.cs index 31a6fca..5050a41 100644 --- a/qtcnet-client/Forms/Games/GuessTheNumber.Designer.cs +++ b/qtcnet-client/Forms/Games/GuessTheNumber.Designer.cs @@ -117,7 +117,7 @@ MinimizeBox = false; Name = "GuessTheNumber"; StartPosition = FormStartPosition.CenterScreen; - Text = "QtC.NET qGame - Guess The Number"; + Text = "qGame - Guess The Number"; Load += GuessTheNumber_Load; ((System.ComponentModel.ISupportInitialize)nudNumberGuess).EndInit(); ResumeLayout(false); diff --git a/qtcnet-client/Forms/Games/StockMarketGame.Designer.cs b/qtcnet-client/Forms/Games/StockMarketGame.Designer.cs index 80e53a7..f76251e 100644 --- a/qtcnet-client/Forms/Games/StockMarketGame.Designer.cs +++ b/qtcnet-client/Forms/Games/StockMarketGame.Designer.cs @@ -179,7 +179,7 @@ MinimizeBox = false; Name = "StockMarketGame"; StartPosition = FormStartPosition.CenterScreen; - Text = "QtC.NET qGame - Stock Market"; + Text = "qGame - Stock Market"; Load += StockMarketGame_Load; pStockManagement.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)nudStockBuySellAmount).EndInit(); diff --git a/qtcnet-client/Forms/Games/TicTacToeGame.Designer.cs b/qtcnet-client/Forms/Games/TicTacToeGame.Designer.cs index 78f38eb..e681fb2 100644 --- a/qtcnet-client/Forms/Games/TicTacToeGame.Designer.cs +++ b/qtcnet-client/Forms/Games/TicTacToeGame.Designer.cs @@ -412,7 +412,7 @@ MaximizeBox = false; Name = "TicTacToeGame"; StartPosition = FormStartPosition.CenterScreen; - Text = "QtC.NET qGame - qTic-Tac-Toe"; + Text = "qGame - qTic-Tac-Toe"; FormClosed += TicTacToeGame_FormClosed; Load += Main_Load; pBoard.ResumeLayout(false); diff --git a/qtcnet-client/Forms/MainForm.cs b/qtcnet-client/Forms/MainForm.cs index fdd3483..1e33012 100644 --- a/qtcnet-client/Forms/MainForm.cs +++ b/qtcnet-client/Forms/MainForm.cs @@ -322,6 +322,9 @@ namespace qtcnet_client Username = _user.Data.Username, Bio = _user.Data.Bio, Status = _user.Data.Status, + Tags = _user.Data.Tags, + TextStatus = _user.Data.TextStatus, + CosmeticId = _user.Data.ProfileCosmeticId, }; // check if user is in contacts list (if profile isn't self) @@ -391,6 +394,9 @@ namespace qtcnet_client Username = _user.Data.Username, Bio = _user.Data.Bio, Status = _user.Data.Status, + Tags = _user.Data.Tags, + TextStatus = _user.Data.TextStatus, + CosmeticId = _user.Data.ProfileCosmeticId, }; // check if user is in contacts list (if profile isn't self) @@ -994,7 +1000,10 @@ namespace qtcnet_client Username = _user.Data.Username, Bio = _user.Data.Bio, Status = _user.Data.Status, - ProfileImage = _imgFactory.GetAndCreateProfileImage(_user.Data.Id, _user.Data.Status, _user.Data.ProfileCosmeticId) + ProfileImage = _imgFactory.GetAndCreateProfileImage(_user.Data.Id, _user.Data.Status, _user.Data.ProfileCosmeticId), + Tags = _user.Data.Tags, + TextStatus = _user.Data.TextStatus, + CosmeticId = _user.Data.ProfileCosmeticId, }; _profile.OnClose += ProfileForm_OnClose; @@ -1010,11 +1019,8 @@ namespace qtcnet_client { // get the open chat room form var _chatRoom = OpenChatRoomForms.FirstOrDefault(e => e.RoomId == _args.Room.Id); - if (_chatRoom != null) - { - // the users to the list - _chatRoom.AddUsersToRoomList(_args.UserList); - } + // the users to the list + _chatRoom?.AddUsersToRoomList(_args.UserList); } } @@ -1126,10 +1132,12 @@ namespace qtcnet_client { UserId = user.Data.Id, Username = user.Data.Username, - TextStatus = "NOT IMPLEMENTED", Status = user.Data.Status, }; + if (!string.IsNullOrEmpty(user.Data.TextStatus)) + ctrl.TextStatus = user.Data.TextStatus; + if (contact.OwnerId == _apiService.CurrentUser.Id) { switch (contact.OwnerStatus) diff --git a/qtcnet-client/Forms/ProfileForm.Designer.cs b/qtcnet-client/Forms/ProfileForm.Designer.cs index e23129d..9a87cbe 100644 --- a/qtcnet-client/Forms/ProfileForm.Designer.cs +++ b/qtcnet-client/Forms/ProfileForm.Designer.cs @@ -29,53 +29,29 @@ private void InitializeComponent() { components = new System.ComponentModel.Container(); - pbProfileImage = new PictureBox(); ctxBoughtItems = new ContextMenuStrip(components); - lblStatus = new Label(); rtxtBio = new RichTextBox(); tlpActionButtons = new TableLayoutPanel(); btnAction1 = new Button(); btnAction2 = new Button(); tlpUsernameTags = new TableLayoutPanel(); lblUsername = new Label(); - tlpTagIcons = new TableLayoutPanel(); + flpTagIcons = new FlowLayoutPanel(); btnSaveProfile = new Button(); - ((System.ComponentModel.ISupportInitialize)pbProfileImage).BeginInit(); + flpPfpStatus = new FlowLayoutPanel(); + lblStatus = new Label(); + pbProfileImage = new PictureBox(); tlpActionButtons.SuspendLayout(); tlpUsernameTags.SuspendLayout(); + flpPfpStatus.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pbProfileImage).BeginInit(); SuspendLayout(); // - // pbProfileImage - // - pbProfileImage.Image = Properties.Resources.DefaultPfp; - pbProfileImage.Location = new Point(12, 12); - pbProfileImage.Name = "pbProfileImage"; - pbProfileImage.Size = new Size(97, 99); - pbProfileImage.SizeMode = PictureBoxSizeMode.Zoom; - pbProfileImage.TabIndex = 0; - pbProfileImage.TabStop = false; - pbProfileImage.MouseClick += pbProfileImage_Click; - pbProfileImage.MouseEnter += pbProfileImage_MouseEnter; - pbProfileImage.MouseLeave += pbProfileImage_MouseLeave; - // // ctxBoughtItems // ctxBoughtItems.Name = "ctxBoughtItems"; ctxBoughtItems.Size = new Size(61, 4); // - // lblStatus - // - lblStatus.AutoEllipsis = true; - lblStatus.Font = new Font("Segoe UI Semibold", 9F, FontStyle.Bold, GraphicsUnit.Point, 0); - lblStatus.ForeColor = Color.White; - lblStatus.Location = new Point(12, 114); - lblStatus.Name = "lblStatus"; - lblStatus.Padding = new Padding(0, 0, 0, 15); - lblStatus.Size = new Size(97, 54); - lblStatus.TabIndex = 2; - lblStatus.Text = "Status"; - lblStatus.TextAlign = ContentAlignment.MiddleCenter; - // // rtxtBio // rtxtBio.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; @@ -125,13 +101,12 @@ // // tlpUsernameTags // - tlpUsernameTags.AutoSize = true; tlpUsernameTags.AutoSizeMode = AutoSizeMode.GrowAndShrink; tlpUsernameTags.ColumnCount = 2; tlpUsernameTags.ColumnStyles.Add(new ColumnStyle()); tlpUsernameTags.ColumnStyles.Add(new ColumnStyle()); tlpUsernameTags.Controls.Add(lblUsername, 0, 0); - tlpUsernameTags.Controls.Add(tlpTagIcons, 1, 0); + tlpUsernameTags.Controls.Add(flpTagIcons, 1, 0); tlpUsernameTags.Location = new Point(115, 11); tlpUsernameTags.Name = "tlpUsernameTags"; tlpUsernameTags.RowCount = 1; @@ -153,20 +128,16 @@ lblUsername.TextAlign = ContentAlignment.MiddleLeft; lblUsername.DoubleClick += lblUsername_DoubleClick; // - // tlpTagIcons + // flpTagIcons // - tlpTagIcons.AutoSize = true; - tlpTagIcons.AutoSizeMode = AutoSizeMode.GrowAndShrink; - tlpTagIcons.ColumnCount = 1; - tlpTagIcons.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); - tlpTagIcons.GrowStyle = TableLayoutPanelGrowStyle.AddColumns; - tlpTagIcons.Location = new Point(155, 3); - tlpTagIcons.MinimumSize = new Size(145, 49); - tlpTagIcons.Name = "tlpTagIcons"; - tlpTagIcons.RowCount = 1; - tlpTagIcons.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); - tlpTagIcons.Size = new Size(145, 49); - tlpTagIcons.TabIndex = 1; + flpTagIcons.AutoSize = true; + flpTagIcons.Dock = DockStyle.Fill; + flpTagIcons.Location = new Point(155, 3); + flpTagIcons.Name = "flpTagIcons"; + flpTagIcons.Padding = new Padding(0, 10, 0, 0); + flpTagIcons.Size = new Size(145, 49); + flpTagIcons.TabIndex = 1; + flpTagIcons.WrapContents = false; // // btnSaveProfile // @@ -179,6 +150,39 @@ btnSaveProfile.Visible = false; btnSaveProfile.Click += btnSaveProfile_Click; // + // flpPfpStatus + // + flpPfpStatus.Controls.Add(pbProfileImage); + flpPfpStatus.Controls.Add(lblStatus); + flpPfpStatus.FlowDirection = FlowDirection.RightToLeft; + flpPfpStatus.Location = new Point(5, 11); + flpPfpStatus.Name = "flpPfpStatus"; + flpPfpStatus.Size = new Size(104, 166); + flpPfpStatus.TabIndex = 8; + // + // lblStatus + // + lblStatus.AutoEllipsis = true; + lblStatus.Font = new Font("Segoe UI Semibold", 9F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + lblStatus.ForeColor = Color.White; + lblStatus.Location = new Point(4, 105); + lblStatus.Name = "lblStatus"; + lblStatus.Padding = new Padding(0, 0, 0, 15); + lblStatus.Size = new Size(97, 54); + lblStatus.TabIndex = 4; + lblStatus.Text = "Enter Status Here"; + lblStatus.TextAlign = ContentAlignment.MiddleCenter; + // + // pbProfileImage + // + pbProfileImage.Image = Properties.Resources.DefaultPfp; + pbProfileImage.Location = new Point(4, 3); + pbProfileImage.Name = "pbProfileImage"; + pbProfileImage.Size = new Size(97, 99); + pbProfileImage.SizeMode = PictureBoxSizeMode.Zoom; + pbProfileImage.TabIndex = 3; + pbProfileImage.TabStop = false; + // // ProfileForm // AutoScaleDimensions = new SizeF(7F, 15F); @@ -190,8 +194,7 @@ Controls.Add(tlpUsernameTags); Controls.Add(tlpActionButtons); Controls.Add(rtxtBio); - Controls.Add(lblStatus); - Controls.Add(pbProfileImage); + Controls.Add(flpPfpStatus); FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; Name = "ProfileForm"; @@ -199,26 +202,26 @@ Text = "QtC.NET User Profile"; FormClosed += ProfileForm_FormClosed; Load += ProfileForm_Load; - ((System.ComponentModel.ISupportInitialize)pbProfileImage).EndInit(); tlpActionButtons.ResumeLayout(false); tlpUsernameTags.ResumeLayout(false); tlpUsernameTags.PerformLayout(); + flpPfpStatus.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pbProfileImage).EndInit(); ResumeLayout(false); - PerformLayout(); } #endregion - - private PictureBox pbProfileImage; - private Label lblStatus; private RichTextBox rtxtBio; private TableLayoutPanel tlpActionButtons; private TableLayoutPanel tlpUsernameTags; private Label lblUsername; - private TableLayoutPanel tlpTagIcons; private Button btnAction1; private Button btnAction2; private Button btnSaveProfile; private ContextMenuStrip ctxBoughtItems; + private FlowLayoutPanel flpTagIcons; + private FlowLayoutPanel flpPfpStatus; + private PictureBox pbProfileImage; + private Label lblStatus; } } \ No newline at end of file diff --git a/qtcnet-client/Forms/ProfileForm.cs b/qtcnet-client/Forms/ProfileForm.cs index 6fcd1c3..3f5feef 100644 --- a/qtcnet-client/Forms/ProfileForm.cs +++ b/qtcnet-client/Forms/ProfileForm.cs @@ -32,12 +32,14 @@ namespace qtcnet_client.Forms public Contact.ContactStatus ContactStatus { get; set; } [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public Image ProfileImage { get; set; } = Resources.DefaultPfp; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public int CosmeticId { get; set; } = 0; public event EventHandler? OnMessageClicked; public event EventHandler? OnClose; - private IApiService _apiService; - private ImageFactory _imgFactory; + private readonly IApiService _apiService; + private readonly ImageFactory _imgFactory; public ProfileForm(IApiService apiService, ImageFactory imageFactory) { _apiService = apiService; @@ -47,13 +49,16 @@ namespace qtcnet_client.Forms private async void ProfileForm_Load(object sender, EventArgs e) { - Text = $"QtC.NET User Profile - {Username}"; + SuspendLayout(); + + Text = $"User Profile - {Username}"; lblUsername.Text = Username; lblStatus.Text = TextStatus; rtxtBio.Text = Bio; pbProfileImage.Image = ProfileImage; ResizeFormToUsername(); + SetTagIcons(); if (Status == 0) lblStatus.Visible = false; @@ -82,6 +87,15 @@ namespace qtcnet_client.Forms } } } + + lblStatus.Visible = true; + + if(string.IsNullOrEmpty(TextStatus)) + lblStatus.Text = "Enter Status Here"; + + lblStatus.Font = new("Segoe UI", 9, FontStyle.Bold | FontStyle.Italic); + lblStatus.ForeColor = Color.LightGray; + lblStatus.DoubleClick += lblStatus_DoubleClick; } switch (ContactStatus) @@ -112,6 +126,46 @@ namespace qtcnet_client.Forms btnAction2.Click += BtnAction2_AddContactClick; break; } + + ResumeLayout(true); + } + + private async void SetTagIcons() + { + // for each tag the user has, get the image associated with it from the server + List _tagImages = []; + foreach(var tag in Tags) + { + var _res = await _apiService.GetTagPic(tag); + if(_res.Success && _res.Data != null) + { + // create a picturebox control and add it to the tag table + Bitmap bm = new(new MemoryStream(_res.Data)); + _tagImages.Add(bm); + } + } + + ApplyTagIcons(_tagImages); + } + + private void ApplyTagIcons(List tagImages) + { + flpTagIcons.SuspendLayout(); + + foreach(var img in tagImages) + { + PictureBox tagPb = new() + { + Image = img, + SizeMode = PictureBoxSizeMode.Zoom, + Size = new(20, 20), + Anchor = AnchorStyles.Left, + }; + + flpTagIcons.Controls.Add(tagPb); + } + + flpTagIcons.ResumeLayout(true); } private async void ProfileForm_StoreItemToolStripClick(object? sender, EventArgs e) @@ -255,6 +309,37 @@ namespace qtcnet_client.Forms } } + private void lblStatus_DoubleClick(object? sender, EventArgs e) + { + if (UserId == _apiService.CurrentUser?.Id) + { + lblStatus.Visible = false; + + TextBox txtStatusEdit = new() + { + Text = lblStatus.Text, + Font = lblStatus.Font, + MaxLength = 150, + Location = lblStatus.Location, + Size = lblStatus.Size, + }; + txtStatusEdit.KeyDown += TxtStatusEdit_KeyDown; + flpPfpStatus.Controls.Add(txtStatusEdit); + txtStatusEdit.Focus(); + } + } + + private void TxtStatusEdit_KeyDown(object? sender, KeyEventArgs e) + { + if(sender is TextBox txtStatusEdit && e.KeyCode == Keys.Enter) + { + lblStatus.Text = txtStatusEdit.Text; + flpPfpStatus.Controls.Remove(txtStatusEdit); + txtStatusEdit.Dispose(); + lblStatus.Visible = true; + } + } + private void TxtUsernameEdit_KeyDown(object? sender, KeyEventArgs e) { if (sender is TextBox txtUsernameEdit && e.KeyCode == Keys.Enter) @@ -276,6 +361,7 @@ namespace qtcnet_client.Forms Username = lblUsername.Text, Bio = rtxtBio.Text, DateOfBirth = _apiService.CurrentUser.DateOfBirth, + TextStatus = lblStatus.Text, }); if (_res.Success && _res.Data != null) KryptonMessageBox.Show("Profile Updated", "Yipee!"); @@ -304,8 +390,7 @@ namespace qtcnet_client.Forms var _apiRes = await _apiService.UpdateUserProfilePic(openFileDialog.FileName); if(_apiRes.Success) { - Image newImg = Image.FromFile(openFileDialog.FileName); - pbProfileImage.Image = newImg; + pbProfileImage.Image = _imgFactory.GetAndCreateProfileImage(UserId, Status, CosmeticId); pbProfileImage.Invalidate(); } } diff --git a/qtcnet-client/Forms/StoreItemForm.Designer.cs b/qtcnet-client/Forms/StoreItemForm.Designer.cs index 3554b15..2b2ba47 100644 --- a/qtcnet-client/Forms/StoreItemForm.Designer.cs +++ b/qtcnet-client/Forms/StoreItemForm.Designer.cs @@ -151,7 +151,7 @@ MinimizeBox = false; Name = "StoreItemForm"; StartPosition = FormStartPosition.CenterScreen; - Text = "QtC.NET Store Item"; + Text = "Store Item"; FormClosed += StoreItemForm_FormClosed; Load += StoreItemForm_Load; flpMainLayout.ResumeLayout(false);