SessionPanel.cs 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Windows.Forms;
  2. namespace ErgometerDoctorApplication
  3. {
  4. class SessionPanel : Panel
  5. {
  6. private int Session;
  7. private string name;
  8. private bool IsNew;
  9. private double timestamp;
  10. public SessionPanel(int session, string name, bool isNew,double timestamp) : base()
  11. {
  12. this.timestamp = timestamp;
  13. Session = session;
  14. this.name = name;
  15. IsNew = isNew;
  16. this.Location = new System.Drawing.Point(0, 0);
  17. this.Size = new System.Drawing.Size(180, 100);
  18. this.BackColor = System.Drawing.Color.DarkGray;
  19. this.Click += SessionPanel_Click;
  20. this.MouseEnter += SessionPanel_MouseEnter;
  21. this.MouseLeave += SessionPanel_MouseLeave;
  22. this.Cursor = Cursors.Hand;
  23. this.labelTimestamp = new Label();
  24. this.labelName = new System.Windows.Forms.Label();
  25. //
  26. // labelActiveSessions
  27. //
  28. this.labelName.Anchor = System.Windows.Forms.AnchorStyles.None;
  29. this.labelName.AutoSize = true;
  30. this.labelName.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  31. this.labelName.Location = new System.Drawing.Point(10, 10);
  32. this.labelName.ForeColor = System.Drawing.Color.White;
  33. this.labelName.Name = "labelActiveSessions";
  34. this.labelName.Size = new System.Drawing.Size(103, 21);
  35. this.labelName.TabIndex = 3;
  36. this.labelName.Text = name;
  37. this.labelName.Click += SessionPanel_Click;
  38. this.labelName.MouseEnter += SessionPanel_MouseEnter;
  39. this.labelName.MouseLeave += SessionPanel_MouseLeave;
  40. this.labelName.Cursor = Cursors.Hand;
  41. this.labelTimestamp.Name = "labelTimeStamp";
  42. this.labelTimestamp.Anchor = AnchorStyles.None;
  43. this.labelTimestamp.Text = ErgometerLibrary.Helper.MillisecondsToTime(timestamp);
  44. this.labelTimestamp.Location = new System.Drawing.Point(10, 40);
  45. this.labelTimestamp.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  46. this.labelTimestamp.ForeColor = System.Drawing.Color.White;
  47. this.labelTimestamp.Size = new System.Drawing.Size(103, 21);
  48. this.labelTimestamp.Click += SessionPanel_Click;
  49. this.labelTimestamp.MouseEnter += SessionPanel_MouseEnter;
  50. this.labelTimestamp.MouseLeave += SessionPanel_MouseLeave;
  51. if (isNew)
  52. labelTimestamp.Visible = false;
  53. this.Controls.Add(labelName);
  54. this.Controls.Add(labelTimestamp);
  55. }
  56. private void SessionPanel_MouseEnter(object sender, System.EventArgs e)
  57. {
  58. this.BackColor = System.Drawing.Color.Gray;
  59. this.labelName.ForeColor = System.Drawing.Color.WhiteSmoke;
  60. labelTimestamp.ForeColor = System.Drawing.Color.WhiteSmoke;
  61. }
  62. private void SessionPanel_MouseLeave(object sender, System.EventArgs e)
  63. {
  64. this.BackColor = System.Drawing.Color.DarkGray;
  65. this.labelName.ForeColor = System.Drawing.Color.White;
  66. this.labelTimestamp.ForeColor = System.Drawing.Color.White;
  67. }
  68. private void SessionPanel_Click(object sender, System.EventArgs e)
  69. {
  70. if(IsNew)
  71. MainClient.StartNewClient(name, Session);
  72. else
  73. MainClient.StartOldClient(name, Session);
  74. }
  75. public System.Windows.Forms.Label labelName;
  76. public Label labelTimestamp;
  77. }
  78. }