public override void LoadPanelContents()
        {
            InitializeHelper();

            var masterSettingsFile = helper.GetProperty <string>("SourceAnalysisOverrideSettingsFile", "", true);

            if (masterSettingsFile.Length == 0)
            {
                helper.SetProperty <string>("SourceAnalysisOverrideSettingsFile",
                                            StyleCopWrapper.GetMasterSettingsFile(),
                                            true,
                                            PropertyStorageLocations.Base);
            }

            AnalysisProjectOptions po = new AnalysisProjectOptions();

            po.Dock = DockStyle.Fill;
            Controls.Add(po);

            ChooseStorageLocationButton btnEnable;
            ChooseStorageLocationButton btnFileLocation;

            btnEnable       = helper.BindBoolean(po.EnableCheckBox, "RunSourceAnalysis", false).CreateLocationButton(po.EnableCheckBox);
            btnFileLocation = helper.BindString(po.SettingsFileTextBox, "SourceAnalysisOverrideSettingsFile", TextBoxEditMode.EditRawProperty).CreateLocationButton(po.SettingsFileTextBox);
            ConfigurationGuiBinding binding = po.CreateBinding();

            binding.RegisterLocationButton(btnEnable);
            binding.RegisterLocationButton(btnFileLocation);

            helper.AddConfigurationSelector(this);

            po.ModifyStyleCopSettingsButton.Click += ModifyStyleCopSettingsClick;
        }
        public override void StartBuild()
        {
            BuildOptions options = new BuildOptions(BuildTarget.Rebuild, CallbackMethod);

            options.TargetForDependencies = BuildTarget.Build;
            options.ProjectAdditionalProperties["RunSourceAnalysis"] = "true";
            options.ProjectAdditionalProperties["StyleCopFile"]      = StyleCopWrapper.FindStyleCopPath() ?? string.Empty;
            BuildEngine.BuildInGui(this.ProjectToBuild, options);
        }
        void ModifyStyleCopSettingsClick(object sender, EventArgs e)
        {
            var settingsFile = helper.GetProperty <string>("SourceAnalysisOverrideSettingsFile", "", true);

            if (settingsFile == StyleCopWrapper.GetMasterSettingsFile())
            {
                if (ConfirmSwitchFromMaster())
                {
                    settingsFile = CopyFromMaster();
                }
            }

            if (!System.IO.File.Exists(settingsFile))
            {
                if (ConfirmReplaceMissingFile())
                {
                    settingsFile = CopyFromMaster();
                }
                else
                {
                    MessageService.ShowWarning("No settings file found to modify.");
                    return;
                }
            }

            string styleCopPath = StyleCopWrapper.FindStyleCopPath();
            string executable;

            if (styleCopPath != null)
            {
                executable = Path.Combine(styleCopPath, "StyleCopSettingsEditor.exe");
            }
            else
            {
                executable = null;
            }
            string parameters = "\"" + settingsFile + "\"";

            if (!File.Exists(executable))
            {
                LoggingService.Debug("StyleCopSettingsEditor.exe: " + executable);
                MessageService.ShowWarning("Unable to find the StyleCop Settings editor. Please specify the StyleCop location in Tools Options.");
                return;
            }

            using (Process p = Process.Start("\"" + executable + "\"", parameters)) {
                // No need to wait for the settings dialog to close - we can leave it open.
            }
        }
        void ShowStatus()
        {
            string path = StyleCopWrapper.FindStyleCopPath();

            if (path == null)
            {
                Get <Label>("status").Text = StringParser.Parse("StyleCop not found in the given path.");
                Get <Button>("ModifyStyleCopSettings").Enabled = false;
            }
            else
            {
                Get <Label>("status").Text = StringParser.Parse("StyleCop was found in: ")
                                             + Environment.NewLine + path;
                Get <Button>("ModifyStyleCopSettings").Enabled = true;
            }
        }
        private string CopyFromMaster()
        {
            var newSettingsFile = helper.Project.Directory + "\\Settings.SourceAnalysis";

            System.IO.File.Copy(
                StyleCopWrapper.GetMasterSettingsFile(),
                newSettingsFile,
                true
                );
            helper.SetProperty <string>("SourceAnalysisOverrideSettingsFile",
                                        newSettingsFile,
                                        true,
                                        PropertyStorageLocations.Base
                                        );
            return(newSettingsFile);
        }
        void ModifyStyleCopSettingsClick(object sender, EventArgs e)
        {
            var executable = Path.Combine(StyleCopWrapper.FindStyleCopPath(), "StyleCopSettingsEditor.exe");
            var parameters = "\"" + StyleCopWrapper.GetMasterSettingsFile() + "\"";

            if (!File.Exists(executable))
            {
                LoggingService.Debug("StyleCopSettingsEditor.exe: " + executable);
                MessageService.ShowWarning("Unable to find the StyleCop Settings editor. Please specify the StyleCop location in Tools Options.");
                return;
            }

            using (Process p = Process.Start("\"" + executable + "\"", parameters))
            {
                // No need to wait for the settings dialog to close - we can leave it open.
            }
        }
 void FindStyleCopPathClick(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog()) {
         dlg.DefaultExt = "dll";
         dlg.Filter     = StringParser.Parse("StyleCop|Microsoft.StyleCop.dll|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             string path = Path.GetDirectoryName(dlg.FileName);
             if (StyleCopWrapper.IsStyleCopPath(path))
             {
                 StyleCopPath = path;
             }
             else
             {
                 MessageService.ShowError("Directory does not contain StyleCop.");
             }
         }
     }
     ShowStatus();
 }
Пример #8
0
 void FindStyleCopPathClick(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog()) {
         dlg.DefaultExt = "dll";
         dlg.Filter     = StringParser.Parse("StyleCop|*" + StyleCopWrapper.STYLE_COP_FILE + "|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             string path = dlg.FileName;
             if (StyleCopWrapper.IsStyleCopPath(path))
             {
                 StyleCopPath = path;
             }
             else
             {
                 MessageService.ShowError(string.Format("Directory does not contain StyleCop (*{0}).", StyleCopWrapper.STYLE_COP_FILE));
             }
         }
     }
     ShowStatus();
 }