public class aaWaitWindow : aaBaseForm { private System.Windows.Forms.Label lblMessage; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; private string sMsg; private CMS.Main.Windows.Forms.aaTimer aaTimer1; private Form ParentWin; private int iTimeOutSeconds = 0; private int iElapsed = 0; public aaWaitWindow() { InitializeComponent(); } public string Message { set { this.lblMessage.Text = value; } get { return this.lblMessage.Text; } } public void Show(IWin32Window ParentWin, string sMessage, int iTimeOut) { this.iTimeOutSeconds = iTimeOut; this.aaTimer1.Start(); this.Show(ParentWin,sMessage); } /// <summary> /// Recommend overload to use /// </summary> /// <param name="ParentWin">The parent form</param> /// <param name="sMessage">Message to display</param> public void Show(IWin32Window ParentWin, string sMessage) { this.ParentWin = (Form) ParentWin; this.sMsg = sMessage; this.Show(); } public void Show(string sMessage, int iTimeOut) { this.iTimeOutSeconds = iTimeOut; this.aaTimer1.Start(); this.Show(sMessage); } /// <summary> /// If you use this overload, the message window will show up on the middle of the screen /// </summary> /// <param name="sMessage">Message to display</param> public void Show(string sMessage) { this.sMsg = sMessage; this.Show(); } /// <summary> /// Hide the wait window /// </summary> public void Clear() { this.Hide(); } /// <summary> /// Set the message and reposition the window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void aaWaitWindow_Activated(object sender, System.EventArgs e) { this.SuspendLayout(); this.lblMessage.Text = this.sMsg; this.Width = this.lblMessage.Width + 20; this.Height = this.lblMessage.Height; if (this.ParentWin != null) { this.Top = this.ParentWin.Top + 30; this.Left = this.ParentWin.Left + this.ParentWin.Width - this.Width - 30; // this.Top = this.ParentWin.MdiParent.Top + 30; // this.Left = this.ParentWin.MdiParent.Left + this.ParentWin.MdiParent.Width - this.Width - 30; } this.ResumeLayout(); } /// <summary> /// Hide the wait window when timeout /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void aaTimer1_Tick(object sender, System.EventArgs e) { this.iElapsed += 1000; if (this.iElapsed >= this.iTimeOutSeconds * 1000) { this.Clear(); this.aaTimer1.Stop(); this.iElapsed = 0; } } } }