示例#1
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            string path = assemblyPathTextBox.Text;

            try
            {
                FileInfo info = new FileInfo(path);

                if (!info.Exists)
                {
                    DialogResult answer = UserMessage.Ask(string.Format(
                                                              "The path {0} does not exist. Do you want to use it anyway?", path));
                    if (answer != DialogResult.Yes)
                    {
                        return;
                    }
                }

                DialogResult = DialogResult.OK;
                this.path    = path;
                this.Close();
            }
            catch (System.Exception exception)
            {
                assemblyPathTextBox.SelectAll();
                UserMessage.DisplayFailure(exception, "Invalid Entry");
            }
        }
        private void removeButton_Click(object sender, System.EventArgs e)
        {
            if (project.Configs.Count == 1)
            {
                string msg = "Removing the last configuration will make the project unloadable until you add another configuration.\r\rAre you sure you want to remove the configuration?";

                if (UserMessage.Ask(msg, "Remove Configuration") == DialogResult.No)
                {
                    return;
                }
            }

            project.Configs.RemoveAt(selectedIndex);
            FillListBox();
        }
示例#3
0
        private DialogResult SaveProjectIfDirty()
        {
            DialogResult result = DialogResult.OK;

            if (loader.TestProject.IsDirty)
            {
                string msg = "Project has been changed. Do you want to save changes?";

                result = UserMessage.Ask(msg, MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    SaveProject();
                }
            }

            return(result);
        }
示例#4
0
        private static DialogResult SaveProjectIfDirty(Form owner)
        {
            DialogResult result = DialogResult.OK;
            TestLoader   loader = Services.TestLoader;

            if (loader.TestProject.IsDirty)
            {
                string msg = "Project has been changed. Do you want to save changes?";

                result = UserMessage.Ask(msg, MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    SaveProject(owner);
                }
            }

            return(result);
        }
示例#5
0
        private static DialogResult SaveProjectIfDirty(Form owner)
        {
            DialogResult result  = DialogResult.OK;
            NUnitProject project = Services.TestLoader.TestProject;

            if (project.IsDirty)
            {
                string msg = string.Format(
                    "Project {0} has been changed. Do you want to save changes?", project.Name);

                result = UserMessage.Ask(msg, MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    SaveProject(owner);
                }
            }

            return(result);
        }
示例#6
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            if (Services.TestLoader.IsTestLoaded && this.HasChangesRequiringReload)
            {
                DialogResult answer = UserMessage.Ask(
                    "Some changes will only take effect when you reload the test project. Do you want to reload now?",
                    "NUnit Options",
                    MessageBoxButtons.YesNo);

                if (answer == DialogResult.Yes)
                {
                    this.reloadProjectOnClose = true;
                }
            }

            ApplySettings();

            DialogResult = DialogResult.OK;

            Close();
        }
示例#7
0
        public static void AddToProject(Form owner, string configName)
        {
            TestLoader    loader = Services.TestLoader;
            ProjectConfig config = configName == null
                                ? loader.TestProject.ActiveConfig
                                : loader.TestProject.Configs[configName];

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title            = "Add Assemblies To Project";
            dlg.InitialDirectory = config.BasePath;

            if (VisualStudioSupport)
            {
                dlg.Filter =
                    "Projects & Assemblies(*.csproj,*.vbproj,*.vjsproj, *.vcproj,*.dll,*.exe )|*.csproj;*.vjsproj;*.vbproj;*.vcproj;*.dll;*.exe|" +
                    "Visual Studio Projects (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
                    "C# Projects (*.csproj)|*.csproj|" +
                    "J# Projects (*.vjsproj)|*.vjsproj|" +
                    "VB Projects (*.vbproj)|*.vbproj|" +
                    "C++ Projects (*.vcproj)|*.vcproj|" +
                    "Assemblies (*.dll,*.exe)|*.dll;*.exe";
            }
            else
            {
                dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
            }

            dlg.FilterIndex = 1;
            dlg.FileName    = "";

            if (dlg.ShowDialog(owner) != DialogResult.OK)
            {
                return;
            }

            if (PathUtils.IsAssemblyFileType(dlg.FileName))
            {
                config.Assemblies.Add(dlg.FileName);
                return;
            }
            else if (VSProject.IsProjectFile(dlg.FileName))
            {
                try
                {
                    VSProject         vsProject = new VSProject(dlg.FileName);
                    MessageBoxButtons buttons;
                    string            msg;

                    if (configName != null && vsProject.Configs.Contains(configName))
                    {
                        msg = "The project being added may contain multiple configurations;\r\r" +
                              "Select\tYes to add all configurations found.\r" +
                              "\tNo to add only the " + configName + " configuration.\r" +
                              "\tCancel to exit without modifying the project.";
                        buttons = MessageBoxButtons.YesNoCancel;
                    }
                    else
                    {
                        msg = "The project being added may contain multiple configurations;\r\r" +
                              "Select\tOK to add all configurations found.\r" +
                              "\tCancel to exit without modifying the project.";
                        buttons = MessageBoxButtons.OKCancel;
                    }

                    DialogResult result = UserMessage.Ask(msg, buttons);
                    if (result == DialogResult.Yes || result == DialogResult.OK)
                    {
                        loader.TestProject.Add(vsProject);
                        return;
                    }
                    else if (result == DialogResult.No)
                    {
                        foreach (string assembly in vsProject.Configs[configName].Assemblies)
                        {
                            config.Assemblies.Add(assembly);
                        }
                        return;
                    }
                }
                catch (Exception ex)
                {
                    UserMessage.DisplayFailure(ex.Message, "Invalid VS Project");
                }
            }
        }