Пример #1
0
 private void randomExcuse_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         currentExcuse = new Excuse(random, selectedFolder);
         UpdateForm(false);
     }
 }
Пример #2
0
 private void open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.Filter           =
             "Excuse files (*.excuse)|*.excuse|All files (*.*)|*.*";
         openFileDialog1.FileName = description.Text + ".excuse";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             bool clearForm = false;
             try
             {
                 currentExcuse = new Excuse(openFileDialog1.FileName);
                 try
                 {
                     UpdateForm(false);
                 }
                 catch
                 {
                     MessageBox.Show("The excuse file ‘"
                                     + openFileDialog1.FileName + "’ is invalid",
                                     "Unable to open the excuse");
                     clearForm = true;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("An error occurred while opening the excuse ‘"
                                 + openFileDialog1.FileName + "’\n" + ex.Message,
                                 "Unable to open the excuse", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
                 clearForm = true;
             }
             finally
             {
                 if (clearForm)
                 {
                     description.Text = "";
                     results.Text     = "";
                     lastUsed.Value   = DateTime.Now;
                 }
             }
         }
     }
 }