コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
 public Form1()
 {
     InitializeComponent();
     notSavedChanges        = false;
     currentExcuse          = new Excuse();
     currentExcuse.LastUsed = lastUsed.Value;
     saveButton.Enabled     = false;
     openButton.Enabled     = false;
     randomButton.Enabled   = false;
 }
コード例 #3
0
 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);
     }
 }