public static string ShowBox(string txtMessage, string txtTitle) { newMessageBox = new InactivityMessageBox(); newMessageBox.lblMessage.Text = txtMessage; newMessageBox.Text = txtTitle; newMessageBox.ShowDialog(); return(Button_id); }
// Every predefined timer duration above a custom messagebox will appear // btnClicked == 1 is "Yes" while nothing happens when Cancel is clicked. private void TimerIdle_Tick(object sender, EventArgs e) { timerIdle.Stop(); string btnClicked = InactivityMessageBox.ShowBox("Do you want to log out?", "Inactivity noticed"); if (btnClicked == "1") { LoginForm log = new LoginForm(PoleSystem); Form currentForm = Form.ActiveForm; currentForm.Hide(); log.ShowDialog(); currentForm.Close(); } }