private void HandleExtractAllAction() { if (fileSystem == null) { return; } CustomFileChooserDialog dlg = new CustomFileChooserDialog( this, "Extract pack", FileChooserAction.SelectFolder); dlg.Ok += (sender, e) => { packStore.GetTopIters().ToList().ForEach(iterInPack => { Packer.Item item = packStore.GetValue(iterInPack, 0) as Packer.Item; if (item.IsFolder) { ExtractFolder(iterInPack, dlg.FileChooser.Filename); } else { ExtractFile(iterInPack, dlg.FileChooser.Filename + System.IO.Path.DirectorySeparatorChar + item.Name); } }); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void HandleOpenAction() { CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Open pack", FileChooserAction.Open); dlg.FileChooser.SelectMultiple = false; Packer.SupportedExtensions.ToList().ForEach(ext => { using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = ext.ToUpper(); filter.AddPattern("*." + ext); dlg.FileChooser.AddFilter(filter); } }); dlg.Ok += (sender, e) => { if (fileSystem != null) { fileSystem.Close(); } fileSystem = null; OpenPack(dlg.FileChooser.Filename); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void HandleAddFilesAction() { if (fileSystem == null) { return; } CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Add files to pack", FileChooserAction.Open); dlg.FileChooser.SelectMultiple = true; using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = "All"; filter.AddPattern("*.*"); dlg.FileChooser.AddFilter(filter); } dlg.Ok += (sender, e) => { packTreeView.Selection.UnselectAll(); waitWindow = new WaitWindow(this, "Adding", ""); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { dlg.Destroy(); waitWindow.Destroy(); waitWindow = null; })); new Thread(new ThreadStart(() => { dlg.FileChooser.Filenames.ToList().ForEach( file => AppendFile(currentFolder, file)); done.WakeupMain(); })).Start(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void HandleAddFolderAction() { if (fileSystem == null) { return; } CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Add folder to pack", FileChooserAction.SelectFolder); dlg.Ok += (sender, e) => { packTreeView.Selection.UnselectAll(); waitWindow = new WaitWindow(this, "Adding", ""); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; })); new Thread(new ThreadStart(() => { string path = dlg.FileChooser.Filename; dlg.Destroy(); Packer.Item folderItem = NewItem(currentFolder, path); TreeIter folderIter = AppendItem(currentFolder, folderItem); if (!TreeIter.Zero.Equals(folderIter)) { AppendFolders(folderIter, folderItem.HDDPath); } done.WakeupMain(); })).Start(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void HandleExtractAction() { if (fileSystem == null) { return; } int selectedCount = packTreeView.Selection.CountSelectedRows(); if (selectedCount == 0) { return; } List <TreeIter> selectedInFolder = packTreeView.GetSelected().ToList(); Packer.Item firstItem = folderStore.GetValue(selectedInFolder.First(), 2) as Packer.Item; if (selectedCount == 1 && !firstItem.IsFolder) { TreeIter iterInPack = FindInPack(firstItem); CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Extract file from pack", FileChooserAction.Save); dlg.FileChooser.CurrentName = firstItem.Name; using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = "All"; filter.AddPattern("*.*"); dlg.FileChooser.AddFilter(filter); } dlg.Ok += (sender, e) => { ExtractFile(iterInPack, dlg.FileChooser.Filename); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); } else { CustomFileChooserDialog dlg = new CustomFileChooserDialog( this, "Extract from pack", FileChooserAction.SelectFolder); dlg.Ok += (sender, e) => { selectedInFolder.ForEach(iter => { Packer.Item item = folderStore.GetValue(iter, 2) as Packer.Item; TreeIter iterInPack = FindInPack(item); if (item.IsFolder) { ExtractFolder(iterInPack, dlg.FileChooser.Filename); } else { ExtractFile(iterInPack, dlg.FileChooser.Filename + System.IO.Path.DirectorySeparatorChar + item.Name); } }); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); } }
private void HandleSaveAction() { if (fileSystem == null) { return; } CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Save pack", FileChooserAction.Save); dlg.FileChooser.SelectMultiple = false; using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = fileSystem.Extension.ToUpper(); filter.AddPattern("*." + fileSystem.Extension.ToLower()); dlg.FileChooser.AddFilter(filter); } using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = "All"; filter.AddPattern("*.*"); dlg.FileChooser.AddFilter(filter); } dlg.Ok += (sender, e) => { string filename = dlg.FileChooser.Filename; waitWindow = new WaitWindow(this, "Saving", filename); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; })); ThreadNotify error = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError); msg.Run(); msg.Destroy(); })); new Thread(new ThreadStart(() => { if (fileSystem.Save(filename)) { done.WakeupMain(); } else { error.WakeupMain(); } })).Start(); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }