Exemplo n.º 1
0
 //An event handler that executes when the "Modify Existing Flash Card" button is pressed
 private void btnModifyExistingFlashCard_Click(object sender, EventArgs e)
 {
     try
     {
         //Showing Dialog to select file
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             //opening and reading the file
             CreateAndModify frm = new CreateAndModify(ReadAndWriteToFile.readFromFile(openFileDialog.FileName),
                                                       openFileDialog.FileName.Split('\\').Last().Split('.').First()); //Gets the just the file name, not full path, and no extention
             //Displaying the 'CreateAndModify' form, with the cards inside of it
             frm.ShowDialog();
         }
     }
     catch (Exception err)
     {
         //Displaying the error that occurred
         MessageBox.Show("Error: " + err);
     }
 }
Exemplo n.º 2
0
 //An event handler that executes when the user click's on the save button
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         //Displaying dialogbox to user
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             //Checking to make sure the filename is not empty
             if (saveFileDialog.FileName != "")
             {
                 //Reading File and if there is no problems, show message
                 if (ReadAndWriteToFile.writeToFile(saveFileDialog.FileName, listOfCards))
                 {
                     MessageBox.Show("Your FlashCards have been saved!");
                 }
             }
         }
     }
     catch (Exception er)    //An error occurred, showing the message to the user
     {
         MessageBox.Show("Error: " + er.Message);
     }
 }