/// <summary> /// Event handler for double click on a file item in the file list. /// The clicked file are executed and the results from the calculations are shown in the result list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstFiles_MouseDoubleClick(object sender, MouseEventArgs e) { //Find the location of the double click. int index = lstFiles.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { //The location corresponded to an item. //Run the script file. FileEditor editor = fm.ChangeFile(index); ScriptFileEvaluator fileEvaluator = new ScriptFileEvaluator(editor.ReadFileContents()); List <ExpressionItem> list = new List <ExpressionItem>(); try { //Try to evaluate and print the rows in the script file. fileEvaluator.Evaluate(out list); PrintValues(list); } catch (Exception ex) { //All rows weren't possible to evaluate. //Print the rows that were evaluated and display an error message. PrintValues(list); lstResultList.Items.Add(String.Format(" error: {0}", ex.Message)); } } lstResultList.Items.Add(String.Empty); UpdateGUI(); }
/// <summary> /// Initializez the GUI with the file contents. /// </summary> private void InitializeGUI() { //Sets the form title to the filename Text = file.ToString(); //Add the file contents to the form. txtEditor.Text = file.ReadFileContents().Trim(); }