void HandleFromFile(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(GettextCatalog.GetString("Select Policy File")); dlg.Action = FileChooserAction.Open; dlg.TransientFor = this; dlg.AddFilter(GettextCatalog.GetString("MonoDevelop policy files"), "*.mdpolicy"); dlg.AddAllFilesFilter(); dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir; if (dlg.Run()) { try { PolicySet pset = new PolicySet(); pset.LoadFromFile(dlg.SelectedFile); if (string.IsNullOrEmpty(pset.Name)) { pset.Name = dlg.SelectedFile.FileNameWithoutExtension; } pset.Name = GetValidName(pset.Name); sets.Add(pset); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory; FillPolicySets(); policiesCombo.Active = sets.IndexOf(pset); } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The policy set could not be loaded")); } } }
void HandleClicked(object sender, EventArgs e) { var dlg = new OpenFileDialog(GettextCatalog.GetString("Select Assembly"), MonoDevelop.Components.FileChooserAction.Open); // dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.[Dd][Ll][Ll]", "*.[Ee][Xx][Ee]"); dlg.AddFilter(GettextCatalog.GetString("Assemblies"), "*.dll", "*.exe"); dlg.CurrentFolder = basePath; dlg.SelectMultiple = true; dlg.TransientFor = selectDialog; if (dlg.Run()) { basePath = dlg.CurrentFolder; foreach (string file in dlg.SelectedFiles) { var fn = new FilePath(file).CanonicalPath; var asm = assemblies.FirstOrDefault(a => a.File.Equals(fn)); if (asm != null) { if (!asm.Selected) { asm.Selected = true; AddReference(file); } continue; } bool isAssembly = true; try { SystemAssemblyService.GetAssemblyName(System.IO.Path.GetFullPath(file)); } catch { isAssembly = false; } if (isAssembly) { assemblies.Add(new AssemblyInfo(file) { Selected = true }); AddReference(file); if (IsExternalAssembly(file)) { selectDialog.RegisterFileReference(file); } else if (!IsNuGetAssembly(file)) { selectDialog.RegisterFileReference(file, project.ParentSolution.FileName); } } else { MessageService.ShowError(GettextCatalog.GetString("File '{0}' is not a valid .Net Assembly", file)); } } Reset(); } }
private async void Button1_Click(object sender, MouseEventArgs e) { list_box.Items.Clear(); var ofd = new OpenFileDialog { AllowMultiple = true, InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Title = "Open some files up" }; ofd.AddFilter("All Files", "*"); ofd.AddFilter("Image Files", "png", "gif", "jpg", "jpeg"); ofd.AddFilter("Text Files", "txt", "log"); if ((await ofd.ShowDialog(FindForm())) == DialogResult.OK) { foreach (var file in ofd.FileNames) { list_box.Items.Add(file); } } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.AddFilter("Token File", "*.xml"); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileInfo fi = new FileInfo(ofd.FileName); if (fi.DirectoryName == System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)) { TokenFile = fi.Name; } else { TokenFile = ofd.FileName; } } } }
void HandleToFile(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(GettextCatalog.GetString("Select Policy File")); dlg.TransientFor = this; dlg.InitialFileName = currentSet.Name + ".mdpolicy"; dlg.Action = FileChooserAction.Save; dlg.AddFilter(GettextCatalog.GetString("MonoDevelop policy files"), "*.mdpolicy"); dlg.AddAllFilesFilter(); dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir; if (dlg.Run()) { try { currentSet.SaveToFile(dlg.SelectedFile); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory; } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The policy set could not be saved")); } } }
void HandleClicked (object sender, EventArgs e) { var dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Assembly"), FileChooserAction.Open); // dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.[Dd][Ll][Ll]", "*.[Ee][Xx][Ee]"); dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.dll", "*.exe"); dlg.CurrentFolder = basePath; dlg.SelectMultiple = true; if (dlg.Run ()) { basePath = dlg.CurrentFolder; foreach (string file in dlg.SelectedFiles) { var fn = new FilePath (file).CanonicalPath; var asm = assemblies.FirstOrDefault (a => a.File.Equals (fn)); if (asm != null) { if (!asm.Selected) { asm.Selected = true; AddReference (file); } continue; } bool isAssembly = true; try { SystemAssemblyService.GetAssemblyName (System.IO.Path.GetFullPath (file)); } catch { isAssembly = false; } if (isAssembly) { assemblies.Add (new AssemblyInfo (file) { Selected = true }); AddReference (file); if (IsExternalAssembly (file)) selectDialog.RegisterFileReference (file); else if (!IsNuGetAssembly (file)) selectDialog.RegisterFileReference (file, project.ParentSolution.FileName); } else { MessageService.ShowError (GettextCatalog.GetString ("File '{0}' is not a valid .Net Assembly", file)); } } Reset (); } }
void HandleToFile (object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File")); dlg.TransientFor = this; dlg.InitialFileName = currentSet.Name + ".mdpolicy"; dlg.Action = FileChooserAction.Save; dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy"); dlg.AddAllFilesFilter (); dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir; if (dlg.Run ()) { try { currentSet.SaveToFile (dlg.SelectedFile); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory; } catch (Exception ex) { MessageService.ShowException (ex, GettextCatalog.GetString ("The policy set could not be saved")); } } }
void HandleFromFile (object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File")); dlg.Action = FileChooserAction.Open; dlg.TransientFor = this; dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy"); dlg.AddAllFilesFilter (); dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir; if (dlg.Run ()) { try { PolicySet pset = new PolicySet (); pset.LoadFromFile (dlg.SelectedFile); if (string.IsNullOrEmpty (pset.Name)) pset.Name = dlg.SelectedFile.FileNameWithoutExtension; pset.Name = GetUnusedName (pset.Name); sets.Add (pset); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory; FillPolicySets (); policiesCombo.Active = sets.IndexOf (pset); } catch (Exception ex) { MessageService.ShowException (ex, GettextCatalog.GetString ("The policy set could not be loaded")); } } }