public static string DialogFile(string heading = default) { string result = null; Gtk.FileChooserDialog OpenDialog = new Gtk.FileChooserDialog(heading, null, Gtk.FileChooserAction.Save, "Open", Gtk.FileChooserAction.Open); OpenDialog.SetPosition(Gtk.WindowPosition.CenterAlways); if (OpenDialog.Run() == (int)Gtk.FileChooserAction.Open) { result = OpenDialog.Filename; OpenDialog.Dispose(); } OpenDialog.Dispose(); return(result); }
private void OpenImage() { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Load image", gtkWin, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept) { Filter = new FileFilter() }; fc.Filter.AddPattern("*.jpg"); fc.Filter.AddPattern("*.png"); fc.Filter.AddPattern("*.bmp"); fc.LocalOnly = false; if (fc.Run() == (int)Gtk.ResponseType.Accept) { attentionHandler.OpenImage(fc.Filename, true); manager.SaveConfig(); LoadImageInformation(); } //Destroy() to close the File Dialog fc.Dispose(); }
private void ButtonOpen_Clicked(object sender, EventArgs a) { Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Выберете файл", null, Gtk.FileChooserAction.Open); fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); fcd.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok); fcd.DefaultResponse = Gtk.ResponseType.Ok; fcd.SelectMultiple = true; Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run(); if (response == Gtk.ResponseType.Ok) { _playlist = fcd.Filenames.ToList(); if (_player != null) { _player.Stop(); _player = null; } new Task(() => LoadFile(_playlist.First())).Start(); _currentIndex = 0; fcd.Dispose(); treestore.Clear(); foreach (var item in _playlist) { treestore.AppendValues(item); } } }
/// <summary> /// Choose file to save contacts. /// </summary> private string ChooseFileToSave(string dialogTitle) { string fileToSave = ""; // New dialog to save sim contacts on file Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(dialogTitle, MainWindow, FileChooserAction.Save, GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel, GlobalObjUI.LMan.GetString("savelbl"), Gtk.ResponseType.Accept); // Filter for using only monosim files Gtk.FileFilter myFilter = new Gtk.FileFilter(); myFilter.AddPattern("*.monosim"); myFilter.Name = "monosim files"; FileBox.AddFilter(myFilter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png"); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned fileToSave = FileBox.Filename; string chkfile = fileToSave.PadLeft(9).ToLower(); if (chkfile.Substring(chkfile.Length - 8) != ".monosim") { fileToSave += ".monosim"; } FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return(""); } return(fileToSave); }
/// <summary> /// Open command file /// </summary> private void OpenCommandFile() { // New dialog for select command file Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalObj.LMan.GetString("selectfile"), MainWindow, FileChooserAction.Open, GlobalObj.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel, GlobalObj.LMan.GetString("openlbl"), Gtk.ResponseType.Accept); // Filter to use only comex files Gtk.FileFilter myFilter = new Gtk.FileFilter(); myFilter.AddPattern("*.comex"); myFilter.Name = "comex project files (*.comex)"; FileBox.AddFilter(myFilter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("comex_256.png"); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned commandFilePath = FileBox.Filename; commandFileName = System.IO.Path.GetFileNameWithoutExtension(commandFilePath); log.Debug("file selected: " + commandFilePath); UpdateGuiForCommandFile(); FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } }
private void Openfile_Clicked(object sender, EventArgs a) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { MakeEditor(new FileInfo(fc.Filename)); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Dispose(); }
private void Openfolder_Clicked(object sender, EventArgs a) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Directory to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { //System.Console.WriteLine(fc.Filename); _folderexplore.SetDirectory(fc.Filename); _mainpaned.Remove(_folderexplore); _mainpaned.Add(_folderexplore); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Dispose(); }
private void ButtonLoadLabels_Clicked(object sender, EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Load labels", gtkWin, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept) { Filter = new FileFilter() }; fc.Filter.AddPattern("*.json"); if (fc.Run() == (int)Gtk.ResponseType.Accept) { manager.LoadLabels(fc.Filename); manager.SaveConfig(); } //Destroy() to close the File Dialog fc.Dispose(); }
public string ShowSaveDialog() { string result = null; Gtk.FileChooserDialog saveDialog = new Gtk.FileChooserDialog("Сохранить как", null, Gtk.FileChooserAction.Save, "Отмена", Gtk.ResponseType.Cancel, "Сохранить", Gtk.ResponseType.Accept); saveDialog.SetCurrentFolder(Environment.CurrentDirectory + @"\Yaml"); FileFilter filter = new FileFilter(); filter.Name = "doc/pdf"; filter.AddPattern("*.yml"); filter.AddPattern("*.yaml"); saveDialog.Filter = filter; if (saveDialog.Run() == (int)Gtk.ResponseType.Accept) { result = saveDialog.Filename; } saveDialog.Dispose(); return(result); }
public void on_save_activate(System.Object b, EventArgs e) { FileChooserDialog fd = new FileChooserDialog (Catalog.GetString("Save Game"), csboardWindow, FileChooserAction.Save); fd.AddButton (Stock.Close, (int) ResponseType.Close); fd.AddButton (Stock.Save, (int) ResponseType.Ok); int res = fd.Run(); fd.Hide (); if (res == (int) ResponseType.Ok) { if (System.IO.File.Exists (fd.Filename)) { MessageDialog md = new MessageDialog (csboardWindow, DialogFlags. DestroyWithParent, MessageType.Warning, ButtonsType.OkCancel, Catalog.GetString("File ") + fd.Filename + Catalog.GetString(" already exists\n\n") + Catalog.GetString("Do you wish to overwrite it?")); if (md.Run () == (int)ResponseType.Ok) { control.SaveGame (fd.Filename); } md.Hide (); md.Dispose (); } else { control.SaveGame (fd.Filename); } } fd.Dispose (); }
public void on_open_activate(System.Object b, EventArgs e) { statusbar.Pop (gameStatusbarId); FileChooserDialog fd = new FileChooserDialog (Catalog.GetString ("Open Game"), csboardWindow, FileChooserAction.Open); fd.AddButton (Stock.Close, (int) ResponseType.Close); fd.AddButton (Stock.Open, (int) ResponseType.Ok); if (fd.Run () == (int)ResponseType.Ok) { control.OpenGame (fd.Filename); control.SaveGame(App.session.Filename); } fd.Hide (); fd.Dispose (); }
protected virtual void OnSaveAsActionActivated(object sender, System.EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog ("Save Xaml File", this, Gtk.FileChooserAction.Save, "Cancel", Gtk.ResponseType.Cancel, "Save", Gtk.ResponseType.Ok); int x = fc.Run (); if (x == (int)Gtk.ResponseType.Ok) { if (fc.Filename != null) { StreamWriter sw = new StreamWriter (fc.Filename); filename = fc.Filename; sw.Write (sb.Text); sw.Close (); statusbar1.Push (0, "Saved.."); } } fc.Visible = false; fc.Dispose (); }
protected virtual void OnOpenActionActivated(object sender, System.EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog ("Open File", this, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Ok); int x = fc.Run (); if (x == (int)Gtk.ResponseType.Ok) { if (fc.Filename != null) { LoadFile (fc.Filename); } } fc.Visible = false; fc.Dispose (); }
/// <summary> /// Try to open all file contained in a specific /// folder (optional also in her subfolders) /// </summary> private void OpenFolder(bool recursive) { string selectedFolder = ""; Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FOLDEROPEN"), MainWindow, FileChooserAction.SelectFolder, GlobalData.GetLanguageKeyValue("BTNCANCEL"), Gtk.ResponseType.Cancel, GlobalData.GetLanguageKeyValue("BTNOPEN"), Gtk.ResponseType.Accept); FileBox.WindowPosition= WindowPosition.CenterOnParent; // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png"); FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned selectedFolder = FileBox.Filename.ToString(); FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } if (selectedFolder == "") { return; } // Recall other constructor OpenFolder(selectedFolder, recursive); }
/// <summary> /// Choose file to save contacts. /// </summary> private string ChooseFileToSave(string dialogTitle) { string fileToSave = ""; // New dialog to save sim contacts on file Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(dialogTitle, MainWindow, FileChooserAction.Save, GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel, GlobalObjUI.LMan.GetString("savelbl"), Gtk.ResponseType.Accept); // Filter for using only monosim files Gtk.FileFilter myFilter = new Gtk.FileFilter(); myFilter.AddPattern("*.monosim"); myFilter.Name = "monosim files"; FileBox.AddFilter(myFilter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png"); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned fileToSave = FileBox.Filename; string chkfile = fileToSave.PadLeft(9).ToLower(); if (chkfile.Substring(chkfile.Length-8) != ".monosim") { fileToSave += ".monosim"; } FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return ""; } return fileToSave; }
private void OpenContactsFile() { GlobalObjUI.ContactsFilePath = ""; // New dialog for select contacts file Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalObjUI.LMan.GetString("openfileact"), MainWindow, FileChooserAction.Open, GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel, GlobalObjUI.LMan.GetString("openlbl"), Gtk.ResponseType.Accept); // Filter for using only monosim files Gtk.FileFilter myFilter = new Gtk.FileFilter(); myFilter.AddPattern("*.monosim"); myFilter.Name = "monosim files"; FileBox.AddFilter(myFilter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png"); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned GlobalObjUI.ContactsFilePath = FileBox.Filename; FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } // Update gui UpdateFileControls(false); lstFileContacts.Clear(); MainClass.GtkWait(); try { GlobalObjUI.FileContacts = new Contacts(); StreamReader sr = new StreamReader(GlobalObjUI.ContactsFilePath); string descRow = sr.ReadLine(); string phoneRow = ""; while (!sr.EndOfStream) { phoneRow = sr.ReadLine(); // check for right values if (descRow.Trim() != "" && phoneRow.Trim() != "") { GlobalObjUI.FileContacts.SimContacts.Add(new Contact(descRow, phoneRow)); } // read new contact description descRow = sr.ReadLine(); } sr.Close(); sr.Dispose(); sr = null; } catch (Exception Ex) { log.Error("MainWindowClass::OpenContactsFile: " + Ex.Message + "\r\n" + Ex.StackTrace); MainClass.ShowMessage(MainWindow, "ERROR", Ex.Message, MessageType.Error); return; } // loop to append data readed from file foreach(Contact cnt in GlobalObjUI.FileContacts.SimContacts) { lstFileContacts.AppendValues(new string[]{cnt.Description, cnt.PhoneNumber}); } UpdateFileControls(true); }
private void OpenContactsFile() { GlobalObjUI.ContactsFilePath = ""; // New dialog for select contacts file Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalObjUI.LMan.GetString("openfileact"), MainWindow, FileChooserAction.Open, GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel, GlobalObjUI.LMan.GetString("openlbl"), Gtk.ResponseType.Accept); // Filter for using only monosim files Gtk.FileFilter myFilter = new Gtk.FileFilter(); myFilter.AddPattern("*.monosim"); myFilter.Name = "monosim files"; FileBox.AddFilter(myFilter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png"); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned GlobalObjUI.ContactsFilePath = FileBox.Filename; FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } // Update gui UpdateFileControls(false); lstFileContacts.Clear(); MainClass.GtkWait(); try { GlobalObjUI.FileContacts = new Contacts(); StreamReader sr = new StreamReader(GlobalObjUI.ContactsFilePath); string descRow = sr.ReadLine(); string phoneRow = ""; while (!sr.EndOfStream) { phoneRow = sr.ReadLine(); // check for right values if (descRow.Trim() != "" && phoneRow.Trim() != "") { GlobalObjUI.FileContacts.SimContacts.Add(new Contact(descRow, phoneRow)); } // read new contact description descRow = sr.ReadLine(); } sr.Close(); sr.Dispose(); sr = null; } catch (Exception Ex) { log.Error("MainWindowClass::OpenContactsFile: " + Ex.Message + "\r\n" + Ex.StackTrace); MainClass.ShowMessage(MainWindow, "ERROR", Ex.Message, MessageType.Error); return; } // loop to append data readed from file foreach (Contact cnt in GlobalObjUI.FileContacts.SimContacts) { lstFileContacts.AppendValues(new string[] { cnt.Description, cnt.PhoneNumber }); } UpdateFileControls(true); }
private void OpenFile() { string selectedFile = ""; Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FILEOPEN"), MainWindow, FileChooserAction.Open, GlobalData.GetLanguageKeyValue("BTNCANCEL"), Gtk.ResponseType.Cancel, GlobalData.GetLanguageKeyValue("BTNOPEN"), Gtk.ResponseType.Accept); FileBox.WindowPosition= WindowPosition.CenterOnParent; FileFilter filter = new FileFilter(); filter.Name = GlobalData.FileDialogExtensions; string[] managedExt = GlobalData.bFactory.GetManagedExtentions(); for (int j=0; j<managedExt.Length; j++) { filter.AddPattern("*." + managedExt[j]); } FileBox.AddFilter(filter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png"); FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned selectedFile = FileBox.Filename.ToString(); FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } if (selectedFile == "") { return; } // recall other constructor OpenFile(selectedFile); }
private void openConfigFile(object s, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Open Config File...", this, FileChooserAction.Open); fcd.TransientFor = this; fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Ok, ResponseType.Ok); FileFilter ff = new FileFilter(); ff.Name = "Config file (.xml)"; ff.AddMimeType("text/xml"); ff.AddMimeType("application/xml"); fcd.AddFilter(ff); int result = fcd.Run(); fcd.HideAll(); if(result == (int)ResponseType.Ok) { try { ss.ReadConfigFile(fcd.Filename); this.sr = ss.Simulator.CollectResults(); this.bs.SetMinCurrentMax(1, 1, this.sr.ChapterCount); this.bpsp.SimulatorResult = sr; } catch(Exception ex) { Console.Error.WriteLine(ex); MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, true, ex.Message); md.Run(); md.Destroy(); } this.bpsp.Reload(); } fcd.Dispose(); }
/// <summary> /// Generate report file /// </summary> private void SaveReport() { if (tabContainer.NPages < 1) { // If there isn't any selected tab, exit return; } string selectedFile = ""; Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FILESAVE"), MainWindow, FileChooserAction.Save, GlobalData.GetLanguageKeyValue("BTNCANCEL"), Gtk.ResponseType.Cancel, GlobalData.GetLanguageKeyValue("BTNSAVE"), Gtk.ResponseType.Accept); FileBox.WindowPosition= WindowPosition.CenterOnParent; FileFilter filter = new FileFilter(); filter.AddPattern("*.report"); filter.Name = "Report file (*.report)"; FileBox.AddFilter(filter); // Manage result of dialog box FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png"); FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath); int retFileBox = FileBox.Run(); if ((ResponseType)retFileBox == Gtk.ResponseType.Accept) { // path of a right file returned selectedFile = FileBox.Filename.ToString(); FileBox.Destroy(); FileBox.Dispose(); } else { // nothing returned FileBox.Destroy(); FileBox.Dispose(); return; } // generate report GlobalData.bFactory .SaveReportFile(fiEntity[tabContainer.Page].Video, fiEntity[tabContainer.Page].Audio, fiEntity[tabContainer.Page].FileName, selectedFile, fiEntity[tabContainer.Page].PluginUsed); // Message of report generated MessageDialog dlg = new MessageDialog(MainWindow, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, GlobalData.GetLanguageKeyValue("SAVEREPORTMSG") + "\r\n" + fiEntity[tabContainer.Page].FileName); dlg.Title = GlobalData.GetLanguageKeyValue("SAVEREPORTWIN"); dlg.Run(); dlg.Destroy(); return; }
private void openLibFile(object s, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Open Library File...", this, FileChooserAction.Open); fcd.TransientFor = this; fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Ok, ResponseType.Ok); FileFilter ff = new FileFilter(); ff.Name = "Dynamic Link Library (.dll,.exe)"; ff.AddPattern(@"*.dll"); ff.AddPattern(@"*.exe"); fcd.AddFilter(ff); int result = fcd.Run(); fcd.HideAll(); if(result == (int)ResponseType.Ok) { ss.ConnectAlgorithmLibrary(fcd.Filename); } fcd.Dispose(); }