Exemplo n.º 1
0
        protected void OnButtonOkClicked(object sender, EventArgs e)
        {
            if (radioCustom.Active)
            {
                if (entryName.Text.Length == 0)
                {
                    MessageService.ShowError(GettextCatalog.GetString("Policy name not specified"));
                    return;
                }
                PolicySet pset = CreatePolicySet();
                pset.Name = entryName.Text;
                PolicyService.AddUserPolicySet(pset);
                PolicyService.SavePolicies();
            }
            else
            {
                if (fileEntry.Path == null || fileEntry.Path.Length == 0)
                {
                    MessageService.ShowError(GettextCatalog.GetString("File name not specified"));
                    return;
                }
                FilePath file = fileEntry.Path;
                if (file.Extension != ".mdpolicy")
                {
                    file = file + ".mdpolicy";
                }
                DefaultFileDialogPolicyDir = file.ParentDirectory;

                if (System.IO.File.Exists(file) && !MessageService.Confirm(GettextCatalog.GetString("The file {0} already exists. Do you want to replace it?", file), AlertButton.Replace))
                {
                    return;
                }

                PolicySet pset = CreatePolicySet();
                pset.Name = file.FileName;
                try {
                    pset.SaveToFile(file);
                } catch (Exception ex) {
                    MessageService.ShowError(GettextCatalog.GetString("The policy file could not be saved"), ex);
                    return;
                }
            }
            Respond(Gtk.ResponseType.Ok);
        }
Exemplo n.º 2
0
        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"));
                }
            }
        }