示例#1
0
        public void RestoreFromRule(Rule r)
        {
            NameTextbox.Text = r.Name;

            ReplaceTextbox.Text = r.replace_.Replace("\n", "\r\n");

            WithTextbox.Text = r.with_.Replace("\n", "\r\n");

            RuleTypeCombobox.SelectedIndex = (int)r.ruletype_;
            RuleEnabledCheckBox.Checked = r.enabled_;

            ReplaceIsRegexCheckbox.Checked = r.regex_;
            ReplaceIsCaseSensitiveCheckBox.Checked = (r.regexOptions_ & RegexOptions.IgnoreCase) == 0;
            ReplaceIsMultilineCheckBox.Checked = (r.regexOptions_ & RegexOptions.Multiline) > 0;
            ReplaceIsSinglelineCheckbox.Checked = (r.regexOptions_ & RegexOptions.Singleline) > 0;

            NumberOfTimesUpDown.Value = r.numoftimes_;

            IfContainsTextBox.Text = r.ifContains_;
            IfNotContainsTextBox.Text = r.ifNotContains_;

            IfIsRegexCheckBox.Checked = r.ifIsRegex_;
            IfIsCaseSensitiveCheckBox.Checked = (r.ifRegexOptions_ & RegexOptions.IgnoreCase) == 0;
            IfIsMultilineCheckbox.Checked = (r.ifRegexOptions_ & RegexOptions.Multiline) > 0;
            IfIsSinglelineCheckBox.Checked = (r.ifRegexOptions_ & RegexOptions.Singleline) > 0;

            UpdateRegexOptionCheckboxes();
        }
示例#2
0
        public void SaveToRule(Rule r)
        {
            if (r == null)
                return;

            r.Name = NameTextbox.Text.Trim();
            r.replace_ = ReplaceTextbox.Text.Replace("\r\n", "\n");
            r.with_ = WithTextbox.Text.Replace("\r\n", "\n");
            r.ruletype_ = (Rule.T)RuleTypeCombobox.SelectedIndex;
            r.enabled_ = RuleEnabledCheckBox.Checked;

            r.regex_ = ReplaceIsRegexCheckbox.Checked;
            r.regexOptions_ = RegexOptions.None;
            if (!ReplaceIsCaseSensitiveCheckBox.Checked)
                r.regexOptions_ |= RegexOptions.IgnoreCase;
            if (ReplaceIsSinglelineCheckbox.Checked)
                r.regexOptions_ |= RegexOptions.Singleline;
            if (ReplaceIsMultilineCheckBox.Checked)
                r.regexOptions_ |= RegexOptions.Multiline;

            r.numoftimes_ = (int)NumberOfTimesUpDown.Value;

            r.ifContains_ = IfContainsTextBox.Text;
            r.ifNotContains_ = IfNotContainsTextBox.Text;

            r.ifIsRegex_ = IfIsRegexCheckBox.Checked;
            r.ifRegexOptions_ = RegexOptions.None;
            if (!IfIsCaseSensitiveCheckBox.Checked)
                r.ifRegexOptions_ |= RegexOptions.IgnoreCase;
            if (IfIsSinglelineCheckBox.Checked)
                r.ifRegexOptions_ |= RegexOptions.Singleline;
            if (IfIsMultilineCheckbox.Checked)
                r.ifRegexOptions_ |= RegexOptions.Multiline;
        }