/// <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> /// 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(); }