Exemplo n.º 1
0
 public void OpenFile(string excusePath)
 {
     using (Stream input = File.OpenRead(excusePath))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         Excuse          temp = (Excuse)bf.Deserialize(input);
         this.Description = temp.Description;
         this.LastUsed    = temp.LastUsed;
         this.Results     = temp.Results;
     }
 }
Exemplo n.º 2
0
 private void Open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = currentFolder;
         openFileDialog1.Filter           = "Excuse Files|*.excuse";
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             bool clearForm = false;
             try
             {
                 currentExcuse = new Excuse(openFileDialog1.FileName);
                 try
                 {
                     UpdateForm(false);
                 }
                 catch (ArgumentOutOfRangeException
                        )
                 {
                     clearForm = true;
                 }
             }
             catch (SerializationException)
             {
                 MessageBox.Show("The excuse file '" + openFileDialog1.FileName + "' is invalid");
                 clearForm = true;
             }
             finally
             {
                 if (clearForm)
                 {
                     currentExcuse.Description = "";
                     currentExcuse.Results     = "";
                     currentExcuse.LastUsed    = DateTime.Now;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 private void Random_Click(object sender, EventArgs e)
 {
     currentExcuse = new Excuse(random, currentFolder);
     UpdateForm(false);
 }