12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace DayOf1440
- {
- static class Program
- {
- public static List<Form> formList = new List<Form>();
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainForm());
- }
- /// <summary>
- /// new a Form object
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- internal static Form getInstance(Type type)
- {
- Form currentForm = null;
- foreach (Form formItem in formList)
- {
- if (formItem.GetType() == type)
- {
- currentForm = formItem;
- currentForm.Activate();
- break;
- }
- }
- if (currentForm == null)
- {
- object obj = Activator.CreateInstance(type);
- if (obj is Form)
- {
- currentForm = obj as Form;
- currentForm.Show();
- }
- }
- return currentForm;
- }
- }
- }
|