void DataGridView1RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { dataGridView1.ClearSelection(); int nRowIndex = dataGridView1.Rows.Count - 1; if (nRowIndex > 0) { dataGridView1.Rows[nRowIndex].Selected = true; dataGridView1.FirstDisplayedScrollingRowIndex = nRowIndex; } // print the label if (checkBox1.Checked) { if (((HostCommandStub)PluginContext.HostCommandStub).DoTrackPluginPresetFileFormat) { TrackPresetTextBox.Text = ""; byte[] trackedBytes = ((HostCommandStub)PluginContext.HostCommandStub).TrackPluginPresetFileBytes; BinaryFile.ByteOrder bOrder = BinaryFile.ByteOrder.BigEndian; bool invert = false; if (LittleEndianCheckBox.Checked) { bOrder = BinaryFile.ByteOrder.LittleEndian; invert = true; } TrackPresetTextBox.Text = StringUtils.ToHexAndAsciiString(trackedBytes, invert); int i = BinaryFile.ByteArrayToInt32(trackedBytes, bOrder); float f = BinaryFile.ByteArrayToSingle(trackedBytes, bOrder); double d = BinaryFile.ByteArrayToDouble(trackedBytes, bOrder); ValueTextBox.Text = String.Format("int: {0} float: {1:0.####E+000} double: {2:0.0000}", i, f, d); // store these values in a tracking list together with the ParameterDisplay Value string paramName = dataGridView1["ParameterName", nRowIndex].Value.ToString(); string paramValue = dataGridView1["ParameterDisplay", nRowIndex].Value.ToString().Trim(); var row = new InvestigatedPluginPresetFileFormat(0, 0, paramName, "", paramValue, String.Format("{0:00.0000}", f)); // store this in a xml ouput file. string xmlFilePath = "track-chunk-dump.xml"; if (File.Exists(xmlFilePath)) { // add to existing xml document if the entry does not exist from before. XDocument xmlDoc = XDocument.Load(xmlFilePath); var query = from r in xmlDoc.Element("TrackedPresetFileChanges") .Elements("Row") where r.Element("ParameterName").Value == paramName && r.Element("ParameterDisplay").Value == paramValue && Convert.ToSingle(r.Element("FloatValue").Value, CultureInfo.InvariantCulture) == f && Convert.ToInt32(r.Element("IntValue").Value) == i select r; if (query.Count() == 0) { xmlDoc.Element("TrackedPresetFileChanges").Add( new XElement("Row", new XElement("ParameterName", paramName), new XElement("ParameterDisplay", paramValue), new XElement("FloatValue", f), new XElement("IntValue", i))); xmlDoc.Save(xmlFilePath); } } else { // create xml document first var xmlDoc = new XDocument( new XElement("TrackedPresetFileChanges", new XElement("Row", new XElement("ParameterName", paramName), new XElement("ParameterDisplay", paramValue), new XElement("FloatValue", f), new XElement("IntValue", i)) ) ); xmlDoc.Save(xmlFilePath); } } } }