/// <summary> /// Does action "Switch Enabled". /// </summary> private void Action_SwitchEnabled_Do() { if (!Action_SwitchEnabled_IsAvailable()) { return; } ListViewItem lvi = listRules.SelectedItems[0]; CustomRuleTag tag = (CustomRuleTag)lvi.Tag; bool enabled = SettingsGrabber.IsRuleEnabled(Page.Analyzer.Id, tag.Rule.RuleName); if (enabled) { SettingsGrabber.DisableRule(Page.Analyzer.Id, tag.Rule.RuleName); } else { SettingsGrabber.EnableRule(Page.Analyzer.Id, tag.Rule.RuleName); } UpdateListItem(lvi); Page.Dirty = true; UpdateControls(); }
/// <summary> /// Updates page warnings. /// </summary> public void UpdateWarnings() { warningArea.Clear(); if (!SettingsGrabber.IsRuleEnabled(Page.Analyzer.Id, Rules.AdvancedNamingRules.ToString())) { warningArea.Add(Resources.WarningDisabledAdvancedNamingRulesCode); } else if (SettingsGrabber.IsAnalyzerEnabled(Constants.NamingRulesAnalyzerId)) { warningArea.Add(Resources.WarningDontUseOriginalNamingRulesCode); } }
/// <summary> /// Does action "Reset". /// </summary> private void Action_Reset_Do() { if (!Action_Reset_IsAvailable()) { return; } ListViewItem lvi = listRules.SelectedItems[0]; CustomRuleTag tag = (CustomRuleTag)lvi.Tag; bool inheritedEnabled = SettingsGrabber.IsRuleEnabled(Page.Analyzer.Id, tag.Rule.RuleName); if (SettingsGrabber.IsRuleBold(Page.Analyzer.Id, tag.Rule.RuleName)) { inheritedEnabled = !inheritedEnabled; } string preview = GetOptionsText(inheritedEnabled, tag.OptionsControl, tag.InheritedValue); if (Messages.ShowWarningYesNo(this, Resources.ResetSettingQuestion, preview) != DialogResult.Yes) { return; } if (inheritedEnabled) { SettingsGrabber.EnableRule(Page.Analyzer.Id, tag.Rule.RuleName); } else { SettingsGrabber.DisableRule(Page.Analyzer.Id, tag.Rule.RuleName); } if (tag.SettingName != null) { tag.MergedValue = tag.InheritedValue; } UpdateListItem(lvi); Page.Dirty = true; UpdateControls(); }
/// <summary> /// Updates list item depending on specified properties. /// </summary> private void UpdateListItem(ListViewItem lvi) { CustomRuleTag tag = (CustomRuleTag)lvi.Tag; ListViewItem.ListViewSubItem sub = lvi.SubItems[1]; bool enabled = SettingsGrabber.IsRuleEnabled(Page.Analyzer.Id, tag.Rule.RuleName); sub.Text = GetOptionsText(enabled, tag.OptionsControl, tag.MergedValue); lvi.ImageKey = enabled ? Pictures.RuleEnabled : Pictures.RuleDisabled; if (SettingsGrabber.IsRuleBold(Page.Analyzer.Id, tag.Rule.RuleName)) { sub.Font = m_bold; } else { sub.Font = tag.Modified ? m_bold : m_regular; } }
/// <summary> /// Updates option panel. /// </summary> private void UpdateOptions() { if (listRules.SelectedItems.Count != 1) { checkEnabled.Enabled = false; checkEnabled.Checked = false; panelOptions.Controls.Clear(); return; } ListViewItem lvi = listRules.SelectedItems[0]; CustomRuleTag tag = (CustomRuleTag)lvi.Tag; bool enabled = SettingsGrabber.IsRuleEnabled(Page.Analyzer.Id, tag.Rule.RuleName); checkEnabled.Enabled = true; checkEnabled.Checked = enabled; panelOptions.Enabled = enabled; if (tag.OptionsControl == null) { panelOptions.Controls.Clear(); return; } if (panelOptions.Controls.Count > 0) { if (panelOptions.Controls[0] == tag.OptionsControl) { if (tag.OptionsControl.ParseOptions() == tag.MergedValue) { return; } } } panelOptions.Controls.Clear(); panelOptions.Controls.Add(tag.OptionsControl); tag.OptionsControl.DisplayOptions(tag.MergedValue); }