/// <summary> /// Opens current entry in file list /// </summary> public void OpenSelectedEntry() { if (fileListView.SelectedItems.Count == 1) { Cursor = Cursors.WaitCursor; ListViewItem currentItem = fileListView.SelectedItems[0]; Object tag = currentItem.Tag; try { if (tag is FileSystemInfo) { // File or directory string path = ((tag as FileSystemInfo).FullName); try { _Refresh(path); CurrentFolder = path; } catch (NotImplementedException ex) { // Not applicable -> entry will be opened with default assos __SystemRun(path); } } else if (tag is PackedFile) { // Packed file -> it must be extracted first // Reloads BNK to get correct contents Bnk parentBnk = new Bnk { Name = CurrentFolder }; parentBnk.Read(); PackedFile updatedPackedFile = parentBnk.GetPackedFile((tag as PackedFile).Id); // TODO handle temporary folder string path = @"T:\COMMUN\" + updatedPackedFile.Name; Bnk.Extract(updatedPackedFile, path); // Opens with default file associations for now __SystemRun(path); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } finally { Cursor = Cursors.Default; } } }
/// <summary> /// Updates packed file info label /// </summary> private void _UpdatePackedInfo() { const string defaultLabel = "Please select a single packed file..."; const string labelFormat = "{0}: {1} bytes"; if (_Bank != null && contentsLst.SelectedItems.Count == 1) { PackedFile pf = _Bank.GetPackedFile((uint)contentsLst.SelectedIndex); packedFileInfoLbl.Text = string.Format(labelFormat, pf.Name, pf.Size); } else { packedFileInfoLbl.Text = defaultLabel; } }