MainForm.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. public MainForm()
  19. {
  20. InitializeComponent();
  21. }
  22. private void label3_Click(object sender, EventArgs e)
  23. {
  24. }
  25. private void btnGenerate_Click(object sender, EventArgs e)
  26. {
  27. }
  28. private void btnHome_Click(object sender, EventArgs e)
  29. {
  30. interHome();
  31. }
  32. public void interHome()
  33. {
  34. if (home == null)
  35. {
  36. home = HomeControl.getInstance();
  37. }
  38. plContent.Controls.Clear();
  39. plContent.Controls.Add(home);
  40. }
  41. private void btnAboutMe_Click(object sender, EventArgs e)
  42. {
  43. if (aboutMe == null)
  44. {
  45. aboutMe = AboutMe.getInstance();
  46. }
  47. plContent.Controls.Clear();
  48. plContent.Controls.Add(aboutMe);
  49. }
  50. private void btnMini_Click(object sender, EventArgs e)
  51. {
  52. Hide();
  53. }
  54. private void btnClose_Click(object sender, EventArgs e)
  55. {
  56. Application.Exit();
  57. }
  58. private void MainForm_Load(object sender, EventArgs e)
  59. {
  60. interHome();
  61. }
  62. private static bool IsDrag = false;
  63. private int enterX;
  64. private int enterY;
  65. private void plTitle_MouseDown(object sender, MouseEventArgs e)
  66. {
  67. IsDrag = true;
  68. enterX = e.Location.X;
  69. enterY = e.Location.Y;
  70. }
  71. private void plTitle_MouseUp(object sender, MouseEventArgs e)
  72. {
  73. IsDrag = false;
  74. enterX = 0;
  75. enterY = 0;
  76. }
  77. private void plTitle_MouseMove(object sender, MouseEventArgs e)
  78. {
  79. if (IsDrag)
  80. {
  81. this.Left += e.Location.X - enterX;
  82. this.Top += e.Location.Y - enterY;
  83. }
  84. }
  85. }
  86. }