public static DialogResult Show(string message, string caption, MessageAlertButtons button) { MessageAlert m = new MessageAlert(); m.lblMessage.Text = message; m.Text = caption; // Set lblMessage position,size , hide pictureBoxIcon m.pictureBoxIcon.SetBounds(0, 0, 0, 0); m.lblMessage.SetBounds(m.lblMessage.Location.X - 55, m.lblMessage.Location.Y, m.lblMessage.ClientSize.Width + 55, m.lblMessage.ClientSize.Height); switch (button) { case MessageAlertButtons.OK: m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; break; case MessageAlertButtons.OK_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; m.btnCancel.Visible = true; break; case MessageAlertButtons.YES: m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; break; case MessageAlertButtons.YES_NO: m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height); m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; m.btnNo.Visible = true; break; case MessageAlertButtons.RETRY_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height); m.btnRetry.Visible = true; m.btnCancel.Visible = true; break; default: break; } return(m.ShowDialog()); }
public static DialogResult Show(string message, string caption, MessageAlertButtons button, MessageAlertIcons icon) { MessageAlert m = new MessageAlert(); m.lblMessage.Text = message; m.Text = caption; m.setIconImage(icon); switch (button) { case MessageAlertButtons.OK: m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; break; case MessageAlertButtons.OK_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; m.btnCancel.Visible = true; m.btnCancel.Focus(); break; case MessageAlertButtons.YES: m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; break; case MessageAlertButtons.YES_NO: m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height); m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; m.btnNo.Visible = true; break; case MessageAlertButtons.RETRY_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height); m.btnRetry.Visible = true; m.btnCancel.Visible = true; m.btnCancel.Focus(); break; default: break; } return(m.ShowDialog()); }
public static DialogResult Show(string message, string caption, MessageAlertButtons button, MessageAlertIcons icon) { MessageAlert m = new MessageAlert(); m.lblMessage.Text = message; m.Text = caption; m.setIconImage(icon); switch (button) { case MessageAlertButtons.OK: m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; break; case MessageAlertButtons.OK_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; m.btnCancel.Visible = true; m.btnCancel.Focus(); break; case MessageAlertButtons.YES: m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; break; case MessageAlertButtons.YES_NO: m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height); m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; m.btnNo.Visible = true; break; case MessageAlertButtons.RETRY_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height); m.btnRetry.Visible = true; m.btnCancel.Visible = true; m.btnCancel.Focus(); break; default: break; } return m.ShowDialog(); }
public static DialogResult Show(string message, string caption, MessageAlertButtons button) { MessageAlert m = new MessageAlert(); m.lblMessage.Text = message; m.Text = caption; // Set lblMessage position,size , hide pictureBoxIcon m.pictureBoxIcon.SetBounds(0, 0, 0, 0); m.lblMessage.SetBounds(m.lblMessage.Location.X - 55, m.lblMessage.Location.Y, m.lblMessage.ClientSize.Width + 55, m.lblMessage.ClientSize.Height); switch (button) { case MessageAlertButtons.OK: m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; break; case MessageAlertButtons.OK_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnOK.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnOK.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnOK.Height) / 2), m.btnOK.Width, m.btnOK.Height); m.btnOK.Visible = true; m.btnCancel.Visible = true; break; case MessageAlertButtons.YES: m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; break; case MessageAlertButtons.YES_NO: m.btnNo.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnNo.Height) / 2), m.btnNo.Width, m.btnNo.Height); m.btnYes.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnNo.Width + 10 + m.btnYes.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnYes.Height) / 2), m.btnYes.Width, m.btnYes.Height); m.btnYes.Visible = true; m.btnNo.Visible = true; break; case MessageAlertButtons.RETRY_CANCEL: m.btnCancel.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnCancel.Height) / 2), m.btnCancel.Width, m.btnCancel.Height); m.btnRetry.SetBounds(m.panelBtn.ClientSize.Width - (10 + m.btnCancel.Width + 10 + m.btnRetry.Width), Convert.ToInt32((m.panelBtn.ClientSize.Height - m.btnRetry.Height) / 2), m.btnRetry.Width, m.btnRetry.Height); m.btnRetry.Visible = true; m.btnCancel.Visible = true; break; default: break; } return m.ShowDialog(); }