private void OpenButton_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = folderPath; openFileDialog1.Filter = "Pliki tekstowe (*.txt)|*.txt|" + "Wszystkie pliki (*.*)|*.*"; if (notSavedChanges) { if (MessageBox.Show("Bieżąca wymówka nie została zapisana. Czy kontynuować?", "Ostrzeżenie", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.No) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { currentExcuse = new Excuse(openFileDialog1.FileName); currentExcuse.ExcusePath = openFileDialog1.FileName; notSavedChanges = false; UpdateForm(notSavedChanges); } } } else { if (openFileDialog1.ShowDialog() == DialogResult.OK) { currentExcuse = new Excuse(openFileDialog1.FileName); currentExcuse.ExcusePath = openFileDialog1.FileName; notSavedChanges = false; UpdateForm(notSavedChanges); } } }
public Form1() { InitializeComponent(); notSavedChanges = false; currentExcuse = new Excuse(); currentExcuse.LastUsed = lastUsed.Value; saveButton.Enabled = false; openButton.Enabled = false; randomButton.Enabled = false; }
private void RandomButton_Click(object sender, EventArgs e) { if (notSavedChanges) { if (MessageBox.Show("Bieżąca wymówka nie została zapisana. Czy kontynuować?", "Ostrzeżenie", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.No) { Random random = new Random(); string[] filePaths = Directory.GetFiles(folderPath, "*.txt", SearchOption.AllDirectories); currentExcuse = new Excuse(filePaths, random); notSavedChanges = false; UpdateForm(notSavedChanges); } } else { Random random = new Random(); string[] filePaths = Directory.GetFiles(folderPath, "*.txt", SearchOption.AllDirectories); currentExcuse = new Excuse(filePaths, random); notSavedChanges = false; UpdateForm(notSavedChanges); } }