BrowserSelect.Form1.add_rule C# (CSharp) Method

add_rule() public method

public add_rule ( Browser b ) : void
b Browser
return void
        public void add_rule(Browser b)
        {
            // check if desired pattern is ambiguous
            if (_alwaysRule.mode == 3)
            {
                // generate a context menu with tld_rule and second_rule as options
                // and call the overloaded add_rule with pattern as second arg on click
                _alwaysAsk = new ContextMenu((new[] { _alwaysRule.tld_rule, _alwaysRule.second_rule })
                    .Select(x => new MenuItem(x, (s, e) => add_rule(b, x))).ToArray());
                // display the context menu at mouse position
                _alwaysAsk.Show(this, PointToClient(Cursor.Position));
            }
            else if (_alwaysRule.mode == 0)
            {
                // in case ambiguousness of pattern was not determined, should not happen
                MessageBox.Show(String.Format("Error while generating pattern from url." +
                    " Please include the following url in your bug report:\n{0}",
                    Program.url));
            }
            else
            {
                // in case pattern was not ambiguous, just set the pattern as rule and open the url
                var pat = (_alwaysRule.mode == 1) ? _alwaysRule.tld_rule : _alwaysRule.second_rule;
                add_rule(b, pat);
            }
        }

Same methods

Form1::add_rule ( Browser b, string pattern ) : void