private void listView1_ItemDrag(object sender, ItemDragEventArgs e) { string fn = Path.Combine(Path.GetTempPath(), files[listView1.SelectedIndices[0]].name); File.WriteAllBytes(fn, Compress.ProcessBuffer(files[listView1.SelectedIndices[0]].file)); DoDragDrop(new DataObject(DataFormats.FileDrop, new string[] { fn }), DragDropEffects.All); }
private void LoadFile(string filename) { this.filename = Path.GetFullPath(filename); byte[] file = File.ReadAllBytes(filename); switch (System.Text.Encoding.ASCII.GetString(file, 0, 0x10)) { case "archive V2.2\0\0\0": is2010 = false; break; case "archive V2.DMZ\0": is2010 = true; break; default: MessageBox.Show("Error: Unknown archive version/type"); return; } int count = BitConverter.ToInt32(file, 0x10); files = new List <FENTRY>(count); listView1.Items.Clear(); imageList1.Images.Clear(); listView1.BeginUpdate(); for (int i = 0; i < count; i++) { files.Add(new FENTRY(file, 0x14 + (i * 0xC))); imageList1.Images.Add(GetIcon(files[i].name)); ListViewItem it = listView1.Items.Add(files[i].name, i); it.ForeColor = Compress.isFileCompressed(files[i].file) ? Color.Blue : Color.Black; } listView1.EndUpdate(); Text = "SADXsndSharp - " + Path.GetFileName(filename); saveToolStripMenuItem.Enabled = true; }
private void listView1_ItemActivate(object sender, EventArgs e) { string fp = Path.Combine(Path.GetTempPath(), files[listView1.SelectedIndices[0]].name); File.WriteAllBytes(fp, Compress.ProcessBuffer(files[listView1.SelectedIndices[0]].file)); System.Diagnostics.Process.Start(fp); }
private void RefreshListView(View view) { listView1.Items.Clear(); imageList1.Images.Clear(); imageList2.Images.Clear(); listView1.BeginUpdate(); for (int j = 0; j < files.Count; j++) { Text = $"SADXsndSharp - Loading item " + j.ToString() + " of " + files.Count.ToString() + ", please wait..."; if (view == View.LargeIcon || view == View.Tile) { imageList1.Images.Add(GetIcon(files[j].name, false)); } else { imageList2.Images.Add(GetIcon(files[j].name, true)); } ListViewItem it = listView1.Items.Add(files[j].name, j); it.SubItems.Add(files[j].file.Length.ToString()); it.SubItems.Add(j.ToString()); it.ForeColor = Compress.isFileCompressed(files[j].file) ? Color.Blue : Color.Black; } listView1.View = view; listView1.EndUpdate(); Text = "SADXsndSharp - " + Path.GetFileName(filename); }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedItem == null) { return; } using (OpenFileDialog a = new OpenFileDialog() { DefaultExt = "wav", Filter = "WAV Files|*.wav|ADX Files|*.adx|All Files|*.*", Multiselect = true }) if (a.ShowDialog() == DialogResult.OK) { int i = listView1.Items.IndexOf(selectedItem); foreach (string item in a.FileNames) { files.Insert(i, new FENTRY(item)); i++; } listView1.Items.Clear(); imageList1.Images.Clear(); listView1.BeginUpdate(); for (int j = 0; j < files.Count; j++) { imageList1.Images.Add(GetIcon(files[j].name)); ListViewItem it = listView1.Items.Add(files[j].name, j); it.ForeColor = Compress.isFileCompressed(files[j].file) ? Color.Blue : Color.Black; } listView1.EndUpdate(); } }
private void replaceToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedItem == null) { return; } int i = int.Parse(selectedItem.SubItems[2].Text); string fn = files[i].name; using (OpenFileDialog a = new OpenFileDialog() { DefaultExt = "wav", Filter = "WAV Files|*.wav|ADX Files|*.adx|All Files|*.*", FileName = fn }) if (a.ShowDialog() == DialogResult.OK) { files[i] = new FENTRY(a.FileName); if (files[i].name != fn) { DialogResult mb = MessageBox.Show("Keep original filename " + fn + "?", "Keep filename?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (mb == DialogResult.Yes) { files[i].name = fn; } } selectedItem.ForeColor = Compress.isFileCompressed(files[i].file) ? Color.Blue : Color.Black; unsaved = true; RefreshListView(mainView); } }
private void extractAllToolStripMenuItem_Click(object sender, EventArgs e) { using (SaveFileDialog a = new SaveFileDialog() { DefaultExt = "", Filter = "", FileName = "soundpack" }) { if (filename != null) { a.InitialDirectory = Path.GetDirectoryName(filename); a.FileName = Path.GetFileNameWithoutExtension(filename); } if (a.ShowDialog(this) == DialogResult.OK) { Directory.CreateDirectory(a.FileName); } string dir = Path.Combine(Path.GetDirectoryName(a.FileName), Path.GetFileName(a.FileName)); using (StreamWriter sw = File.CreateText(Path.Combine(dir, "index.txt"))) { List <FENTRY> list = new List <FENTRY>(files); list.Sort((f1, f2) => StringComparer.OrdinalIgnoreCase.Compare(f1.name, f2.name)); foreach (FENTRY item in list) { Text = $"SADXsndSharp - Saving item " + list.IndexOf(item) + " of " + files.Count.ToString() + ", please wait..."; sw.WriteLine(item.name); File.WriteAllBytes(Path.Combine(dir, item.name), Compress.ProcessBuffer(item.file)); } sw.Flush(); sw.Close(); } Text = "SADXsndSharp - " + Path.GetFileName(filename); } }
private void listView1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] dropfiles = (string[])e.Data.GetData(DataFormats.FileDrop, true); int i = files.Count; foreach (string item in dropfiles) { files.Add(new FENTRY(item)); imageList1.Images.Add(GetIcon(files[i].name)); ListViewItem it = listView1.Items.Add(files[i].name, i); it.ForeColor = Compress.isFileCompressed(files[i].file) ? Color.Blue : Color.Black; i++; } } }
private void extractToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedItem == null) { return; } using (SaveFileDialog a = new SaveFileDialog() { DefaultExt = "wav", Filter = "WAV Files|*.wav|ADX Files|*.adx|All Files|*.*", FileName = selectedItem.Text }) if (a.ShowDialog() == DialogResult.OK) { File.WriteAllBytes(a.FileName, Compress.ProcessBuffer(files[listView1.Items.IndexOf(selectedItem)].file)); } }
private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog a = new OpenFileDialog() { DefaultExt = "wav", Filter = "WAV Files|*.wav|ADX Files|*.adx|All Files|*.*", Multiselect = true }) if (a.ShowDialog() == DialogResult.OK) { int i = files.Count; foreach (string item in a.FileNames) { files.Add(new FENTRY(item)); imageList1.Images.Add(GetIcon(files[i].name)); ListViewItem it = listView1.Items.Add(files[i].name, i); it.ForeColor = Compress.isFileCompressed(files[i].file) ? Color.Blue : Color.Black; i++; } } }
private void replaceToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedItem == null) { return; } int i = listView1.Items.IndexOf(selectedItem); string fn = files[i].name; using (OpenFileDialog a = new OpenFileDialog() { DefaultExt = "wav", Filter = "WAV Files|*.wav|ADX Files|*.adx|All Files|*.*", FileName = fn }) if (a.ShowDialog() == DialogResult.OK) { files[i] = new FENTRY(a.FileName); files[i].name = fn; selectedItem.ForeColor = Compress.isFileCompressed(files[i].file) ? Color.Blue : Color.Black; } }
private void extractAllToolStripMenuItem_Click(object sender, EventArgs e) { using (FolderBrowserDialog a = new FolderBrowserDialog() { ShowNewFolderButton = true }) { if (filename != null) { a.SelectedPath = Path.GetDirectoryName(filename); } if (a.ShowDialog(this) == DialogResult.OK) { using (StreamWriter sw = File.CreateText(Path.Combine(a.SelectedPath, "index.txt"))) { List <FENTRY> list = new List <FENTRY>(files); list.Sort((f1, f2) => StringComparer.OrdinalIgnoreCase.Compare(f1.name, f2.name)); foreach (FENTRY item in list) { sw.WriteLine(item.name); File.WriteAllBytes(Path.Combine(a.SelectedPath, item.name), Compress.ProcessBuffer(item.file)); } sw.Flush(); sw.Close(); } } } }