Exemplo n.º 1
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedfolder;
         openFileDialog1.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
         openFileDialog1.FileName         = txtExcuse.Text + ".txt";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             try
             {
                 currentExcuse = new Excuse(openFileDialog1.FileName);
                 try
                 {
                     UpdateForm(false);
                 }
                 catch (Exception)
                 {
                     MessageBox.Show("O arquivo de desculpas é inválido");
                     clearForm = true;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Um erro ocorreu durante a abertura da desculpa\n"
                                 + openFileDialog1.FileName + "\n" + ex.Message, "Impossível abrir desculpa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 clearForm = true;
             }
         }
Exemplo n.º 2
0
 private void btnRandom_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         currentExcuse = new Excuse(random, selectedfolder);
         UpdateForm(false);
     }
 }
Exemplo n.º 3
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedfolder;
         openFileDialog1.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
         openFileDialog1.FileName         = txtExcuse.Text + ".txt";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             currentExcuse = new Excuse(openFileDialog1.FileName);
             UpdateForm(false);
         }
     }
 }