private void MailClientForm_Shown(object sender, EventArgs e) { // Give the webbrowser a grayish background after is is shown. webBrowserView.DocumentText = "<body bgcolor='#FAFAFA'>"; // Instantiate the loginform. loginForm = new LoginForm(); // Show the loginform as a dialog, so the user cannot access the other form. loginForm.ShowDialog(); }
private void labelStatus_ForeColorChanged(object sender, EventArgs e) { // Check if the programs status is either login- or settingsaccepted. if (programStatus == ProgramStatus.LoginAccepted || programStatus == ProgramStatus.SettingAccepted) { // Create a thread delegate which matches the function: "StartConnection". Thread threadMailClient = new Thread(StartConnection); // Tell the thread to run in the background so that is stops when the main thread is stopped. threadMailClient.IsBackground = true; // Start the thread. threadMailClient.Start(); } // Check if the programs status is in error. else if (programStatus == ProgramStatus.Error) { // Check if it is the user credentials that fails. if (labelStatus.Text.Contains("user credentials")) { // Instantiate the loginform with a new instance. loginForm = new LoginForm(); // Show the loginform as a dialog, so the user cannot access the other form. loginForm.ShowDialog(); } // Check if something else is wrong. else if (labelStatus.Text != "Disconnected") { // Instantiate the settingsform, assuming that these are wrong. settingsForm = new SettingsForm(); // Show the settingsform as a dialog, so the user cannot access the other form. settingsForm.ShowDialog(); } } // Check if the programs status is at timeout. else if (programStatus == ProgramStatus.TimeOut) { // Declare and initialize a variable for the amount of mails in the database. int dbMailCount = mailDatabase.ReadMailCount(textBoxMail.Text); // Retrieve the datetime for the latest mail. newestMailDateTime = mailDatabase.ReadMail(textBoxMail.Text, dbMailCount).Headers.DateSent; // Check if any new mails is present on the server. connectToServer.RefreshConnection(newestMailDateTime); // Reset the timeout counter again. timeOutCounter = 0; } // Make sure that the timeoutcounter is reset once in a while. if (programStatus != ProgramStatus.TimeOut) // Reset the timeout counter again. timeOutCounter = 0; }