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")); } } }
PolicySet GetPolicySet(bool notifyErrors) { if (radioCustom.Active) { return(PolicyService.GetPolicySet(combPolicies.ActiveText)); } else { if (string.IsNullOrEmpty(fileEntry.Path)) { if (notifyErrors) { MessageService.ShowError(GettextCatalog.GetString("File name not specified")); } return(null); } try { PolicySet pset = new PolicySet(); pset.LoadFromFile(fileEntry.Path); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = System.IO.Path.GetDirectoryName(fileEntry.Path); return(pset); } catch (Exception ex) { if (notifyErrors) { MessageService.ShowException(ex, GettextCatalog.GetString("The policy set could not be loaded")); } return(null); } } }
PolicySet GetPolicySet(bool notifyErrors) { if (radioCustom.Active) { return(PolicyService.GetPolicySet(combPolicies.ActiveText)); } var f = fileEntry.Path; if (string.IsNullOrEmpty(f) || !System.IO.File.Exists(f)) { return(null); } var pset = new PolicySet(); pset.LoadFromFile(fileEntry.Path); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = System.IO.Path.GetDirectoryName(fileEntry.Path); return(pset); }