ChatItem.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. namespace ErgometerLibrary.Chat
  8. {
  9. public class ChatItem : Panel
  10. {
  11. private Label messageLabel, timeLabel;
  12. public ChatItem(ChatMessage chat) : base()
  13. {
  14. this.messageLabel = new Label();
  15. this.timeLabel = new Label();
  16. this.AutoSize = true;
  17. this.setAppearance(chat.IsDoctor);
  18. this.Controls.Add(this.messageLabel);
  19. this.Controls.Add(this.timeLabel);
  20. this.MinimumSize = new System.Drawing.Size(150, 60);
  21. this.Name = "messageContainer";
  22. this.Padding = new System.Windows.Forms.Padding(6);
  23. //
  24. // Message Label
  25. //
  26. this.messageLabel.AutoSize = true;
  27. this.messageLabel.Dock = System.Windows.Forms.DockStyle.Fill;
  28. this.messageLabel.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  29. this.messageLabel.Location = new System.Drawing.Point(6, 6);
  30. this.messageLabel.MaximumSize = new System.Drawing.Size(250, 0);
  31. this.messageLabel.Size = new System.Drawing.Size(121, 20);
  32. this.messageLabel.Text = chat.Message.Replace("\n", "");
  33. //
  34. // Time Label
  35. //
  36. this.timeLabel.AutoSize = true;
  37. this.timeLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
  38. this.timeLabel.Font = new System.Drawing.Font("Segoe UI Semilight", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  39. this.timeLabel.Location = new System.Drawing.Point(6, 26);
  40. this.timeLabel.Margin = new System.Windows.Forms.Padding(6);
  41. this.timeLabel.Size = new System.Drawing.Size(32, 13);
  42. this.timeLabel.Text = Helper.MillisecondsToTime(chat.TimeStamp);
  43. }
  44. private void setAppearance(bool isDoctor)
  45. {
  46. if (isDoctor)
  47. {
  48. this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  49. this.Dock = DockStyle.Right;
  50. }
  51. else
  52. {
  53. this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
  54. this.Dock = DockStyle.Left;
  55. }
  56. }
  57. }
  58. }