Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------------------
        private void BrowserButton_Click(object sender, EventArgs e)
        //-------------------------------------------------------------------------------------------------------------
        {
            // callback for click event inside the browserControls
            BrowserButtonControl button;

            if (sender is BrowserButtonControl)
            {
                button = (BrowserButtonControl)sender;
            }
            else if (((Control)sender).Parent is BrowserButtonControl)
            {
                button = (BrowserButtonControl)((Control)sender).Parent;
            }
            else
            {
                throw new Exception("Invalid item was clicked!");
            }

            UrlProcessor processor = new UrlProcessor();

            // check if create rule button was clicked
            if (button.createRule)
            {
                ShowAddRuleMenu(button.browser);
            }
            else if ((ModifierKeys & Keys.Shift) != 0 || (ModifierKeys & Keys.Alt) != 0)    // open in incognito
            {
                processor.OpenUrl(button.browser, true);
            }
            else
            {
                processor.OpenUrl(button.browser);
            }
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------------------
        public void AddRule(string type, string pattern, BrowserModel browser)
        //-------------------------------------------------------------------------------------------------------------
        {
            SaveRule(type, pattern, browser);

            UrlProcessor processor = new UrlProcessor();

            processor.OpenUrl(browser);
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------------------------------------------
        private void BrowserSelectView_KeyPress(object sender, KeyPressEventArgs e)
        //-------------------------------------------------------------------------------------------------------------
        {
            int i = 1;

            foreach (var browser in browsers)
            {
                if (browser.shortcuts.Contains(e.KeyChar) || e.KeyChar == (Convert.ToString(i++))[0])
                {
                    UrlProcessor processor = new UrlProcessor();
                    processor.OpenUrl(browser);
                    return;
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        //-------------------------------------------------------------------------------------------------------------
        {
            BrowserSelectSetup.RegisterAsBrowser();
            ConfigureUriParser();

            // to prevent loss of settings when updating to new version
            if (Settings.Default.Version == 0)
            {
                Settings.Default.Upgrade();
                Settings.Default.Version = 2;
                // to prevent null reference in case settings file did not exist
                if (Settings.Default.HiddenBrowsers == null)
                {
                    Settings.Default.HiddenBrowsers = new StringCollection();
                }
                if (Settings.Default.Rules == null)
                {
                    Settings.Default.Rules = new StringCollection();
                }
                Settings.Default.Save();
            }

            //checking if a url is being opened or app is run from start menu (without arguments)
            if (args.Length > 0)
            {
                //check to see if auto select rules match
                url = args[0];
                //normalize the url
                Uri uri = new UriBuilder(url).Uri;
                url           = uri.AbsoluteUri;
                launchWithUrl = true;

                UrlProcessor processor = new UrlProcessor();
                if (processor.ProcessUrl(uri))
                {
                    return;
                }
            }

            // display main view
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new BrowserSelectView());
        }