BaseControl.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace TaskbarGroups.Views
  11. {
  12. public partial class BaseControl : UserControl
  13. {
  14. public BaseControl()
  15. {
  16. InitializeComponent();
  17. }
  18. private void InitializeComponent()
  19. {
  20. }
  21. private void BaseControl_Load(object sender, EventArgs e)
  22. {
  23. }
  24. /// <summary>
  25. /// Control 之间跳转
  26. /// </summary>
  27. /// <param name="type"></param>
  28. /// <returns></returns>
  29. internal static Form Go(Type type)
  30. {
  31. Form currentControl = null;
  32. foreach (Form controlItem in Program.formList)
  33. {
  34. if (controlItem.GetType() == type)
  35. {
  36. currentControl = controlItem;
  37. currentControl.Activate();
  38. break;
  39. }
  40. }
  41. if (currentControl == null)
  42. {
  43. object obj = Activator.CreateInstance(type);
  44. if (obj is Form)
  45. {
  46. currentControl = obj as Form;
  47. currentControl.Show();
  48. }
  49. }
  50. return currentControl;
  51. }
  52. }
  53. }