Пример #1
0
 /// <summary>
 /// When the user enters a name for the experiment, this name is verified if it valid (That means, it is checked
 /// if the folder already exists.)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void fileNameTextBox_TextChanged(object sender, EventArgs e)
 {
     if (!fileNameTextBox.Text.Equals("") && !Directory.Exists(FileGenerator.getInstance().ExperimentDir + @"\" + fileNameTextBox.Text))
     {
         fileExistsLabel.Text = "";
         if (!okButton.Enabled)
         {
             okButton.Enabled = true;
         }
         if (deleteButton.Enabled)
         {
             deleteButton.Enabled = false;
         }
     }
     else
     {
         if (okButton.Enabled)
         {
             okButton.Enabled = false;
         }
         if (!deleteButton.Enabled)
         {
             deleteButton.Enabled = true;
         }
         fileExistsLabel.Text = "Experiment name already exists.";
     }
 }
Пример #2
0
 /// <summary>
 /// Display a pop-up window which waits for a valid name of the experiment and starts the creation process.
 /// </summary>
 /// <param name="experiment">The experiment dataa</param>
 public NameForm(ExperimentDescriptor experiment)
 {
     InitializeComponent();
     this.experiment = experiment;
     FileGenerator.getInstance().createDefaultDir();
     FileGenerator.getInstance().createSubDirs();
 }
Пример #3
0
 /// <summary>
 /// Calls the save-as function, after displaying the save-as file dialog.
 /// </summary>
 /// <param name="sender">Not used</param>
 /// <param name="e">Not used</param>
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         FileGenerator.getInstance().saveExperiment(experiment, saveFileDialog.FileName);
     }
 }
Пример #4
0
 /// <summary>
 /// Calls the save or save-as function, depending if a filename is defined.
 /// </summary>
 /// <param name="sender">Not used</param>
 /// <param name="e">Not used</param>
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!actualFilename.Equals(""))
     {
         FileGenerator.getInstance().saveExperiment(experiment, actualFilename);
     }
     else
     {
         saveAsToolStripMenuItem_Click(sender, e);
     }
 }
Пример #5
0
 /// <summary>
 /// Starts the deletion of an existing experiment folder.
 /// </summary>
 /// <param name="sender">Not used</param>
 /// <param name="e">Not used</param>
 private void deleteBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     //BackgroundWorker deleteWorker = sender as BackgroundWorker;
     try
     {
         Directory.Delete(FileGenerator.getInstance().ExperimentDir + @"\" + (string)e.Argument, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Can't delete Folder - Are still files in use?", "Error deleting folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Пример #6
0
 /// <summary>
 /// After clicking on OK, the creation of folders and files for the experiment can be started. (In a parallel thread).
 /// </summary>
 /// <param name="sender">Not used</param>
 /// <param name="e">Not used</param>
 private void okButton_Click(object sender, EventArgs e)
 {
     if (!fileNameTextBox.Text.Equals("") && !Directory.Exists(FileGenerator.getInstance().DefaultDir + fileNameTextBox.Text))
     {
         okButton.Enabled          = false;
         cancelButton.Enabled      = false;
         fileExistsLabel.ForeColor = Color.Black;
         fileExistsLabel.Text      = "Please wait while files are being created.";
         fileExistsLabel.Update();
         experiment.ExperimentName   = fileNameTextBox.Text;
         experiment.ExperimentFolder = FileGenerator.getInstance().ExperimentDir + @"\" + fileNameTextBox.Text;
         backgroundWorker.RunWorkerAsync(experiment);
     }
 }
Пример #7
0
 /// <summary>
 /// Displays the open-file dialog and load the experiment data in this file.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             actualFilename = openFileDialog.FileName;
             experiment     = FileGenerator.getInstance().loadExperiment(actualFilename);
         }
         updateTrialList();
     }
     catch (Exception ex)
     {
         actualFilename = "";
     }
 }
Пример #8
0
 /// <summary>
 /// The generation of the files in a parallel Thread.
 /// </summary>
 /// <param name="sender">Not used</param>
 /// <param name="e">Not used</param>
 private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     //BackgroundWorker worker = sender as BackgroundWorker;
     FileGenerator.getInstance().generateSessionFiles((ExperimentDescriptor)(e.Argument));
 }