private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (OpenFileDia.ShowDialog() == DialogResult.OK) { if (Path.GetExtension(OpenFileDia.FileName) == ".torrent") { Torrent newTorrent = OpenAndParse(OpenFileDia.FileName); if (newTorrent != null) { var InfoWindow = new TorrentInfo(this, newTorrent); InfoWindow.Show(); } } else if (Path.GetExtension(OpenFileDia.FileName) == ".session") { try { var dictionary = standardParser.Parse <BDictionary>(File.ReadAllBytes(OpenFileDia.FileName)); string rootSessionPath = Path.GetDirectoryName(OpenFileDia.FileName) + Path.DirectorySeparatorChar; Torrent newTorrent = OpenAndParse(rootSessionPath + dictionary.First().Key.ToString()); if (newTorrent != null) { ParseSession(dictionary, newTorrent, rootSessionPath); AddNewViewListEntry(filesList.Last.Value); if (filesList.Last.Value.filesCorrupted) { UpdateStatus(filesList.Last.Value, FILESCORRUPTEDMSG); } else { UpdateProgress(filesList.Last.Value); } } } catch { MessageBox.Show(this, "This session file cannot be accessed or is corrupted and cannot be read:\r\n" + OpenFileDia.FileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void OpenFileStrip_Click(object sender, EventArgs e) { if (OpenFileDia.ShowDialog() == DialogResult.OK) { var fname = OpenFileDia.FileName; var nwext = Path.GetFileNameWithoutExtension(OpenFileDia.FileName); var ext = Path.GetExtension(OpenFileDia.FileName); var dir = Path.GetDirectoryName(OpenFileDia.FileName); if (ext == ".bfres") { if (model != null) { model.Exit(); } LoadBFRES(OpenFileDia.FileName); } else if (ext == ".cmp") { bool allow = true; if (model != null) { if (nwext == Path.GetFileName(model.FileName)) { //oh boy this looks bad let's not do this allow = false; MessageBox.Show("File is currently loaded, cannot decompress.", "CMP File", MessageBoxButtons.OK); } } if (allow) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "cmd.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = "/C cd " + Directory.GetCurrentDirectory() + "/tools" + "&" + " quickbms -o KirbyStarAllies-Decompress.bms " + fname + " " + dir; using (var Proc = Process.Start(startInfo)) { Proc.WaitForExit(); } var resp = MessageBox.Show("File decompressed. Want to load the file?", "CMP File", MessageBoxButtons.YesNo); if (resp == DialogResult.Yes) { if (model != null) { model.Exit(); } LoadBFRES(dir + "/" + nwext); } } } else { MessageBox.Show("The file you selected is not .bfres or .cmp", "Invalid File Type", MessageBoxButtons.OK); } } }