private void extractSelectedFilesToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; foreach (ListViewItem item in mainListView.SelectedItems) { try { BarnFile bf = item.Tag as BarnFile; int index = bf.Index; if (bf.Extension == "BMP" && convertBitmapsToolStripMenuItem.Checked) { byte[] data = BarnManager.ExtractData(bf.Index); GK3Bitmap bmp = new GK3Bitmap(data); bmp.Save(BarnManager.ExtractPath + bf.Name); bmp.Dispose(); } else { BarnManager.Extract(index); } } catch (System.IO.FileNotFoundException) { // FileNotFoundException most likely means the barn the file // is in could not be found. string filename = BarnManager.GetFileName((int)item.Tag); DialogResult result = MessageBox.Show("Unable to extract " + filename + Environment.NewLine + "Continue extracting the rest of the files?", "Error extracting file", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.No) { break; } } } Cursor.Current = Cursors.Default; }
void mnuFile_Extract_Clicked(object o, EventArgs args) { TreePath[] paths; TreeModel model; paths = mainListBox.Selection.GetSelectedRows(out model); foreach (TreePath path in paths) { TreeIter itr; if (model.GetIter(out itr, path) == true) { uint index = (uint)model.GetValue(itr, 0); Console.Write("Extracting... "); BarnManager.Extract(index); Console.WriteLine("Done!"); } } }