void OnOpen(object sender, EventArgs e) { var fc = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); if (fc.Run() == (int)ResponseType.Accept) { if (!AppController.Instance.Surface.IsEmpty()) { string fileName = Process.GetCurrentProcess().MainModule.FileName.Replace(".vshost", ""); ProcessStartInfo info = new ProcessStartInfo(fileName); info.UseShellExecute = false; info.Arguments = fc.Filename; Process processChild = Process.Start(info); } else { AppController.Instance.FileName = fc.Filename; var saved = ConfigManager.Read <PrimitivesSurface> (AppController.Instance.FileName); AppController.Instance.ResetSurface(); AppController.Instance.ReloadSurface(saved); _grid.Surface = AppController.Instance.Surface; _grid.Surface.QueueDraw(); } } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
private static void SaveQuestionnaire(Ast current) { FileChooserDialog fc = new FileChooserDialog( "Select where to save questionnaire", null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save questionnaire", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); if (fc.Run() == (int)ResponseType.Accept) { File.WriteAllText(fc.Filename, current.SExpr()); } fc.Destroy(); }
private void AddButton_Clicked(object sender, EventArgs args) { using (FileChooserDialog fileChooser = new FileChooserDialog("Select update files", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept)) { fileChooser.SelectMultiple = true; fileChooser.SetPosition(WindowPosition.Center); fileChooser.Filter = new FileFilter(); fileChooser.Filter.AddPattern("*.nsp"); if (fileChooser.Run() == (int)ResponseType.Accept) { foreach (string path in fileChooser.Filenames) { AddUpdate(path); } } } }
void OnExportToPng(object sender, EventArgs e) { var fc = new FileChooserDialog("Enter the file to save", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); if (fc.Run() == (int)ResponseType.Accept) { _grid.ExportToPng(fc.Filename); Process.Start(fc.Filename); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
void OnSaveAs(object sender, EventArgs e) { var fc = new FileChooserDialog("Enter the file to save", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); if (fc.Run() == (int)ResponseType.Accept) { AppController.Instance.FileName = fc.Filename; ConfigManager.Write <PrimitivesSurface> (AppController.Instance.Surface, AppController.Instance.FileName); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
private static bool escolher(string filtro, string titulo, FileChooserAction acao, string textoAcao) { FileChooserDialog fcdialog = new FileChooserDialog(titulo, null, acao, "Cancelar", ResponseType.Cancel, textoAcao, ResponseType.Accept); fcdialog.SetPosition(WindowPosition.Center); montaFiltro(fcdialog, filtro); fcdialog.SelectMultiple = false; fcdialog.SetFilename(nomeArquivo); fcdialog.SetCurrentFolder(diretorioCorrente); int retorno = fcdialog.Run(); nomeArquivo = fcdialog.Filename; diretorioCorrente = fcdialog.CurrentFolder; fcdialog.Destroy(); return(retorno == (int)ResponseType.Accept); }
void OnSaveAs(object sender, EventArgs e) { var fc = new FileChooserDialog("Choose the file to save", _thisDialog, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); if (fc.Run() == (int)ResponseType.Accept) { _fileName = fc.Filename; System.IO.File.WriteAllText(_fileName, textview1.Buffer.Text); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
private void ProfileImageFileChooser() { FileChooserDialog fileChooser = new FileChooserDialog("Import Custom Profile Image", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Import", ResponseType.Accept) { SelectMultiple = false, Filter = new FileFilter() }; fileChooser.SetPosition(WindowPosition.Center); fileChooser.Filter.AddPattern("*.jpg"); fileChooser.Filter.AddPattern("*.jpeg"); fileChooser.Filter.AddPattern("*.png"); fileChooser.Filter.AddPattern("*.bmp"); if (fileChooser.Run() == (int)ResponseType.Accept) { ProcessProfileImage(File.ReadAllBytes(fileChooser.Filename)); } fileChooser.Dispose(); }
private static bool OpenQuestionnaire(Ast current) { FileChooserDialog fc = new FileChooserDialog( "Select questionnaire to open", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open questionnaire", ResponseType.Accept); fc.SetPosition(WindowPosition.Center); Ast next = null; while (fc.Run() == (int)ResponseType.Accept) { try { var parser = new Parser(QL, File.ReadAllText(fc.Filename)); next = parser.ParseAst(); break; } catch { } } fc.Destroy(); if (next != null) { if (current != null) { current.Widget().Toplevel.Destroy(); } UpdateQuestions(next); next.Render(); return(true); } else { return(false); } }
private void ExtractSection(NcaSectionType ncaSectionType) { FileChooserDialog fileChooser = new FileChooserDialog("Choose the folder to extract into", null, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Extract", ResponseType.Accept); fileChooser.SetPosition(WindowPosition.Center); int response = fileChooser.Run(); string destination = fileChooser.Filename; fileChooser.Dispose(); if (response == (int)ResponseType.Accept) { Thread extractorThread = new Thread(() => { string sourceFile = _gameTableStore.GetValue(_rowIter, 9).ToString(); Gtk.Application.Invoke(delegate { _dialog = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Cancel, null) { Title = "Ryujinx - NCA Section Extractor", Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png"), SecondaryText = $"Extracting {ncaSectionType} section from {System.IO.Path.GetFileName(sourceFile)}...", WindowPosition = WindowPosition.Center }; int dialogResponse = _dialog.Run(); if (dialogResponse == (int)ResponseType.Cancel || dialogResponse == (int)ResponseType.DeleteEvent) { _cancel = true; _dialog.Dispose(); } }); using (FileStream file = new FileStream(sourceFile, FileMode.Open, FileAccess.Read)) { Nca mainNca = null; Nca patchNca = null; if ((System.IO.Path.GetExtension(sourceFile).ToLower() == ".nsp") || (System.IO.Path.GetExtension(sourceFile).ToLower() == ".pfs0") || (System.IO.Path.GetExtension(sourceFile).ToLower() == ".xci")) { PartitionFileSystem pfs; if (System.IO.Path.GetExtension(sourceFile) == ".xci") { Xci xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage()); pfs = xci.OpenPartition(XciPartitionType.Secure); } else { pfs = new PartitionFileSystem(file.AsStorage()); } foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) { pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.AsStorage()); if (nca.Header.ContentType == NcaContentType.Program) { int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program); if (nca.Header.GetFsHeader(dataIndex).IsPatchSection()) { patchNca = nca; } else { mainNca = nca; } } } } else if (System.IO.Path.GetExtension(sourceFile).ToLower() == ".nca") { mainNca = new Nca(_virtualFileSystem.KeySet, file.AsStorage()); } if (mainNca == null) { Logger.PrintError(LogClass.Application, "Extraction failed. The main NCA was not present in the selected file."); Gtk.Application.Invoke(delegate { GtkDialog.CreateErrorDialog("Extraction failed. The main NCA was not present in the selected file."); }); return; } int index = Nca.GetSectionIndexFromType(ncaSectionType, mainNca.Header.ContentType); IFileSystem ncaFileSystem = patchNca != null ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid) : mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid); FileSystemClient fsClient = _virtualFileSystem.FsClient; string source = DateTime.Now.ToFileTime().ToString().Substring(10); string output = DateTime.Now.ToFileTime().ToString().Substring(10); fsClient.Register(source.ToU8Span(), ncaFileSystem); fsClient.Register(output.ToU8Span(), new LocalFileSystem(destination)); (Result? resultCode, bool canceled) = CopyDirectory(fsClient, $"{source}:/", $"{output}:/"); if (!canceled) { if (resultCode.Value.IsFailure()) { Logger.PrintError(LogClass.Application, $"LibHac returned error code: {resultCode.Value.ErrorCode}"); Gtk.Application.Invoke(delegate { _dialog?.Dispose(); GtkDialog.CreateErrorDialog("Extraction failed. Read the log file for further information."); }); } else if (resultCode.Value.IsSuccess()) { Gtk.Application.Invoke(delegate { _dialog?.Dispose(); MessageDialog dialog = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, null) { Title = "Ryujinx - NCA Section Extractor", Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png"), SecondaryText = "Extraction has completed successfully.", WindowPosition = WindowPosition.Center }; dialog.Run(); dialog.Dispose(); }); } } fsClient.Unmount(source.ToU8Span()); fsClient.Unmount(output.ToU8Span()); } }); extractorThread.Name = "GUI.NcaSectionExtractorThread"; extractorThread.IsBackground = true; extractorThread.Start(); } }
private void AddButton_Clicked(object sender, EventArgs args) { FileChooserDialog fileChooser = new FileChooserDialog("Select DLC files", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept) { SelectMultiple = true, Filter = new FileFilter() }; fileChooser.SetPosition(WindowPosition.Center); fileChooser.Filter.AddPattern("*.nsp"); if (fileChooser.Run() == (int)ResponseType.Accept) { foreach (string containerPath in fileChooser.Filenames) { if (!File.Exists(containerPath)) { return; } using (FileStream containerFile = File.OpenRead(containerPath)) { PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage()); bool containsDlc = false; _virtualFileSystem.ImportTickets(pfs); TreeIter?parentIter = null; foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) { pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); Nca nca = TryCreateNca(ncaFile.AsStorage(), containerPath); if (nca == null) { continue; } if (nca.Header.ContentType == NcaContentType.PublicData) { if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000).ToString("x16") != _titleId) { break; } parentIter ??= ((TreeStore)_dlcTreeView.Model).AppendValues(true, "", containerPath); ((TreeStore)_dlcTreeView.Model).AppendValues(parentIter.Value, true, nca.Header.TitleId.ToString("X16"), fileEntry.FullPath); containsDlc = true; } } if (!containsDlc) { GtkDialog.CreateErrorDialog("The specified file does not contain a DLC for the selected title!"); } } } } fileChooser.Dispose(); }