Ejemplo n.º 1
0
        public void updateBrowsers()
        {
            SuspendLayout();
            browsers = BrowserFinder.find().Where(b => !Settings.Default.HideBrowsers.Contains(b.Identifier)).ToList();
            int i     = 0;
            int width = 0;

            for (int k = Controls.Count - 1; k >= 0; k--)
            {
                Control c = Controls[k];
                if (c is BrowserUC)
                {
                    Controls.RemoveAt(k);
                }
            }
            // add browserUC objects to the form
            foreach (var browser in browsers)
            {
                var buc = new BrowserUC(browser, i);
                width      = buc.Width; // buc.Width = 128*dpi Scale
                buc.Left   = width * i++;
                buc.Click += browser_click;
                this.Controls.Add(buc);
            }
            ResumeLayout();
            buc.Left      = i * width;
            btn_help.Left = i * width;
            btn_help.Top  = buc.Height - btn_help.Height;
            // this.Width = i * 128 + 20 + 20;
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <Browser> browsers = BrowserFinder.find(true);
            var            c        = ((DataGridViewComboBoxColumn)gv_filters.Columns["browser"]);

            c.Items.Clear();
            browser_filter.Items.Clear();
            foreach (Browser b in browsers)
            {
                browser_filter.Items.Add(b, !Settings.Default.HideBrowsers.Contains(b.exec));
                c.Items.Add(b.ToString());
            }
            // add browser select to the list
            c.Items.Add("display BrowserSelect");
        }
Ejemplo n.º 3
0
        private void btn_refresh_Click(object sender, EventArgs e)
        {
            browsers = BrowserFinder.find(true);
            var c = (DataGridViewComboBoxColumn)gv_filters.Columns["browser"];

            c.Items.Clear();
            foreach (Browser b in browsers)
            {
                c.Items.Add(b.ToString());
            }
            // add browser select to the list
            c.Items.Add("display BrowserSelect");

            PopulateBrowserList();

            mainForm.updateBrowsers();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void frm_settings_Load(object sender, EventArgs e)
        {
            //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 default_browser = key?.GetValue("ProgId");

                //disable the set default if already default
                if (default_browser != null && (string)default_browser == "bselectURL")
                {
                    btn_setdefault.Enabled = false;
                }
            }

            //populate list of browsers for Rule List ComboBox
            var browsers = BrowserFinder.find();
            var c        = ((DataGridViewComboBoxColumn)gv_filters.Columns["browser"]);

            foreach (Browser b in browsers)
            {
                browser_filter.Items.Add(b, !Settings.Default.HideBrowsers.Contains(b.Identifier));
                c.Items.Add(b.ToString());
            }
            // add browser select to the list
            c.Items.Add("display BrowserSelect");

            //populate Rules in the gridview
            foreach (var rule in Settings.Default.AutoBrowser)
            {
                rules.Add(rule);
            }
            var bs = new BindingSource();

            bs.DataSource         = rules;
            gv_filters.DataSource = bs;

            chk_check_update.Checked = Settings.Default.check_update != "nope";

            cmbo_expand_url.DataSource   = (new string[] { "Never", "First Redirect", "All Redirects" });
            cmbo_expand_url.SelectedItem = Settings.Default.expand_url;
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (var b in browserListData)
            {
                var browser = browsers.Find(o => o.Identifier == b.Id);
                if (browser != null)
                {
                    browser.Order = b.Order;
                }

                if (b.IsEnabled && Settings.Default.HideBrowsers.Contains(b.Id))
                {
                    Settings.Default.HideBrowsers.Remove(b.Id);
                }
                else if (!b.IsEnabled && !Settings.Default.HideBrowsers.Contains(b.Id))
                {
                    Settings.Default.HideBrowsers.Add(b.Id);
                }
            }
            BrowserFinder.Save(browsers);
            mainForm.updateBrowsers();
        }
Ejemplo n.º 8
0
        private void btn_refresh_Click(object sender, EventArgs e)
        {
            List <Browser> browsers = BrowserFinder.find(true);
            var            c        = ((DataGridViewComboBoxColumn)gv_filters.Columns["browser"]);

            c.Items.Clear();
            browser_filter.Items.Clear();
            foreach (Browser b in browsers)
            {
                browser_filter.Items.Add(b, !Settings.Default.HideBrowsers.Contains(b.Identifier));
                c.Items.Add(b.ToString());
            }
            // add browser select to the list
            c.Items.Add("display BrowserSelect");

            if (mainForm != null)
            {
                this.mainForm.updateBrowsers();
            }
            else
            {
                browsers = BrowserFinder.find().Where(b => !Settings.Default.HideBrowsers.Contains(b.Identifier)).ToList();
            }
        }
Ejemplo n.º 9
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;
            }));
        }
Ejemplo n.º 10
0
 private void Init()
 {
     browsers = BrowserFinder.find();
     dgvBrowsers.AutoGenerateColumns = false;
     PopulateBrowserList();
 }