/// <summary> /// This menu command allows the user to multi-select a handful of gesture XML files from a directory, and /// to produce an output file containing the recognition results for everything in the directory. /// </summary> /// <param name="sender">The sender of this event.</param> /// <param name="e">The arguments for this event.</param> /// <remarks> /// The gestures loaded must conform to a naming convention where each example of a particular gesture is named /// with the same string, followed by a numerical identifier for that example. As in: /// /// circle01.xml // circle gestures /// circle02.xml /// circle03.xml /// square01.xml // square gestures /// square02.xml /// square03.xml /// triangle01.xml // triangle gestures /// triangle02.xml /// triangle03.xml /// /// The same number of examples should be read in for each gesture category. The testing procedure will load a /// random subset of each gesture and test on the remaining gestures. /// /// <b>Warning.</b> This process will throw an exception if the number of gesture examples for each gesture is /// unbalanced. /// </remarks> private void TestBatch_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Gestures (*.xml)|*.xml"; dlg.Title = "Load Gesture Batch"; dlg.Multiselect = true; dlg.RestoreDirectory = false; if (dlg.ShowDialog(this) == DialogResult.OK) { InfoForm ifrm = new InfoForm(); if (ifrm.ShowDialog(this) == DialogResult.OK) { prgTesting.Visible = true; lblRecognizing.Visible = true; Application.DoEvents(); // each slot in the list contains a gesture Category, which contains a list of gesture prototypes. List <Category> categories = _rec.AssembleBatch(dlg.FileNames); if (categories != null) { string[] rstr = _rec.TestBatch( ifrm.Subject.ToString(), ifrm.Speed, categories, dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\')), _protractor ); if (rstr != null) { MessageBox.Show(this, "Testing complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, "There was an error writing the output file during testing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else // error assembling batch { MessageBox.Show(this, "Unreadable files, or unbalanced number of gestures in categories.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } lblRecognizing.Visible = false; prgTesting.Visible = false; } } }