// otwieranie okna z treścią wiadomości private void displayEmailBody(ListView listView) { ListViewItem selected = listView.SelectedItems[0]; IEmailMessage selectedMessage = selected.Tag as IEmailMessage; string msgText = selectedMessage.Content != null ? selectedMessage.Content : "the email is empty"; MyMessageBox.display(msgText); }
private void DeleteAccountButton_Click(object sender, EventArgs e) { MyMessageBoxResults result = MyMessageBox.display("Usunąć zaznaczone konto?", MyMessageBoxType.YesNo); if (result == MyMessageBoxResults.Yes) { string accountName = getAccountName(); accountConfigsDict.Remove(accountName); ClearThisForm(); } }
private void ClearEmailsButton_Click(object sender, EventArgs e) { if (MyMessageBox.display("Deleting all emails from the data file. Account setting will not be changed. Proceed?", MyMessageBoxType.YesNo) == MyMessageBoxResults.Yes) { foreach (EmailAccount account in emailAccountDict.Values) { account.clearData(); } } saveDataToFile(); }
private bool validateUserInput() { try { checkEmailTimespan = validate(checkEmailTimerTextbox.Text); notificationFrequency = validate(notificationTimerTextbox.Text); numberOfEmailsKept = validate(numberOfEmailsKeptTextbox.Text); emailNumberAtSetup = validate(numberOfEmailsAtSetupTextBox.Text); } catch (ArgumentException ex) { MyMessageBox.display(ex.Message, MyMessageBoxType.Error); } return(true); }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); //Application.Run(new Form1()); } catch (System.Reflection.TargetInvocationException ex) { MyMessageBox.display(ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace); } }
// czyta dane kont pocztowych z pliku private void readDataFromFile(string fileName) { DataBundle dataBundle; try { using (FileStream fileStream = new FileStream(fileName, FileMode.Open)) { byte[] buffer = new byte[fileStream.Length]; using (BinaryReader binReader = new BinaryReader(fileStream)) { buffer = binReader.ReadBytes(buffer.Length); } MemoryStream originalStream = new MemoryStream(buffer); MemoryStream decompressedStream = new MemoryStream(); using (GZipStream gzStream = new GZipStream(originalStream, CompressionMode.Decompress)) { gzStream.CopyTo(decompressedStream); } originalStream.Close(); BinaryFormatter formatter = new BinaryFormatter(); decompressedStream.Position = 0; dataBundle = (DataBundle)formatter.Deserialize(decompressedStream); decompressedStream.Close(); } this.emailAccountDict = dataBundle.mailBoxes; this.emailsToBeDeletedDict = dataBundle.emailsToBeDeletedDict; ProgramSettings.checkEmailTimespan = dataBundle.checkEmailTimespan; ProgramSettings.numberOfEmailsKept = dataBundle.numberOfEmailsKept; ProgramSettings.showNotificationTimespan = dataBundle.showNotificationTimespan; //ProgramSettings.numberOfEmailsAtSetup = dataBundle. } catch (System.IO.InvalidDataException exc) { MyMessageBox.display("błąd odczytu z pliku danych\r\n" + exc.Message + "\r\n" + exc.StackTrace, MyMessageBoxType.Error); } catch (System.InvalidCastException ex) { MyMessageBox.display("błąd odczytu z pliku danych\r\n" + ex.Message + "\r\n" + ex.StackTrace, MyMessageBoxType.Error); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MyMessageBox.display("This will exit the application, monitoring of email accounts will stop. Proceed?", MyMessageBoxType.YesNo) == MyMessageBoxResults.Yes) { this.cancellationTokenSource.Cancel(); if (emailsDeletedFromServer) { saveDataToFile(); } if (emailsDisplayed != EmailListType.none) { closeEmailsDisplayWindow(); } } else { e.Cancel = true; } }
private void saveButton_Click(object sender, EventArgs e) { try { if (saveButtonClickedEvent != null) { if (addOrUpdateAccountConfiguration() || accountConfigsDict.Count > 0) { ConfigurationFormEventArgs args = new ConfigurationFormEventArgs(); args.emailAccountConfigs = this.accountConfigsDict; saveButtonClickedEvent(this, args); } } } catch (ArgumentException exc) { MyMessageBox.display(exc.Message + "\r\n" + exc.InnerException, MyMessageBoxType.Error); } }
// ręczne sprawdzanie poczty private async void checkForEmailsButton_Click(object sender, EventArgs e) { try { if (emailsDisplayed != EmailListType.none) { closeEmailsDisplayWindow(); } if (await checkForEmails()) { saveDataToFile(); displayNewEmails(); } else { MyMessageBox.displayAndClose("no new messages"); } } catch (ArgumentException exc) { MyMessageBox.display(exc.Message, MyMessageBoxType.Error); } }
private void InfoButton_Click(object sender, EventArgs e) { MyMessageBox.display(infoButtonMessage); }