Ejemplo n.º 1
0
        /// <summary>
        /// Analyzes rules tree directly from UI.
        /// </summary>
        public static void Initialize(PropertyControl tabControl)
        {
            IPropertyControlPage analyzersOptions = tabControl.Pages[0];
            TreeView tree = (TreeView)analyzersOptions.GetType().InvokeMember(
                "analyzeTree",
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField,
                null,
                analyzersOptions,
                null);

            s_ruleNodes = new Dictionary<string, Dictionary<string, TreeNode>>();

            foreach (TreeNode parserNode in tree.Nodes)
            {
                foreach (TreeNode analyzerNode in parserNode.Nodes)
                {
                    SourceAnalyzer analyzer = (SourceAnalyzer)analyzerNode.Tag;
                    s_ruleNodes[analyzer.Id] = new Dictionary<string, TreeNode>();
                    AnalyzeRuleNodes(s_ruleNodes[analyzer.Id], analyzerNode);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PropertyDialog));
     this.help = new System.Windows.Forms.Button();
     this.cancel = new System.Windows.Forms.Button();
     this.ok = new System.Windows.Forms.Button();
     this.apply = new System.Windows.Forms.Button();
     this.properties = new Microsoft.StyleCop.PropertyControl();
     this.SuspendLayout();
     //
     // help
     //
     resources.ApplyResources(this.help, "help");
     this.help.Name = "help";
     this.help.Click += new System.EventHandler(this.HelpClick);
     //
     // cancel
     //
     resources.ApplyResources(this.cancel, "cancel");
     this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.cancel.Name = "cancel";
     this.cancel.Click += new System.EventHandler(this.CancelClick);
     //
     // ok
     //
     resources.ApplyResources(this.ok, "ok");
     this.ok.Name = "ok";
     this.ok.Click += new System.EventHandler(this.OkClick);
     //
     // apply
     //
     resources.ApplyResources(this.apply, "apply");
     this.apply.Name = "apply";
     this.apply.Click += new System.EventHandler(this.ApplyClick);
     //
     // properties
     //
     resources.ApplyResources(this.properties, "properties");
     this.properties.HotTrack = true;
     this.properties.Name = "properties";
     this.properties.SelectedIndex = 0;
     //
     // PropertyDialog
     //
     this.AcceptButton = this.ok;
     this.CancelButton = this.cancel;
     resources.ApplyResources(this, "$this");
     this.Controls.Add(this.properties);
     this.Controls.Add(this.apply);
     this.Controls.Add(this.ok);
     this.Controls.Add(this.cancel);
     this.Controls.Add(this.help);
     this.Name = "PropertyDialog";
     this.ResumeLayout(false);
 }
 public void Initialize(PropertyControl propertyControl)
 {
     this.tabControl = propertyControl;
     StringProperty property = this.tabControl.LocalSettings.GlobalSettings.GetProperty("MergeSettingsFiles") as StringProperty;
     string strA = (property == null) ? "Parent" : property.Value;
     if (!this.tabControl.Core.Environment.SupportsLinkedSettings && (string.CompareOrdinal(strA, "Linked") == 0))
     {
         strA = "Parent";
         this.disableLinking = true;
     }
     if (string.CompareOrdinal(strA, "NoMerge") == 0)
     {
         this.noMerge.Checked = true;
     }
     else if (string.CompareOrdinal(strA, "Linked") == 0)
     {
         this.mergeWithLinkedFile.Checked = true;
         StringProperty property2 = this.tabControl.LocalSettings.GlobalSettings.GetProperty("LinkedSettingsFile") as StringProperty;
         if ((property2 != null) && !string.IsNullOrEmpty(property2.Value))
         {
             string relativePath = Environment.ExpandEnvironmentVariables(property2.Value);
             if (relativePath.StartsWith(".", StringComparison.Ordinal))
             {
                 relativePath = StyleCopCore.MakeAbsolutePath(this.tabControl.LocalSettings.Location, relativePath);
             }
             this.linkedFilePath.Text = relativePath;
         }
     }
     else
     {
         this.mergeWithParents.Checked = true;
     }
     this.EnableDisable();
     bool defaultSettings = this.tabControl.LocalSettings.DefaultSettings;
     this.mergeWithParents.Enabled = !defaultSettings;
     this.editParentSettingsFile.Enabled = !defaultSettings;
     this.mergeWithLinkedFile.Enabled = !defaultSettings;
     this.locationLabel.Enabled = !defaultSettings;
     this.linkedFilePath.Enabled = !defaultSettings;
     this.browse.Enabled = !defaultSettings;
     this.editLinkedSettingsFile.Enabled = !defaultSettings;
     if (!this.noMerge.Checked && defaultSettings)
     {
         this.noMerge.Checked = true;
     }
     this.dirty = false;
     this.tabControl.DirtyChanged();
 }
Ejemplo n.º 4
0
 public void Initialize(PropertyControl propertyControl)
 {
     this.tabControl = propertyControl;
     this.FillAnalyzerTree();
     if (this.analyzeTree.Nodes.Count > 0)
     {
         this.analyzeTree.SelectedNode = this.analyzeTree.Nodes[0];
     }
     this.dirty = false;
     this.tabControl.DirtyChanged();
 }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            // Get the merge style setting.
            StringProperty mergeTypeProperty = this.tabControl.LocalSettings.GlobalSettings.GetProperty(SettingsMerger.MergeSettingsFilesProperty) as StringProperty;
            string mergeType = mergeTypeProperty == null ? SettingsMerger.MergeStyleParent : mergeTypeProperty.Value;

            // If the merge style is set to link but the current environment doesn't support linking, change it to parent.
            if (!this.tabControl.Core.Environment.SupportsLinkedSettings && string.CompareOrdinal(mergeType, SettingsMerger.MergeStyleLinked) == 0)
            {
                mergeType = SettingsMerger.MergeStyleParent;
                this.disableLinking = true;
            }

            if (string.CompareOrdinal(mergeType, SettingsMerger.MergeStyleNone) == 0)
            {
                this.noMerge.Checked = true;
            }
            else if (string.CompareOrdinal(mergeType, SettingsMerger.MergeStyleLinked) == 0)
            {
                this.mergeWithLinkedFile.Checked = true;

                StringProperty linkedSettingsFileProperty = this.tabControl.LocalSettings.GlobalSettings.GetProperty(SettingsMerger.LinkedSettingsProperty) as StringProperty;
                if (linkedSettingsFileProperty != null && !string.IsNullOrEmpty(linkedSettingsFileProperty.Value))
                {
                    // This mode assumes that StyleCop is running in a file-based environment.
                    string linkedSettingsFile = Environment.ExpandEnvironmentVariables(linkedSettingsFileProperty.Value);

                    if (linkedSettingsFile.StartsWith(".", StringComparison.Ordinal))
                    {
                        linkedSettingsFile = StyleCopCore.MakeAbsolutePath(this.tabControl.LocalSettings.Location, linkedSettingsFile);
                    }

                    this.linkedFilePath.Text = linkedSettingsFile;
                }
            }
            else
            {
                this.mergeWithParents.Checked = true;
            }

            this.EnableDisable();

            bool defaultSettings = this.tabControl.LocalSettings.DefaultSettings;

            // Disable the parent link controls if this is the default settings file.
            this.mergeWithParents.Enabled = !defaultSettings;
            this.editParentSettingsFile.Enabled = !defaultSettings;
            this.mergeWithLinkedFile.Enabled = !defaultSettings;
            this.locationLabel.Enabled = !defaultSettings;
            this.linkedFilePath.Enabled = !defaultSettings;
            this.browse.Enabled = !defaultSettings;
            this.editLinkedSettingsFile.Enabled = !defaultSettings;

            if (!this.noMerge.Checked && defaultSettings)
            {
                this.noMerge.Checked = true;
            }

            // Reset the dirty flag to false now.
            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Ejemplo n.º 6
0
 private void InitializeComponent()
 {
     ComponentResourceManager manager = new ComponentResourceManager(typeof(PropertyDialog));
     this.help = new Button();
     this.cancel = new Button();
     this.ok = new Button();
     this.apply = new Button();
     this.properties = new PropertyControl();
     base.SuspendLayout();
     manager.ApplyResources(this.help, "help");
     this.help.Name = "help";
     this.help.Click += new EventHandler(this.HelpClick);
     manager.ApplyResources(this.cancel, "cancel");
     this.cancel.DialogResult = DialogResult.Cancel;
     this.cancel.Name = "cancel";
     this.cancel.Click += new EventHandler(this.CancelClick);
     manager.ApplyResources(this.ok, "ok");
     this.ok.Name = "ok";
     this.ok.Click += new EventHandler(this.OkClick);
     manager.ApplyResources(this.apply, "apply");
     this.apply.Name = "apply";
     this.apply.Click += new EventHandler(this.ApplyClick);
     manager.ApplyResources(this.properties, "properties");
     this.properties.HotTrack = true;
     this.properties.Name = "properties";
     this.properties.SelectedIndex = 0;
     base.AcceptButton = this.ok;
     base.CancelButton = this.cancel;
     manager.ApplyResources(this, "$this");
     base.Controls.Add(this.properties);
     base.Controls.Add(this.apply);
     base.Controls.Add(this.ok);
     base.Controls.Add(this.cancel);
     base.Controls.Add(this.help);
     base.Name = "PropertyDialog";
     base.ResumeLayout(false);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes the specified property control with the StyleCop settings file.
        /// </summary>
        public void Initialize(PropertyControl propertyControl)
        {
            m_tabControl = propertyControl;

            SettingsGrabber.Initialize(m_tabControl);
            namingRulesPage.Initialize();
            customRulesPage.Initialize();
        }
Ejemplo n.º 8
0
 public void Initialize(PropertyControl propertyControl)
 {
     Param.RequireNotNull(propertyControl, "propertyControl");
     this.tabControl = propertyControl;
     this.InitializeSettings();
     this.DetectBoldState();
     this.dirty = false;
     this.tabControl.DirtyChanged();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            // Get the cache setting.
            PropertyDescriptor<bool> descriptor = this.tabControl.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor<bool>;

            this.parentProperty = this.tabControl.ParentSettings == null ?
                null :
                this.tabControl.ParentSettings.GlobalSettings.GetProperty(descriptor.PropertyName) as BooleanProperty;

            BooleanProperty mergedProperty = this.tabControl.MergedSettings == null ?
                null :
                this.tabControl.MergedSettings.GlobalSettings.GetProperty(descriptor.PropertyName) as BooleanProperty;

            this.enableCache.Checked = mergedProperty == null ? descriptor.DefaultValue : mergedProperty.Value;

            this.SetBoldState();

            // Reset the dirty flag to false now.
            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "tabControl");

            this.tabControl = propertyControl;

            // Adds the parsers and analyzers to the tree.
            this.FillAnalyzerTree();

            // Select the first node in the tree.
            if (this.analyzeTree.Nodes.Count > 0)
            {
                this.analyzeTree.SelectedNode = this.analyzeTree.Nodes[0];
            }

            // Reset the dirty flag to false now.
            this.dirty = false;
            this.tabControl.DirtyChanged();
        }