/// <summary> /// Main calling method. Opens a new instance of the form, and displays it /// </summary> /// <param name="Parent">The parent form, that will be used to center this form over</param> /// <param name="AllowDrag">Sets whether this window will be allowed to be moved by the user</param> /// <param name="WindowTitle">The text in the window title bar</param> public static void ShowScreen(Form Parent, bool AllowDrag = false, string WindowTitle = "Loading... Please Wait") { // Make sure it is currently not open and running. if (Instance != null && !Instance.IsDisposed) { return; } // Set window position to center parent Instance = new LoadingForm(); Instance.Text = WindowTitle; Instance.AllowDrag = AllowDrag; double H = Parent.Location.Y + (Parent.Height / 2) - (Instance.Height / 2); double W = Parent.Location.X + (Parent.Width / 2) - (Instance.Width / 2); Instance.Location = new Point((int)Math.Round(W, 0), (int)Math.Round(H, 0)); // Display the Instanced Form Instance.Show(Parent); // Wait until the Instance form is displayed while (!Instance.IsHandleCreated) { Thread.Sleep(50); } }
/// <summary> /// Main calling method. Opens a new instance of the form, and displays it /// </summary> /// <param name="Parent">The parent form, that will be used to center this form over</param> /// <param name="AllowDrag">Sets whether this window will be allowed to be moved by the user</param> /// <param name="WindowTitle">The text in the window title bar</param> public static void ShowScreen(Form Parent, bool AllowDrag = false, string WindowTitle = "Loading... Please Wait") { // Make sure it is currently not open and running. if (Instance != null && !Instance.IsDisposed) return; // Set window position to center parent Instance = new LoadingForm(); Instance.Text = WindowTitle; Instance.AllowDrag = AllowDrag; double H = Parent.Location.Y + (Parent.Height / 2) - (Instance.Height / 2); double W = Parent.Location.X + (Parent.Width / 2) - (Instance.Width / 2); Instance.Location = new Point((int)Math.Round(W, 0), (int)Math.Round(H, 0)); // Display the Instanced Form Instance.Show(Parent); // Wait until the Instance form is displayed while (!Instance.IsHandleCreated) Thread.Sleep(50); }