private void cloneCurrentRow_Click(object sender, EventArgs e) { int num = (dataGridView.SelectedRows.Count == 1) ? dataGridView.SelectedRows[0].Index : dataGridView.SelectedCells[0].RowIndex; List <FieldInstance> newEntry = EditedFile.GetNewEntry(); createRow(newEntry, num); }
/* * Insert the previously given values into the db table. * A warning will be printed and no data added if the given data doesn't * fit the db file's structure. */ public override void Execute() { // insert always into packed files at the save to file foreach (PackedFile packed in PackedFiles) { // we'll read from packed, but that is in the source pack; // get or create the db file in the target pack DBFile targetFile = GetTargetFile(packed); foreach (RowValues insertValues in Source.Values) { if (targetFile.CurrentType.Fields.Count == insertValues.Count) { DBRow newRow = targetFile.GetNewEntry(); for (int i = 0; i < newRow.Count; i++) { newRow[i].Value = insertValues[i]; } targetFile.Entries.Add(newRow); } else { Console.WriteLine("Cannot insert: was given {0} values, expecting {1} in {2}", insertValues.Count, targetFile.CurrentType.Fields.Count, packed.FullPath); Console.WriteLine("Values: {0}", string.Join(",", insertValues)); } } // encode and store in target pack PackedFile newPacked = new PackedFile(packed.FullPath, false); newPacked.Data = PackedFileDbCodec.GetCodec(newPacked).Encode(targetFile); SaveTo.Add(newPacked, true); } }