Esempio n. 1
0
        //-------------------------------------------------------------------------------------------------------------
        public void RefreshBrowserListUI()
        //-------------------------------------------------------------------------------------------------------------
        {
            SuspendLayout();

            BrowserFinder finder = new BrowserFinder();

            browsers = finder.FindBrowsers().Where(b => !Settings.Default.HiddenBrowsers.Contains(b.Identifier)).ToList();

            // remove existing browser buttons
            for (int i = Controls.Count - 1; i >= 0; i--)
            {
                Control control = Controls[i];
                if (control is BrowserButtonControl)
                {
                    Controls.RemoveAt(i);
                }
            }

            int index      = 0;
            int totalWidth = 0;

            // add a button for each enabled browser to the form
            foreach (var browser in browsers)
            {
                var control = new BrowserButtonControl(browser, index);
                control.Left   = control.Width * index++;
                totalWidth    += control.Width;
                control.Click += BrowserButton_Click;
                Controls.Add(control);
                tooltipUrl.SetToolTip(control, BrowserSelectApp.url);
            }

            ResumeLayout();

            // position Settings button at right edge of form
            Control settingsControl = this.Controls["SettingsButtonControl"];

            if (settingsControl != null)
            {
                settingsControl.Left = totalWidth;
            }

            CenterWindow();
        }
Esempio n. 2
0
        //-------------------------------------------------------------------------------------------------------------
        private void RefreshButton_Click(object sender, EventArgs e)
        //-------------------------------------------------------------------------------------------------------------
        {
            var mbox = MessageBox.Show("Refreshing the browser list will remove any custom ordering set on the list.  Are you sure?",
                                       "Refresh Browser List",
                                       MessageBoxButtons.YesNo);

            if (mbox == DialogResult.No)
            {
                return;
            }

            //populate list of browsers for RulesGrid, BrowserList, and DefaultBrowserList
            BrowserFinder finder = new BrowserFinder();

            browsers = finder.FindBrowsers(true);

            var browserColumn = ((DataGridViewComboBoxColumn)RulesGrid.Columns["browser"]);

            browserColumn.Items.Clear();
            BrowserList.Items.Clear();
            DefaultBrowserList.Items.Clear();
            DefaultBrowserList.Items.Add("<choose with BrowserSelect>");

            foreach (BrowserModel browser in browsers)
            {
                BrowserList.Items.Add(browser, !Settings.Default.HiddenBrowsers.Contains(browser.Identifier));
                DefaultBrowserList.Items.Add(browser.ToString());
                browserColumn.Items.Add(browser.ToString());
            }

            if (String.IsNullOrEmpty(Settings.Default.DefaultBrowser))
            {
                DefaultBrowserList.SelectedIndex = 0;
            }
            else
            {
                DefaultBrowserList.SelectedItem = Settings.Default.DefaultBrowser;
            }
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------------------------------------------
        private void SettingsView_Load(object sender, EventArgs e)
        //-------------------------------------------------------------------------------------------------------------
        {
            MinimizeBox = false;

            //check if browser select is the default browser or not
            //to disable/enable "set Browser select as default" button
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(
                       @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"))
            {
                var defaultBrowser = key?.GetValue("ProgId");

                //disable the set default if already default
                if (defaultBrowser != null && (string)defaultBrowser == "BrowserSelectURL")
                {
                    SetDefaultButton.Enabled = false;
                }
            }

            var typeColumn = ((DataGridViewComboBoxColumn)RulesGrid.Columns["type"]);

            typeColumn.Items.Add("URL");
            typeColumn.Items.Add("Process");

            //populate list of browsers for RulesGrid, BrowserList, and DefaultBrowserList
            BrowserFinder finder = new BrowserFinder();

            browsers = finder.FindBrowsers();

            var browserColumn = ((DataGridViewComboBoxColumn)RulesGrid.Columns["browser"]);

            DefaultBrowserList.Items.Add("<choose with BrowserSelect>");

            foreach (BrowserModel browser in browsers)
            {
                BrowserList.Items.Add(browser, !Settings.Default.HiddenBrowsers.Contains(browser.Identifier));
                DefaultBrowserList.Items.Add(browser.ToString());
                browserColumn.Items.Add(browser.ToString());
            }

            if (String.IsNullOrEmpty(Settings.Default.DefaultBrowser))
            {
                DefaultBrowserList.SelectedIndex = 0;
            }
            else
            {
                DefaultBrowserList.SelectedItem = Settings.Default.DefaultBrowser;
            }

            if (String.IsNullOrEmpty(Settings.Default.RedirectPolicy))
            {
                RedirectPolicy.SelectedIndex = 0;
            }
            else
            {
                RedirectPolicy.SelectedItem = Settings.Default.RedirectPolicy;
            }

            //populate rules list data source and bind it to its grid
            foreach (var rule in Settings.Default.Rules)
            {
                rules.Add(rule);
            }
            var bs = new BindingSource();

            bs.DataSource        = rules;
            RulesGrid.DataSource = bs;

            isDirty = false;
            UpdateUIState();

            CenterWindow();

            this.BeginInvoke(new Action(() =>
            {
                isLoaded = true;
            }));
        }