/// <summary> /// On click "..." button - select file /// </summary> protected virtual void OnBtnSelectFileClicked(object sender, System.EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog ( AddinManager.CurrentLocalizer.GetString ("Choose the file to open"), new Dialog(), Gtk.FileChooserAction.Open, AddinManager.CurrentLocalizer.GetString ("Cancel"), ResponseType.Cancel, AddinManager.CurrentLocalizer.GetString ("Open"), ResponseType.Accept); if (!string.IsNullOrEmpty (this.eCommand.Text)) { fc.SetFilename(this.eCommand.Text); } if (fc.Run() == (int) ResponseType.Accept) { // check UnixFileInfo info = new UnixFileInfo (fc.Filename); if ((info.FileAccessPermissions & FileAccessPermissions.UserExecute) != FileAccessPermissions.UserExecute) { MessageDialog md = new MessageDialog (new Dialog(), DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, AddinManager.CurrentLocalizer.GetString ("Selected invalid file!\nShould be executable.")); md.Run (); md.Destroy(); } else { this.eCommand.Text = fc.Filename; } } fc.Destroy(); }
protected override void OnActivated() { base.OnActivated(); Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_workspace_open"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); FileFilter filter = new FileFilter(); filter.Name = "Workspace files"; filter.AddMimeType("Workspace file"); filter.AddPattern("*.msw"); fc.AddFilter(filter); if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedWorkspaceDir)) fc.SetCurrentFolder(MainClass.Settings.LastOpenedWorkspaceDir); if (fc.Run() == (int)ResponseType.Accept) { MainClass.Settings.LastOpenedWorkspaceDir = System.IO.Path.GetDirectoryName(fc.Filename); //CloseActualWorkspace(); Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fc.Filename); if (workspace != null){ //MainClass.Settings.RecentFiles.AddWorkspace(fc.Filename,fc.Filename); MainClass.MainWindow.ReloadWorkspace(workspace,true,true); } } fc.Destroy(); }
public override WindowResponse Show() { FileChooserAction fca = FileChooserAction.Open; switch(DialogType) { case FileDialogType.OpenFile: fca = FileChooserAction.Open; break; case FileDialogType.SelectFolder: fca = FileChooserAction.SelectFolder; break; case FileDialogType.SaveFile: fca = FileChooserAction.Save; break; } fc = new FileChooserDialog(Title, null, fca, Message.GetString("Cancel"), ResponseType.Cancel, Message.GetString("Select"), ResponseType.Ok); fc.SetCurrentFolder(InitialDirectory); foreach(FileTypeFilter filter in FileTypeFilters) { FileFilter ft = new FileFilter(); ft.Name = filter.FilterName; foreach(string pat in filter.Filter) ft.AddPattern("*." + pat); fc.AddFilter(ft); } WindowResponse resp = GtkHelper.GetResponse((ResponseType)fc.Run()); SelectedPath = fc.Filename; return resp; }
internal static string OpenExperimentDialog(Window parentWindow) { var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"), parentWindow, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok); fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel }; fileChooserDialog.SelectMultiple = false; AddFilters(fileChooserDialog); int response = fileChooserDialog.Run(); string filename = null; if(response == (int)Gtk.ResponseType.Ok) { filename = fileChooserDialog.Filename; } fileChooserDialog.Destroy(); return filename; }
protected void open(object sender, EventArgs e) { int width, height; this.GetDefaultSize (out width, out height); this.Resize (width, height); // Create and display a fileChooserDialog FileChooserDialog chooser = new FileChooserDialog ( "Please select a file to open ...", this, FileChooserAction.Open, "cancel", ResponseType.Cancel, "view", ResponseType.Accept); if (chooser.Run () == (int)ResponseType.Accept) { System.IO.StreamReader file = System.IO.File.OpenText (chooser.Filename); textview2.Buffer.Text=file.ReadToEnd (); this.Title = " ssource editor -- " + chooser.Filename.ToString (); this.Resize (640, 480); file.Close (); string[] forsaveas=new[]{chooser.Filename}; System.IO.File.WriteAllLines (@".ssourcefile.txt",forsaveas);//write name of file so that it can be saved also after ready = true; this.entry1.Text = ("opened : " + chooser.Filename); } chooser.Destroy (); }
internal static string OpenExperimentDialog(Window parentWindow) { var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"), parentWindow, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok); fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel }; fileChooserDialog.SelectMultiple = false; // HERZUM SPRINT 4 TLAB-214 fileChooserDialog.SetCurrentFolder(TraceLab.Core.Settings.Settings.GetSettings().DefaultExperimentsDirectory); // END SPRINT HERZUM 4 HERZUM 4: TLAB-214 AddFilters(fileChooserDialog); int response = fileChooserDialog.Run(); string filename = null; if(response == (int)Gtk.ResponseType.Ok) { filename = fileChooserDialog.Filename; } fileChooserDialog.Destroy(); return filename; }
void buttonBrowsePickTake_Clicked(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog ( "Choose the file to open" , this , FileChooserAction.Open , "Cancel", ResponseType.Cancel , "Open", ResponseType.Accept ); if (fc.Run() == (int)ResponseType.Accept) { int l = fc.Filename.LastIndexOf('\\') + 1; textBoxImageNamePickedTaken.Text = fc.Filename.Substring(l); System.IO.FileStream file = System.IO.File.OpenRead(fc.Filename); file.Close(); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); return; }
protected void OnOpenActionActivated(object sender, EventArgs e) { Gtk.FileChooserDialog fc = new FileChooserDialog ( "Choose image to open", this, Gtk.FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fc.Filter = new FileFilter(); fc.Filter.AddPattern ("*.png"); fc.Filter.AddPattern ("*.jpg"); fc.Filter.AddPattern("*.jpeg"); fc.Filter.AddPattern ("*.gif"); fc.Filter.AddPattern("*.tiff"); if (fc.Run() == (int)ResponseType.Accept) { System.Drawing.Image host = System.Drawing.Image.FromFile (fc.Filename); Bitmap hostImage = new Bitmap (host); MemoryStream pic = new MemoryStream (); hostImage.Save (pic, System.Drawing.Imaging.ImageFormat.Png); pic.Seek (0, SeekOrigin.Begin); Gdk.Pixbuf pb = new Gdk.Pixbuf (pic); originalImage.Pixbuf = pb; } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
public string AskForQuizFilePath() { string output; Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the quiz to open", this, FileChooserAction.Open, "Cancel",ResponseType.Cancel, "Open",ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { output = fc.Filename; } else { throw new ApplicationException("Could for some reason not read the wanted file: " + fc.Filename); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); return output; }
public void Activate() { object[] buttonResponses = new object[] {"Accept", ResponseType.Accept, "Cancel", ResponseType.Cancel}; FileChooserDialog fileDialog = new FileChooserDialog("Local Studies", (Window)_mainView.GuiElement, FileChooserAction.SelectFolder, buttonResponses); int result = fileDialog.Run(); string folder = fileDialog.Filename; fileDialog.Destroy(); // must manually destroy the dialog if(result == (int)ResponseType.Accept) { LocalImageLoader loader = new LocalImageLoader(); string studyUID = loader.Load(folder); //if(studyUID == "" || WorkstationModel.StudyManager.StudyTree.GetStudy(studyUID) == null) if(studyUID == "" || ImageWorkspace.StudyManager.StudyTree.GetStudy(studyUID) == null) { //Platform.ShowMessageBox(ClearCanvas.Workstation.Model.SR.ErrorUnableToLoadStudy); Platform.ShowMessageBox(ClearCanvas.ImageViewer.SR.ErrorUnableToLoadStudy); } else { ImageWorkspace ws = new ImageWorkspace(studyUID); //WorkstationModel.WorkspaceManager.Workspaces.Add(ws); DesktopApplication.WorkspaceManager.Workspaces.Add(ws); } } }
protected void OnButtonClicked(object sender, EventArgs e) { if (sender == button1) { Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Insert Spacer", ResponseType.None, "Add", ResponseType.Accept); Gtk.Alignment align = new Alignment (1, 0, 0, 1); Gtk.Frame frame = new Frame ("Position"); Gtk.HBox hbox = new HBox (false, 4); RadioButton rbRight; rbRight = new RadioButton ("Right"); hbox.PackEnd(rbRight, false, false, 1); hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1); frame.Add (hbox); align.Add (frame); align.ShowAll (); dialog.ExtraWidget = align; ResponseType response = (ResponseType)dialog.Run (); if (response == ResponseType.Accept) { RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock"); } else if (response == ResponseType.None) { RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock"); } dialog.Destroy (); } }
static void GetClip() { // TODO: Do not offer to save clip after selection and popup a clickable tooltip instead. FileChooserDialog fcd = new FileChooserDialog("PixClip - Save clip as...", null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); FileFilter fltJpg = new FileFilter(); fltJpg.AddMimeType("image/jpeg"); fltJpg.Name = "JPEG image format"; fcd.SetFilename("clip.jpg"); fcd.SetCurrentFolder(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)); fcd.AddFilter(fltJpg); Console.WriteLine("main: selecting save target"); if (fcd.Run() == (int) ResponseType.Accept) { // TODO: Add quality setting to options form. // http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-saving.html string [] keys = {"quality"}; string [] values = {"90"}; pixClip.Savev(fcd.Filename, "jpeg", keys, values); Console.WriteLine("main: image saved"); } else { Console.WriteLine("main: image save canceled"); } fcd.Destroy(); Clipboard clip = Gtk.Clipboard.Get(Atom.Intern("CLIPBOARD", false)); clip.Image = pixClip; Console.WriteLine("main: image added to the clipboard"); }
private void Activated(object sender, EventArgs e) { var fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), PintaCore.Chrome.MainWindow, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok); // Add image files filter FileFilter ff = new FileFilter (); ff.AddPixbufFormats (); ff.AddPattern ("*.ora"); ff.Name = Catalog.GetString ("Image files"); fcd.AddFilter (ff); FileFilter ff2 = new FileFilter (); ff2.Name = Catalog.GetString ("All files"); ff2.AddPattern ("*.*"); fcd.AddFilter (ff2); fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel }; fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory); fcd.SelectMultiple = true; int response = fcd.Run (); if (response == (int)Gtk.ResponseType.Ok) { PintaCore.System.LastDialogDirectory = fcd.CurrentFolder; foreach (var file in fcd.Filenames) if (PintaCore.Workspace.OpenFile (file)) RecentManager.Default.AddFull (fcd.Uri, PintaCore.System.RecentData); } fcd.Destroy (); }
//Will load in multiple files, or a folder of files which will be matched against //loaded templates public static List<Tuple<string, List<PointD>>> loadBatchPoints() { List<Tuple<string,List<PointD>>> result = new List<Tuple<string,List<PointD>>> (); //Setup of dialog and limiting it to only XML files FileChooserDialog fileChooser = new FileChooserDialog ("Open Files", null, FileChooserAction.Open); fileChooser.AddButton (Stock.Cancel, ResponseType.Cancel); fileChooser.AddButton (Stock.Open, ResponseType.Ok); fileChooser.Filter = new FileFilter (); fileChooser.Filter.AddPattern ("*.xml"); string tmp = System.IO.Directory.GetCurrentDirectory(); string newTmp = tmp + "/../../Gestures/RecordedDataPoints/"; fileChooser.SetCurrentFolder (newTmp); fileChooser.SelectMultiple = true; ResponseType retVal = (ResponseType)fileChooser.Run (); if (retVal == ResponseType.Ok) { foreach (string file in fileChooser.Filenames) { result.Add (XMLParser.BatchLoadPoints (file)); } } fileChooser.Destroy (); return result; }
protected void onAddClicked(object sender, System.EventArgs e) { String[] items = {}; FileChooserDialog dialog = new FileChooserDialog("Open", null, FileChooserAction.Open, "Cancel",ResponseType.Cancel, "Open",ResponseType.Accept); dialog.SelectMultiple=true; FileFilter filter = new FileFilter(); /*filter.AddPattern("*.jpg"); filter.AddPattern("*.jpeg"); filter.AddPattern("*.png"); filter.AddPattern("*.svg");*/ filter.AddMimeType("image/*"); dialog.Filter = filter; if(dialog.Run()==(int)ResponseType.Accept) { items = dialog.Filenames; } dialog.Destroy(); localfiles.LocalFiles.addItems(items); fillList(); }
/// <summary> /// Loads a plugin using the Add command from the Plugins menu. /// </summary> /// <param name='sender'> /// Sender. /// </param> /// <param name='e'> /// Event args. /// </param> protected void OnAddActionActivated(object sender, EventArgs e) { var fc = new Gtk.FileChooserDialog("Choose the file to open", null, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept); try { fc.SelectMultiple = true; fc.SetCurrentFolder(Environment.CurrentDirectory); if (fc.Run() == (int)Gtk.ResponseType.Accept) { PluginServiceContainer pluginsToAdd = new PluginServiceContainer(); for (int i = 0; i < fc.Filenames.Length; i++) { if (!plugins.Plugins.Exists(x => x.codeBase == fc.Filenames[i])) { plugins.AddPlugin(fc.Filenames[i]); pluginsToAdd.AddPlugin(fc.Filenames[i]); } } pluginsToAdd.LoadPlugins(); foreach (IPlugin p in pluginsToAdd.GetServices <IPlugin>()) { p.Init(this); } } } finally { fc.Destroy(); } }
protected void OnButtonLoadPhotoClicked(object sender, EventArgs e) { FileChooserDialog Chooser = new FileChooserDialog ("Выберите фото для загрузки...", (Window)this.Toplevel, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Загрузить", ResponseType.Accept); FileFilter Filter = new FileFilter (); Filter.AddPixbufFormats (); Filter.Name = "Все изображения"; Chooser.AddFilter (Filter); if ((ResponseType)Chooser.Run () == ResponseType.Accept) { Chooser.Hide (); logger.Info ("Загрузка фотографии..."); FileStream fs = new FileStream (Chooser.Filename, FileMode.Open, FileAccess.Read); if (Chooser.Filename.ToLower ().EndsWith (".jpg")) { using (MemoryStream ms = new MemoryStream ()) { fs.CopyTo (ms); ImageFile = ms.ToArray (); } } else { logger.Info ("Конвертация в jpg ..."); Gdk.Pixbuf image = new Gdk.Pixbuf (fs); ImageFile = image.SaveToBuffer ("jpeg"); } fs.Close (); buttonSavePhoto.Sensitive = true; logger.Info ("Ok"); } Chooser.Destroy (); }
protected void OnSaveButtonClicked(object sender, EventArgs e) { try { FileChooserDialog fc = new FileChooserDialog("Save Filterset", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); FileFilter filter = new FileFilter(); filter.Name = "DeSERt Filterset"; filter.AddMimeType("Filterset/fis"); filter.AddPattern("*.fis"); fc.AddFilter(filter); fc.DoOverwriteConfirmation = true; fc.CurrentName = FiltersetnameEntry.Text.Replace(" ", "-"); if (Directory.Exists(MySettings.LastFilterDir)) { fc.SetCurrentFolder(MySettings.LastFilterDir); } ResponseType res = (ResponseType)fc.Run(); if (res == ResponseType.Ok || res == ResponseType.Close) { string path; if (!System.IO.Path.HasExtension(fc.Filename)) { path = fc.Filename + ".fis"; } else { path = fc.Filename; } MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename); MySettings.Save(); fst.Name = FiltersetnameEntry.Text; Filterset.SaveFilterset(path, fst); saved = true; } fc.Destroy(); if (res == ResponseType.Close) { this.Destroy(); } } catch (Exception ex) { ErrorReport.ReportError("Save Button (Create Filterset)", ex); } }
public static byte[] GetTemplateFromDisk() { //Читаем файл документа FileChooserDialog Chooser = new FileChooserDialog ("Выберите шаблон документа...", null, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Выбрать", ResponseType.Accept); FileFilter Filter = new FileFilter (); Filter.Name = "ODT документы и OTT шаблоны"; Filter.AddMimeType ("application/vnd.oasis.opendocument.text"); Filter.AddMimeType ("application/vnd.oasis.opendocument.text-template"); Filter.AddPattern ("*.odt"); Filter.AddPattern ("*.ott"); Chooser.AddFilter (Filter); Filter = new FileFilter (); Filter.Name = "Все файлы"; Filter.AddPattern ("*.*"); Chooser.AddFilter (Filter); byte[] file = null; if ((ResponseType)Chooser.Run () == ResponseType.Accept) { Chooser.Hide (); logger.Info ("Чтение файла..."); file = File.ReadAllBytes(Chooser.Filename); logger.Info ("Ok"); } Chooser.Destroy (); return file; }
protected override void OnActivated() { base.OnActivated(); if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error); md.ShowDialog(); return; } Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_project_import"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedImportDir)) fc.SetCurrentFolder(MainClass.Settings.LastOpenedImportDir); FileFilter filter = new FileFilter(); filter.Name = "zip files"; filter.AddMimeType("zip file"); filter.AddPattern("*.zip"); fc.AddFilter(filter); if (fc.Run() == (int)ResponseType.Accept) { MainClass.Settings.LastOpenedImportDir = System.IO.Path.GetDirectoryName(fc.Filename); MainClass.MainWindow.ImportProject(fc.Filename,true); } fc.Destroy(); }
private void OpenFileButton_Clicked(object sender, EventArgs e) { var fileChooser = new FileChooserDialog("Pick a file", this.Window, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fileChooser.Filter = new FileFilter(); fileChooser.Filter.AddPattern("*.xt"); #if DEBUG fileChooser.SetCurrentFolder(@"c:\tmp\traces"); #endif var result = (ResponseType)Enum.ToObject(typeof(ResponseType), fileChooser.Run()); switch (result) { case ResponseType.Accept: var filename = fileChooser.Filename; Parser parser = null; fileChooser.Destroy(); try { parser = Parser.ParseFile(filename); } catch (Exception ex) { var dlg = new MessageDialog(this.Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to load/parse the selected file! \r\nSome indication: " + ex.Message); dlg.Run(); } if (parser != null) { ShowTraces(parser); } break; case ResponseType.Cancel: case ResponseType.DeleteEvent: fileChooser.Destroy(); break; } }
public override bool Execute() { Image image = null; if (File.Exists(_path)) { image = Image.Load(RunMode.Noninteractive, _path, _path); } else { var choose = new FileChooserDialog("Open...", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); if (choose.Run() == (int) ResponseType.Accept) { string fileName = choose.Filename; image = Image.Load(RunMode.Noninteractive, fileName, fileName); }; choose.Destroy(); } if (image != null) { image.CleanAll(); ActiveDisplay = new Display(image); ActiveImage = image; return true; } return false; }
protected override void OnActivated() { base.OnActivated(); if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error); md.ShowDialog(); return; } Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("save_project_export"), MainClass.MainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedExportDir)) fc.SetCurrentFolder(MainClass.Settings.LastOpenedExportDir); FileFilter filter = new FileFilter(); filter.Name = "zip files"; filter.AddMimeType("zip file"); filter.AddPattern("*.zip"); fc.AddFilter(filter); string appname = ""; int typ = -1; Gtk.TreeIter ti = new Gtk.TreeIter(); MainClass.MainWindow.WorkspaceTree.GetSelectedFile(out appname, out typ, out ti); if (String.IsNullOrEmpty(appname)){ return; } Project p = MainClass.Workspace.FindProject_byApp(appname, true); if(p== null){ return; } fc.CurrentName =p.ProjectName+"_"+p.AppFile.Version.Replace(".","_") ; //fc.SetFilename(p.ProjectName); if (fc.Run() != (int)ResponseType.Accept) { fc.Destroy(); return; } string name =fc.Filename; string ext = System.IO.Path.GetExtension(name); if(ext.ToLower() != ".zip"){ name = name+".zip"; } if(p!= null){ p.Export(name,true); MainClass.Settings.LastOpenedExportDir = System.IO.Path.GetDirectoryName(fc.Filename); } fc.Destroy(); }
protected void OnBtnSaveClicked(object sender, System.EventArgs e) { Gtk.FileChooserDialog fd = new Gtk.FileChooserDialog("Save", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save",ResponseType.Ok); if (fd.Run() == (int)ResponseType.Ok) { sg.SavePNG(fd.Filename); } fd.Destroy(); }
public FolderListGui(string Title, string Description, string[] Folders) { this.Build (); this.Folders = Folders; this.label12.Text = Description; this.Title = Title; NodeStore store = new NodeStore(typeof(StringNode)); foreach(string folder in Folders) store.AddNode(new StringNode(){ Value = folder}); nodeview1.NodeStore = store; nodeview1.AppendColumn("Folder", new Gtk.CellRendererText (), "text", 0); buttonOk.Clicked += delegate { // get the folders List<string> nodes = new List<string>(); var enumerator = store.GetEnumerator(); while(enumerator.MoveNext()) { string folder = ((StringNode)enumerator.Current).Value; if(folder.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) folder = folder.Substring(0, folder.Length - 1); nodes.Add(folder); } this.Folders = nodes.ToArray(); this.DialogResult = ResponseType.Ok; this.Destroy(); }; buttonCancel.Clicked += delegate{ this.DialogResult = ResponseType.Cancel; this.Destroy(); }; btnAdd.Clicked += delegate { using(Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Folder to scan.", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept)){ fc.LocalOnly = false; if (fc.Run() == (int)ResponseType.Accept) { store.AddNode(new StringNode(){ Value = fc.Filename}); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); } }; btnRemove.Clicked += delegate { foreach(var node in nodeview1.NodeSelection.SelectedNodes) store.RemoveNode(node); }; }
protected void OnBtnExeBrowseClicked(object o, EventArgs args) { FileChooserDialog fileChooser = new FileChooserDialog("Locate SuperTux Executable", settingsDialog, FileChooserAction.Open, new object[] {}); fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok); fileChooser.DefaultResponse = Gtk.ResponseType.Ok; if (fileChooser.Run() == (int)ResponseType.Ok) { entryExe.Text = fileChooser.Filename; } fileChooser.Destroy(); }
protected void OnBtnDataDirBrowseClicked(object o, EventArgs args) { FileChooserDialog fileChooser = new FileChooserDialog("Locate SuperTux Data Directory", settingsDialog, FileChooserAction.SelectFolder, new object[] {}); fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok); fileChooser.DefaultResponse = Gtk.ResponseType.Ok; if (fileChooser.Run() == (int)ResponseType.Ok) { entryDataDir.Text = fileChooser.Filename; } fileChooser.Destroy(); }
public void WriteToFile(String text) { Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Save Image File", null, FileChooserAction.Save, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Save, Gtk.ResponseType.Ok); int response = fcd.Run (); if (response == (int)Gtk.ResponseType.Ok) SaveFile (fcd.Filename, text); fcd.Destroy (); }
protected void OnButton1Clicked(object sender, EventArgs e) { FileChooserDialog Dlg; Dlg = new FileChooserDialog ("Directorio Inicial", null, FileChooserAction.SelectFolder, Stock.Open, ResponseType.Ok, Stock.Cancel, ResponseType.Cancel); Dlg.ShowAll (); if (Dlg.Run () == (int)ResponseType.Ok) { E1.Text = Dlg.Filename; } Dlg.HideAll (); Dlg.Destroy (); }
protected void OnButton188Pressed(object sender, EventArgs e) { FileChooserDialog dialog = new FileChooserDialog("Change sound records folder", this, FileChooserAction.SelectFolder, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Accept); if (dialog.Run() == (int)ResponseType.Accept) { entry_sounds.Text = dialog.Filename; } dialog.Destroy(); }
protected void OnButton41Clicked(object sender, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Select LunaLua Directory", null, FileChooserAction.SelectFolder); fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Ok, ResponseType.Ok); int ret = fcd.Run(); if (ret == (int)ResponseType.Ok) { lunaLuaDirEntry.Text = fcd.Filename; } fcd.Destroy(); }
protected void OnOpen(object o, EventArgs e) { if (!ChangeConfirm("load a new level")) { return; } fileChooser.Title = "Choose a Level"; fileChooser.Action = Gtk.FileChooserAction.Open; fileChooser.SetCurrentFolder(Settings.Instance.LastDirectoryName); fileChooser.Filter = fileChooser.Filters[0]; int result = fileChooser.Run(); fileChooser.Hide(); if (result != (int)Gtk.ResponseType.Ok) { return; } Settings.Instance.LastDirectoryName = fileChooser.CurrentFolder; Settings.Instance.Save(); Load(fileChooser.Filename); EditProperties(CurrentLevel, "Level"); }
protected void OnAddActionActivated(object sender, EventArgs e) { var fc = new Gtk.FileChooserDialog("Choose the file to open", null, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept); try { fc.SelectMultiple = true; fc.SetCurrentFolder(Environment.CurrentDirectory); if (fc.Run() == (int)Gtk.ResponseType.Accept) { for (int i = 0; i < fc.Filenames.Length; i++) { plugins.AddPlugin(fc.Filenames[i]); } SaveLayout(); plugins.LoadPlugins(); } } finally { fc.Destroy(); } }
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"); if (fc.Run() == (int)Gtk.ResponseType.Accept) { attentionHandler.OpenImage(fc.Filename, true); manager.SaveConfig(); LoadImageInformation(); } //Destroy() to close the File Dialog fc.Dispose(); }
public void onChooseSaveLog(object sender, EventArgs args) { FileFilter filter = new FileFilter(); filter.Name = "Text files"; filter.AddPattern("*.txt"); Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog("Save log to", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); filechooser.SelectMultiple = false; filechooser.Filter = filter; if (filechooser.Run() == (int)ResponseType.Accept) { File.WriteAllText(filechooser.Filename, logWindow.Buffer.Text); } filechooser.Destroy(); }
private void SaveAsFile() { GetControlValues(); Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the file to save", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); var filter = new FileFilter(); filter.Name = "Zora Files"; filter.AddPattern("*.zora"); fc.AddFilter(filter); if (fc.Run() == (int)ResponseType.Accept) { _info.Write(fc.Filename); _currentFile = fc.Filename; } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
protected void openFileClicked(object sender, EventArgs e) { // Open sprite sheet. var dialog = new Gtk.FileChooserDialog("Select Sprite Sheet", this, FileChooserAction.Open, "gtk-cancel", ResponseType.Cancel, "gtk-ok", ResponseType.Ok); dialog.Filter = new FileFilter(); dialog.Filter.AddPattern("*.png"); var result = (ResponseType)dialog.Run(); dialog.Hide(); if (result != ResponseType.Ok) { return; } var app = m_app; app.Filename = dialog.Filename; app.Do(Act.Analyze); }
/// <summary> /// Shows the open dialog. /// </summary> /// <returns> /// The filename. /// </returns> public static string ShowOpenDialog() { try { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(Catalog.GetString("OpeningTitle"), null, FileChooserAction.Open, "Öffnen", ResponseType.Accept, "Abbrechen", ResponseType.Cancel); FileFilter flt = new FileFilter(); flt.Name = Catalog.GetString("Regex - Projects"); flt.AddPattern("*.rgx"); fc.Filter = flt; //fc.CurrentFolder = n fc.SetCurrentFolder(new libTerminus.cPathEnvironment().const_start_path); string filename = ""; //run the Dialog if (fc.Run() == (int)ResponseType.Accept) { filename = fc.Filename; } fc.Destroy(); return(filename); } catch (Exception ex) { MessageBox.Show(ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error); return(""); } }
public static string ShowSaveFileDialog(string title, string extensions) { var extensionList = GetExtensionList(extensions); #if FAMISTUDIO_MACOS return(MacUtils.ShowSaveDialog(title, extensionList)); #else Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog("Choose the file to open", null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); filechooser.KeepAbove = true; filechooser.Modal = true; filechooser.SkipTaskbarHint = true; filechooser.Filter = new FileFilter(); foreach (var ext in extensionList) { filechooser.Filter.AddPattern($"*.{ext}"); } string filename = null; if (filechooser.Run() == (int)ResponseType.Accept) { filename = filechooser.Filename; } ProcessPendingEvents(); filechooser.Destroy(); ProcessPendingEvents(); return(filename); #endif }
public void openFile() { //Abre cuadro de dialogo; Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog("Choose the file to open", this.ventana, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); //si abrio un archivo if (filechooser.Run() == (int)ResponseType.Accept) { this.filePath = filechooser.Filename; String fileExt = System.IO.Path.GetExtension(this.filePath); //destruir cuadro de dialogo switch (fileExt) { case ".hpgl": //si es hpgl this.fileCont = File.ReadAllText(filechooser.Filename); cargarHpgl(); break; case ".ilu": //si es ilu this.fileCont = File.ReadAllText(filechooser.Filename); cargarIlu(); break; default: msgShow("El archivo no tiene el formato requerido (hpgl o ilu)"); break; } } filechooser.Destroy(); }
protected void MenuFileSaveAsClicked(object sender, System.EventArgs e) { Console.WriteLine("MenuFileSaveAsClicked"); Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose file to save to", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { string fileToSaveAs = fc.Filename; if (this.try_to_write(fileToSaveAs) == true) { Console.WriteLine("Saved as " + fileToSaveAs); } else { Console.WriteLine("Failed to save as `" + fileToSaveAs + "`"); MessageDialog md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Cancel, "Failed to save as " + fileToSaveAs); md.Run(); md.Destroy(); } } fc.Destroy(); }
protected void OnExportCommandsButtonPress(object sender, EventArgs e) { Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog ("Choose files" , this , FileChooserAction.SelectFolder , "Select" , ResponseType.Accept , "Cancel" , ResponseType.Close); int response = fileChooser.Run(); if (response == Utils.static_cast <int>(ResponseType.Close)) { UIUtils.ShutDownWindow(ref fileChooser); } else if (response == Utils.static_cast <int>(ResponseType.Accept)) { string fullPath = fileChooser.Filename + "/exported_commands.xml"; UIUtils.ShutDownWindow(ref fileChooser); UITabPage currentTabPage = GetCurrentTabPage(); currentTabPage.GetGameConfig(); GamesConfigLoader gamesLoader = MainApp.GetInstance().GetConfig().GetGameConfig(); FileOperationResult fileOperationResult = gamesLoader.Export(fullPath, currentTabPage.GetGameConfig()); if (!fileOperationResult.IsSuccess()) { UIUtils.ShutDownWindowSafe(ref _windowPrompt); _windowPrompt = new WindowPrompt(fileOperationResult.GetResult()); _windowPrompt.OnAcceptEvent += OnAlertAccept; _windowPrompt.SetCancelVisible(false); _windowPrompt.Show(); MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt); } } }
public void LoadPlugin(ProxyFrame proxy) { if (proxy == null) { return; } var od = new Gtk.FileChooserDialog(null, "Load Plugin", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); foreach (var filter in GetFileFilters()) { od.AddFilter(filter); } if (od.Run() == (int)ResponseType.Accept) { PluginInfo plugin = new PluginInfo(); plugin.Path = od.Filename; bool found = false; Store.Foreach((model, path, iter) => { var item = model.GetValue(iter, 0) as PluginInfo; if (null != item && item.Path == plugin.Path) { return(found = true); } return(false); }); if (!found && LoadAssembly(plugin, proxy)) { Store.AppendValues(plugin); } } od.Destroy(); }
protected override void OnActivated() { base.OnActivated(); Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_workspace_open"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); FileFilter filter = new FileFilter(); filter.Name = "Workspace files"; filter.AddMimeType("Workspace file"); filter.AddPattern("*.msw"); fc.AddFilter(filter); if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedWorkspaceDir)) { fc.SetCurrentFolder(MainClass.Settings.LastOpenedWorkspaceDir); } if (fc.Run() == (int)ResponseType.Accept) { MainClass.Settings.LastOpenedWorkspaceDir = System.IO.Path.GetDirectoryName(fc.Filename); //CloseActualWorkspace(); Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fc.Filename); if (workspace != null) { //MainClass.Settings.RecentFiles.AddWorkspace(fc.Filename,fc.Filename); MainClass.MainWindow.ReloadWorkspace(workspace, true, true); } } fc.Destroy(); }
//Function shows the custom dialog based on provided action description string ShowCustomDialog(FileChooserAction fca, string action) { var temporarydialog = new Gtk.FileChooserDialog("", this, fca, "Cancel", ResponseType.Cancel, action, ResponseType.Accept); temporarydialog.SetCurrentFolder(@"."); //Only *.pro files are supposed to be supported var filefilter = new FileFilter(); filefilter.Name = "Project Files (*.pro)"; filefilter.AddPattern("*.pro"); temporarydialog.AddFilter(filefilter); //Returns empty string on cancellation, filename otherwise. string export = string.Empty; if (temporarydialog.Run() == (int)ResponseType.Accept) { export = temporarydialog.Filename; //Check if extension is presented, enforce its presence string export_ext = System.IO.Path.GetExtension(export); export += export_ext == ".pro" ? string.Empty : ".pro"; } temporarydialog.Destroy(); return(export); }
protected virtual void OnInstallClicked(object sender, System.EventArgs e) { GLib.File file = null; Gtk.FileChooserDialog script_chooser = new Gtk.FileChooserDialog("Helpers", this, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Catalog.GetString("_Select"), ResponseType.Ok); FileFilter filter = new FileFilter(); filter.AddPattern("*.tar"); filter.Name = Catalog.GetString(".tar Archives"); script_chooser.AddFilter(filter); if ((ResponseType)script_chooser.Run() == ResponseType.Ok) { file = GLib.FileFactory.NewForPath(script_chooser.Filename); } script_chooser.Destroy(); if (file == null) { return; } DockServices.Helpers.InstallHelper(file.Path); }
protected void OnTargetNMMLFileButtonClicked(object sender, System.EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Target NMML file", this.Toplevel as Gtk.Window, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept); Gtk.FileFilter filterNMML = new Gtk.FileFilter(); filterNMML.Name = "NMML Files"; filterNMML.AddPattern("*.nmml"); Gtk.FileFilter filterAll = new Gtk.FileFilter(); filterAll.Name = "All Files"; filterAll.AddPattern("*"); fc.AddFilter(filterNMML); fc.AddFilter(filterAll); if (mProject.TargetNMMLFile != "") { fc.SetFilename(mProject.TargetNMMLFile); } else { fc.SetFilename(mProject.BaseDirectory); } if (fc.Run() == (int)ResponseType.Accept) { string path = PathHelper.ToRelativePath(fc.Filename, mProject.BaseDirectory); TargetNMMLFileEntry.Text = path; } fc.Destroy(); }
protected void OnDownloadFolderClicked(object sender, System.EventArgs e) { Gtk.Application.Invoke(delegate { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Save log file", this, FileChooserAction.SelectFolder, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Ok, ResponseType.Accept); if (fc.Run() == (int)ResponseType.Accept) { downloadButImage.Stock = Stock.Harddisk; downloadButLabel.Text = fc.CurrentFolder; downloadFolder = fc.CurrentFolder; if (downloadButLabel.Text.Length > 10) { downloadButLabel.Text = downloadButLabel.Text.Remove(10) + "..."; } //sensorLogFileName = fc.Filename; //sensorLogCheckbutton.Active = true; } fc.Destroy(); }); }
protected void OnButtonAddIncludeClicked(object sender, System.EventArgs e) { var dialog = new Gtk.FileChooserDialog( "Select D Source Folder", Ide.IdeApp.Workbench.RootWindow, Gtk.FileChooserAction.SelectFolder, "Cancel", Gtk.ResponseType.Cancel, "Ok", Gtk.ResponseType.Ok) { TransientFor = Toplevel as Gtk.Window, WindowPosition = Gtk.WindowPosition.Center }; try { if (dialog.Run() == (int)Gtk.ResponseType.Ok) { text_Includes.Buffer.Text += (text_Includes.Buffer.CharCount == 0?"":"\n") + string.Join("\n", dialog.Filenames); } } finally { dialog.Destroy(); } }
protected void OnButton2Clicked(object sender, EventArgs e) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose a file", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Choose", ResponseType.Accept); string mytempfilename = ""; if (fc.Run() == (int)ResponseType.Accept) { mytempfilename = fc.CurrentFolder; if (File.Exists(configLocation)) { configLines[0] = mytempfilename; File.WriteAllLines(configLocation, configLines); } currentPath = mytempfilename; label2.Text = mytempfilename; fc.Destroy(); } else { fc.Destroy(); } }
public string GetExportFilePath() { //Создается здесь а не в конструкторе, потому что единственный способ //закрыть это destroy fileChooser = new Gtk.FileChooserDialog("Выберите где сохранить файл", this, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fileChooser.CurrentName = fileName; var result = fileChooser.Run(); if (result == (int)ResponseType.Accept) { return(fileChooser.Filename); } else { CloseWindow(); return(""); } }
protected void OnPdfActionActivated(object sender, System.EventArgs e) { // ********************************* object[] param = new object[4]; param[0] = "Cancel"; param[1] = Gtk.ResponseType.Cancel; param[2] = "Save"; param[3] = Gtk.ResponseType.Accept; Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Save File As", null, Gtk.FileChooserAction.Save, param); fc.CurrentName = DefaultExportFileName ?? report.Name; Gtk.FileFilter pdfFilter = new Gtk.FileFilter(); pdfFilter.Name = "PDF"; Gtk.FileFilter csvFilter = new Gtk.FileFilter(); csvFilter.Name = "CSV"; Gtk.FileFilter asphtmlFilter = new Gtk.FileFilter(); asphtmlFilter.Name = "ASP HTML"; Gtk.FileFilter excel2007 = new Gtk.FileFilter(); excel2007.Name = "Excel 2007"; Gtk.FileFilter htmlFilter = new Gtk.FileFilter(); htmlFilter.Name = "HTML"; Gtk.FileFilter mhtmlFilter = new Gtk.FileFilter(); mhtmlFilter.Name = "MHTML"; Gtk.FileFilter rtfFilter = new Gtk.FileFilter(); rtfFilter.Name = "RTF"; Gtk.FileFilter xmlFilter = new Gtk.FileFilter(); xmlFilter.Name = "XML"; fc.AddFilter(pdfFilter); fc.AddFilter(csvFilter); fc.AddFilter(asphtmlFilter); fc.AddFilter(excel2007); fc.AddFilter(htmlFilter); fc.AddFilter(mhtmlFilter); fc.AddFilter(xmlFilter); if (fc.Run() == (int)Gtk.ResponseType.Accept) { try { // Must use the RunGetData before each export or there is no data. report.RunGetData(this.Parameters); string filename = fc.Filename; OutputPresentationType exportType = OutputPresentationType.PDF; if (fc.Filter.Name == "CSV") { exportType = OutputPresentationType.CSV; if (filename.ToLower().Trim().EndsWith(".csv") == false) { filename = filename + ".csv"; } } else if (fc.Filter.Name == "PDF") { exportType = OutputPresentationType.PDF; if (filename.ToLower().Trim().EndsWith(".pdf") == false) { filename = filename + ".pdf"; } } else if (fc.Filter.Name == "ASP HTML") { exportType = OutputPresentationType.ASPHTML; if (filename.ToLower().Trim().EndsWith(".asphtml") == false) { filename = filename + ".asphtml"; } } else if (fc.Filter.Name == "Excel 2007") { exportType = OutputPresentationType.Excel; if (filename.ToLower().Trim().EndsWith(".xlsx") == false) { filename = filename + ".xlsx"; } } else if (fc.Filter.Name == "HTML") { exportType = OutputPresentationType.HTML; if (filename.ToLower().Trim().EndsWith(".html") == false) { filename = filename + ".html"; } } else if (fc.Filter.Name == "MHTML") { exportType = OutputPresentationType.MHTML; if (filename.ToLower().Trim().EndsWith(".mhtml") == false) { filename = filename + ".mhtml"; } } else if (fc.Filter.Name == "XML") { exportType = OutputPresentationType.XML; if (filename.ToLower().Trim().EndsWith(".xml") == false) { filename = filename + ".xml"; } } ExportReport(report, filename, exportType); } catch (Exception ex) { Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, false, "Error Saving Copy of PDF." + System.Environment.NewLine + ex.Message); m.Run(); m.Destroy(); } } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
public PeriodicTableUI(PeriodicTableLogic logic, PeriodicTableRenderer renderer) { Application.Init(); aboutDialog = new AboutDialog(); GladeXml dlg_main = new GladeXml(null, "main.glade", "mainWindow", null); dlg_main.Autoconnect(this); chunkSelect.Active = true; loader = new Loader(logic, mainWindow); generate.Clicked += new EventHandler(delegate(object sender, EventArgs e) { if (!string.IsNullOrEmpty(text.Buffer.Text)) { MemoryStream ms = new MemoryStream(); (loadedBitmap = renderer.Render(logic.Spell(text.Buffer.Text, chunkSelect.Active && !elementSearch.Active ? PeriodicTableLogic.SearchAlgorithm.ChunkSearch : PeriodicTableLogic.SearchAlgorithm.ElementBased))).Save(ms, ImageFormat.Png); output.Clear(); ms.Position = 0; using (Pixbuf oldPixbuf = output.Pixbuf) output.Pixbuf = new Pixbuf(ms); } else { MessageDialog md = new MessageDialog(mainWindow, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Please enter text into the conversion field"); md.Run(); md.Destroy(); } UpdateSensitivity(); }); saveAs.Clicked += new EventHandler(delegate(object sender, EventArgs e) { FileChooserDialog fc = new Gtk.FileChooserDialog("Save As...", mainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept) { DoOverwriteConfirmation = true }; FileFilter filter = new FileFilter(); filter.Name = "PNG images"; filter.AddMimeType("image/png"); filter.AddPattern("*.png"); fc.AddFilter(filter); if (fc.Run() == (int)ResponseType.Accept) { Stream file = File.Open(string.IsNullOrEmpty(Path.GetExtension(fc.Filename)) ? (fc.Filename + ".png") : fc.Filename, FileMode.OpenOrCreate); loadedBitmap.Save(file, ImageFormat.Png); file.Close(); } fc.Destroy(); }); about.Clicked += new EventHandler(delegate(object sender, EventArgs e) { aboutDialog.Run(); }); mainWindow.DeleteEvent += new DeleteEventHandler(delegate(object sender, DeleteEventArgs e) { Application.Quit(); }); Assembly asm = Assembly.GetExecutingAssembly(); aboutDialog.ProgramName = (asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title; aboutDialog.Version = asm.GetName().Version.ToString(); aboutDialog.Comments = (asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description; aboutDialog.Copyright = (asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright; aboutDialog.License = license; aboutDialog.Authors = authors; }
private void _SetupMenu() { SaveProjectAction.Activated += (sender, e) => { controller.Save(); }; SaveProjectAsAction.Activated += (sender, e) => { FileChooserDialog fc = new FileChooserDialog("Save ToonBoom Exporter Project", (Gtk.Window)Toplevel, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fc.SetCurrentFolder(System.IO.Directory.GetCurrentDirectory()); FileFilter ff = new FileFilter(); ff.AddPattern("*.tbp"); fc.Filter = ff; if (fc.Run() == (int)ResponseType.Accept) { controller.SaveAs(new Uri(fc.Filename)); Reinit(); } fc.Destroy(); }; NewProjectAction.Activated += (sender, e) => { FileChooserDialog fc = new FileChooserDialog("Create new ToonBoom Exporter Project", (Gtk.Window)Toplevel, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); fc.SetCurrentFolder(System.IO.Directory.GetCurrentDirectory()); FileFilter ff = new FileFilter(); ff.AddPattern("*.tbp"); fc.Filter = ff; if (fc.Run() == (int)ResponseType.Accept) { ProjectController ctrler = ProjectController.NewProject(new Uri(fc.Filename)); ProjectWindow window = new ProjectWindow(ctrler); fc.Destroy(); Destroy(); } else { fc.Destroy(); } }; OpenProjectAction.Activated += (sender, e) => { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open existing ToonBoom Exporter Project.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fc.SetCurrentFolder(System.IO.Directory.GetCurrentDirectory()); FileFilter ff = new FileFilter(); ff.AddPattern("*.tbp"); fc.Filter = ff; if (fc.Run() == (int)ResponseType.Accept) { ProjectController ctrler = ProjectController.LoadProject(new Uri(fc.Filename)); ProjectWindow window = new ProjectWindow(ctrler); fc.Destroy(); Destroy(); } else { fc.Destroy(); } }; SetBinaryLocationAction.Activated += (sender, e) => { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Set Toon Boom binary location.", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select Folder.", ResponseType.Accept); fc.SetCurrentFolder(@"C://Program Files (x86)/Toon Boom Animation/Toon Boom Harmony 12.2 Advanced/win64/bin"); if (fc.Run() == (int)ResponseType.Accept) { ProjectController.ConfigController.SetToonBoomBinPath(fc.Filename); fc.Destroy(); if (ProjectController.ConfigController.Validate()) { Gtk.MessageDialog dialog = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "Executables found."); dialog.Title = "Success"; dialog.Run(); dialog.Destroy(); } else { Gtk.MessageDialog dialog = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Executables could not be found."); dialog.Title = "Error"; dialog.Run(); dialog.Destroy(); } } else { fc.Destroy(); } }; }
public ProjectWindow(ProjectController controller) : base(Gtk.WindowType.Toplevel) { this.Build(); DeleteEvent += OnDeleteEvent; Notebook.RemovePage(0); NotebookExport.RemovePage(0); this.controller = controller; exportListController = controller.ExportController; this.Maximize(); controller.ExportListsChanged += RefreshExportLists; controller.XStageProjectListChanged += RefreshXStageProjectList; NotebookExport.SwitchPage += (o, args) => { Widget w = NotebookExport.GetNthPage((int)args.PageNum); exportListController.SetActiveExportList(notebookMap [w]); Console.WriteLine(notebookMap [w].Name); }; AddXStageButton.Clicked += (sender, e) => { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open xstage file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fc.SetCurrentFolder(new Uri(controller.FileLocation, "./").AbsolutePath); FileFilter ff = new FileFilter(); ff.AddPattern("*.xstage"); fc.Filter = ff; if (fc.Run() == (int)ResponseType.Accept) { XStageProject xsp = XStageProject.Load(fc.Filename); List <XStageElement> elementTable = xsp.elements; controller.AddXStageProject(new Uri(fc.Uri)); } fc.Destroy(); }; NewExportListButton.Clicked += (sender, e) => { Dialog d = new Dialog("Enter Name", this, DialogFlags.Modal, "Cancel", ResponseType.Cancel, "Ok", ResponseType.Ok); Entry nameEntry = new Entry(); d.VBox.Add(nameEntry); d.ShowAll(); nameEntry.Activated += (sender1, e1) => { d.Respond(ResponseType.Ok); }; int response = d.Run(); if ((ResponseType)response == ResponseType.Ok) { controller.AddExportList(nameEntry.Text); } d.Destroy(); }; _SetupMenu(); _SetupExport(); Reinit(); }
/* GS Result*/ public void GSResult(gsParamState_t gs_result) { TempFile tempfile = null; if (gs_result.outputfile != null) { tempfile = new TempFile(gs_result.outputfile); } if (gs_result.result == GS_Result_t.gsCANCELLED) { if (tempfile != null) { try { tempfile.DeleteFile(); } catch { ShowMessage(NotifyType_t.MESS_STATUS, "Problem Deleting Temp File"); } } return; } if (gs_result.result == GS_Result_t.gsFAILED) { ShowMessage(NotifyType_t.MESS_STATUS, "GS Failed Conversion"); if (tempfile != null) { try { tempfile.DeleteFile(); } catch { ShowMessage(NotifyType_t.MESS_STATUS, "Problem Deleting Temp File"); } } return; } switch (gs_result.task) { case GS_Task_t.PS_DISTILL: m_origfile = gs_result.inputfile; Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog("Save Document", (Gtk.Window) this.Toplevel, Gtk.FileChooserAction.Save); dialog.LocalOnly = true; dialog.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); dialog.AddButton(Gtk.Stock.Save, Gtk.ResponseType.Yes); dialog.SetFilename(System.IO.Path.GetFileNameWithoutExtension(m_origfile) + ".pdf"); Gtk.FileFilter filter = new Gtk.FileFilter(); filter.Name = "doc/pdf"; filter.AddMimeType("application/pdf"); filter.AddPattern("*.pdf"); dialog.Filter = filter; int response = dialog.Run(); if (response == (int)Gtk.ResponseType.Yes) { m_currfile = dialog.Filename; try { if (System.IO.File.Exists(m_currfile)) { System.IO.File.Delete(m_currfile); } var res = System.IO.File.Exists(tempfile.Filename); System.IO.File.Copy(tempfile.Filename, dialog.Filename); } catch (Exception except) { ShowMessage(NotifyType_t.MESS_ERROR, "Exception Saving Distilled Result:" + except.Message); } } dialog.Destroy(); tempfile.DeleteFile(); break; } }
protected void OnPdfActionActivated(object sender, System.EventArgs e) { // ********************************* object[] param = new object[4]; param[0] = Strings.ButtonCancel_Text; param[1] = Gtk.ResponseType.Cancel; param[2] = Strings.ButtonSave_Text; param[3] = Gtk.ResponseType.Accept; Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(Strings.FileChooser_SaveFileTo_Title, null, Gtk.FileChooserAction.Save, param); fc.CurrentName = DefaultExportFileName ?? report.Name; if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.PDF)) { Gtk.FileFilter pdfFilter = new Gtk.FileFilter { Name = "PDF" }; var extensionPDF = ".pdf"; pdfFilter.AddPattern($"*{extensionPDF}"); fc.AddFilter(pdfFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.CSV)) { Gtk.FileFilter csvFilter = new Gtk.FileFilter { Name = "CSV" }; var extensionCSV = ".csv"; csvFilter.AddPattern($"*{extensionCSV}"); fc.AddFilter(csvFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.ExcelTableOnly)) { Gtk.FileFilter excel2007Data = new Gtk.FileFilter { Name = "Excel no formatting (Fast)" }; var extensionXLSX = ".xlsx"; excel2007Data.AddPattern($"*{extensionXLSX}"); fc.AddFilter(excel2007Data); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.Excel2007)) { Gtk.FileFilter excel2007 = new Gtk.FileFilter { Name = "Excel with formatting (Slow)" }; var extensionXLSX = ".xlsx"; excel2007.AddPattern($"*{extensionXLSX}"); fc.AddFilter(excel2007); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.TIF)) { Gtk.FileFilter tiffFilter = new Gtk.FileFilter { Name = "TIFF" }; var extensionTIFF = ".tiff"; tiffFilter.AddPattern($"*{extensionTIFF}"); fc.AddFilter(tiffFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.ASPHTML)) { Gtk.FileFilter asphtmlFilter = new Gtk.FileFilter { Name = "ASP HTML" }; var extensionASPHTML = ".asphtml"; asphtmlFilter.AddPattern($"*{extensionASPHTML}"); fc.AddFilter(asphtmlFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.HTML)) { Gtk.FileFilter htmlFilter = new Gtk.FileFilter { Name = "HTML" }; var extensionHTML = ".html"; htmlFilter.AddPattern($"*{extensionHTML}"); fc.AddFilter(htmlFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.MHTML)) { Gtk.FileFilter mhtmlFilter = new Gtk.FileFilter { Name = "MHTML" }; var extensionMHTML = ".mhtml"; mhtmlFilter.AddPattern($"*{extensionMHTML}"); fc.AddFilter(mhtmlFilter); } if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.XML)) { Gtk.FileFilter xmlFilter = new Gtk.FileFilter { Name = "XML" }; var extensionXML = ".xml"; xmlFilter.AddPattern($"*{extensionXML}"); fc.AddFilter(xmlFilter); } if (!fc.Filters.Any()) { Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, false, "Export in all document formats is prohibited"); m.WindowPosition = WindowPosition.Center; m.Run(); m.Destroy(); return; } if (fc.Run() == (int)Gtk.ResponseType.Accept) { try { string searchPattern = "*"; string filename = fc.Filename; OutputPresentationType exportType = OutputPresentationType.PDF; if (fc.Filter.Name == "CSV") { exportType = OutputPresentationType.CSV; if (filename.ToLower().Trim().EndsWith(".csv") == false) { filename = filename + ".csv"; searchPattern = "*.csv"; } } else if (fc.Filter.Name == "PDF") { exportType = OutputPresentationType.PDF; if (filename.ToLower().Trim().EndsWith(".pdf") == false) { filename = filename + ".pdf"; searchPattern = "*.pdf"; } } else if (fc.Filter.Name == "Excel 2007 Data") { exportType = OutputPresentationType.ExcelTableOnly; if (filename.ToLower().Trim().EndsWith(".xlsx") == false) { filename = filename + ".xlsx"; searchPattern = "*.xlsx"; } } else if (fc.Filter.Name == "Excel 2007") { exportType = OutputPresentationType.Excel2007; if (filename.ToLower().Trim().EndsWith(".xlsx") == false) { filename = filename + ".xlsx"; searchPattern = "*.xlsx"; } } else if (fc.Filter.Name == "TIFF") { exportType = OutputPresentationType.TIF; if (filename.ToLower().Trim().EndsWith(".tif") == false) { filename = filename + ".tif"; searchPattern = "*.tif"; } } else if (fc.Filter.Name == "ASP HTML") { exportType = OutputPresentationType.ASPHTML; if (filename.ToLower().Trim().EndsWith(".asphtml") == false) { filename = filename + ".asphtml"; searchPattern = "*.asphtml"; } } else if (fc.Filter.Name == "HTML") { exportType = OutputPresentationType.HTML; if (filename.ToLower().Trim().EndsWith(".html") == false) { filename = filename + ".html"; searchPattern = "*.html"; } } else if (fc.Filter.Name == "MHTML") { exportType = OutputPresentationType.MHTML; if (filename.ToLower().Trim().EndsWith(".mhtml") == false) { filename = filename + ".mhtml"; searchPattern = "*.mhtml"; } } else if (fc.Filter.Name == "XML") { exportType = OutputPresentationType.XML; if (filename.ToLower().Trim().EndsWith(".xml") == false) { filename = filename + ".xml"; searchPattern = "*.xml"; } } string directory = filename.Remove(filename.LastIndexOf(@"\") + 1); var files = Directory.GetFiles(directory, searchPattern); //Check for files with same name in directory if (files.Any()) { for (int i = 0; i < files.Length; i++) { if (files[i] == filename) { //If found files with the same name in directory MessageDialog m = new Gtk.MessageDialog(null, DialogFlags.Modal, MessageType.Question, Gtk.ButtonsType.YesNo, false, Strings.SaveToFile_CheckIf_SameFilesInDir); m.SetPosition(WindowPosition.Center); ResponseType result = (ResponseType)m.Run(); m.Destroy(); if (result == ResponseType.Yes) { // Must use the RunGetData before each export or there is no data. report.RunGetData(this.Parameters); ExportReport(report, filename, exportType); break; } else { break; } } if (i + 1 == files.Length && files[i] != filename) { //If no files with the same name found in directory // Must use the RunGetData before each export or there is no data. report.RunGetData(this.Parameters); ExportReport(report, filename, exportType); break; } } } else { //If no files found in directory // Must use the RunGetData before each export or there is no data. report.RunGetData(this.Parameters); ExportReport(report, filename, exportType); } } catch (Exception ex) { Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, false, "Error Saving Copy of PDF." + System.Environment.NewLine + ex.Message); m.Run(); m.Destroy(); } } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
protected void ReloadData(object sender, EventArgs e) { string result = null; Gtk.FileChooserDialog saveDialog = new Gtk.FileChooserDialog("Load File", null, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Load", Gtk.ResponseType.Accept); Gtk.FileFilter fileFilter = new FileFilter(); fileFilter.AddPattern("*.nirs"); fileFilter.Name = ".nirs"; saveDialog.AddFilter(fileFilter); Gtk.FileFilter fileFilter2 = new FileFilter(); fileFilter.AddPattern("*.snirf"); fileFilter.Name = ".snirf"; saveDialog.AddFilter(fileFilter2); if (saveDialog.Run() == (int)Gtk.ResponseType.Accept) { result = saveDialog.Filename; if (nirsdata == null) { nirsdata = new List <nirs.core.Data>(); } nirsdata.Clear(); if (result.Contains(".nirs")) { nirsdata.Add(nirs.io.readDOTnirs(result)); } else if (result.Contains(".snirf")) { nirs.core.Data[] datas = nirs.io.readSNIRF(result); nirsdata.Add(datas[0]); } for (int i = 0; i < nirsdata[0].probe.ChannelMap.Length; i++) { nirsdata[0].probe.ChannelMap[i].datasubtype = string.Format("raw {0}", nirsdata[0].probe.ChannelMap[i].datasubtype); } _handles.dataListStore.AppendValues(result, "Previously recorded file"); Gtk.ListStore ClearList = new Gtk.ListStore(typeof(string)); MainClass.win._handles.whichdata.Model = ClearList; List <string> datatypes = new List <string>(); for (int ii = 0; ii < nirsdata[0].probe.ChannelMap.Length; ii++) { datatypes.Add(nirsdata[0].probe.ChannelMap[ii].datasubtype); } datatypes = datatypes.Distinct().ToList(); foreach (string s in datatypes) { MainClass.win._handles.whichdata.AppendText(s); } MainClass.win._handles.whichdata.Active = 0; combobox_whichdata.Sensitive = true; combobox_selectview.Sensitive = true; checkbutton_autoscaleY.Sensitive = true; checkbutton_timeWindow.Sensitive = true; entry_timeWindow.Sensitive = true; checkbuttonYmax.Sensitive = true; checkbuttonYmin.Sensitive = true; entryYmax.Sensitive = true; entryYmin.Sensitive = true; } saveDialog.Destroy(); drawingarea_SDG.QueueDraw(); drawingarea_Data.QueueDraw(); drawingarea_SDG2.QueueDraw(); drawingarea_Data2.QueueDraw(); }
protected virtual void OnAcceptClicked(object sender, System.EventArgs e) { // Ask for report file Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Elija dónde guardar el archivo de reporte", this, FileChooserAction.Save, "Cancelar", ResponseType.Cancel, "Guardar", ResponseType.Accept); if (fc.Run() != (int)ResponseType.Accept) { fc.Destroy(); return; } // Add "pdf" extension if it's not present string filename = fc.Filename; if (!fc.Filename.ToLower().EndsWith(".pdf")) { filename += ".pdf"; } // Run report according to the type selected try { ReportType rt = null; if (this.rbPersonsList.Active) { rt = ReportType.GetInstance <SimplePersonsList>(this.selection, this.PageSizeSelected, filename); } else if (this.rbAttendancesList.Active) { rt = ReportType.GetInstance <SimpleAttendanceList>(this.selection, this.PageSizeSelected, filename); } rt.Run(); } catch (Exception ex) { MessageDialog errorMessage = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, true, "Hubo un error al generar el reporte:\n'" + ex.Message + "'"); errorMessage.Title = "Error"; errorMessage.Run(); errorMessage.Destroy(); } fc.Destroy(); // Success message MessageDialog successMessage = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, true, "Reporte generado correctamente."); successMessage.Title = "Reporte generado"; successMessage.Run(); successMessage.Destroy(); }
public FolderListGui(string Title, string Description, string[] Folders) { this.Build(); this.Folders = Folders; this.label12.Text = Description; this.Title = Title; NodeStore store = new NodeStore(typeof(StringNode)); foreach (string folder in Folders) { store.AddNode(new StringNode() { Value = folder }); } nodeview1.NodeStore = store; nodeview1.AppendColumn("Folder", new Gtk.CellRendererText(), "text", 0); buttonOk.Clicked += delegate { // get the folders List <string> nodes = new List <string>(); var enumerator = store.GetEnumerator(); while (enumerator.MoveNext()) { string folder = ((StringNode)enumerator.Current).Value; if (folder.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { folder = folder.Substring(0, folder.Length - 1); } nodes.Add(folder); } this.Folders = nodes.ToArray(); this.DialogResult = ResponseType.Ok; this.Destroy(); }; buttonCancel.Clicked += delegate { this.DialogResult = ResponseType.Cancel; this.Destroy(); }; btnAdd.Clicked += delegate { using (Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Folder to scan.", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept)){ fc.LocalOnly = false; if (fc.Run() == (int)ResponseType.Accept) { store.AddNode(new StringNode() { Value = fc.Filename }); } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); } }; btnRemove.Clicked += delegate { foreach (var node in nodeview1.NodeSelection.SelectedNodes) { store.RemoveNode(node); } }; }