MainForm.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using ShareWifi.Views;
  12. namespace ShareWifi
  13. {
  14. public partial class MainForm : Form
  15. {
  16. HomeControl home;
  17. AboutMe aboutMe;
  18. Button activeMenu;
  19. public MainForm()
  20. {
  21. InitializeComponent();
  22. }
  23. private void label3_Click(object sender, EventArgs e)
  24. {
  25. }
  26. private void btnGenerate_Click(object sender, EventArgs e)
  27. {
  28. }
  29. private void btnHome_Click(object sender, EventArgs e)
  30. {
  31. interHome();
  32. activeMenu = btnHome;
  33. changeMenuTab();
  34. }
  35. public void changeMenuTab()
  36. {
  37. if (activeMenu == btnHome) {
  38. }else if (activeMenu == btnAboutMe) {
  39. btnHome.BackColor = Color.Aquamarine;
  40. }
  41. else
  42. {
  43. activeMenu.BackColor = Color.AliceBlue;
  44. }
  45. }
  46. public void interHome()
  47. {
  48. if (home == null)
  49. {
  50. home = HomeControl.getInstance();
  51. }
  52. plContent.Controls.Clear();
  53. plContent.Controls.Add(home);
  54. }
  55. private void btnAboutMe_Click(object sender, EventArgs e)
  56. {
  57. if (aboutMe == null)
  58. {
  59. aboutMe = AboutMe.getInstance();
  60. }
  61. plContent.Controls.Clear();
  62. plContent.Controls.Add(aboutMe);
  63. activeMenu = btnAboutMe;
  64. }
  65. private void btnMini_Click(object sender, EventArgs e)
  66. {
  67. Hide();
  68. }
  69. private void btnClose_Click(object sender, EventArgs e)
  70. {
  71. Application.Exit();
  72. }
  73. private void MainForm_Load(object sender, EventArgs e)
  74. {
  75. interHome();
  76. }
  77. private static bool IsDrag = false;
  78. private int enterX;
  79. private int enterY;
  80. private void plTitle_MouseDown(object sender, MouseEventArgs e)
  81. {
  82. IsDrag = true;
  83. enterX = e.Location.X;
  84. enterY = e.Location.Y;
  85. }
  86. private void plTitle_MouseUp(object sender, MouseEventArgs e)
  87. {
  88. IsDrag = false;
  89. enterX = 0;
  90. enterY = 0;
  91. }
  92. private void plTitle_MouseMove(object sender, MouseEventArgs e)
  93. {
  94. if (IsDrag)
  95. {
  96. this.Left += e.Location.X - enterX;
  97. this.Top += e.Location.Y - enterY;
  98. }
  99. }
  100. }
  101. }