Beispiel #1
0
        public BrowserUC(Browser b,int index)
        {
            InitializeComponent();

            this.browser = b;

            name.Text = b.name;
            shortcuts.Text = "( " + Convert.ToString(index+1) + "," + String.Join(",", b.shortcuts) + " )";
            shortcuts.ForeColor = Color.FromKnownColor(KnownColor.GrayText);
            icon.Image = b.icon.ToBitmap();
            icon.SizeMode = PictureBoxSizeMode.Zoom;
        }
Beispiel #2
0
        public static void open_url(Browser b, bool incognito = false)
        {
            var args = new List<String>();
            if (incognito)
                args.Add(b.private_arg);
            args.Add(Program.url.Replace("\"", "%22"));

            if (b.exec == "edge")
            {
                //edge is a universal app , which means we can't just run it like other browsers
                Process.Start("microsoft-edge:" + Program.url
                    .Replace(" ", "%20")
                    .Replace("\"", "%22"));
            }
            else if (b.exec.EndsWith("iexplore.exe") && !incognito)
            {
                // IE tends to open in a new window instead of a new tab
                // code borrowed from http://stackoverflow.com/a/3713470/1461004
                bool found = false;
                ShellWindows iExplorerInstances = new ShellWindows();
                foreach (InternetExplorer iExplorer in iExplorerInstances)
                {
                    if (iExplorer.Name.EndsWith("Internet Explorer"))
                    {
                        iExplorer.Navigate(Program.url, 0x800);
                        // for issue #10 (bring IE to focus after opening link)
                        ForegroundAgent.RestoreWindow(iExplorer.HWND);
                        found = true;
                        break;
                    }
                }
                if (!found)
                    Process.Start(b.exec, Program.Args2Str(args));
            }
            else
                Process.Start(b.exec, Program.Args2Str(args));

            Application.Exit();
        }
Beispiel #3
0
 private void save_rule(string pattern, Browser b)
 {
     // save a rule and save app settings
     Settings.Default.AutoBrowser.Add((new AutoMatchRule()
     {
         Pattern = pattern,
         Browser = b.name
     }).ToString());
     Settings.Default.Save();
 }
Beispiel #4
0
 public void add_rule(Browser b, string pattern)
 {
     save_rule(pattern, b);
     open_url(b);
 }
Beispiel #5
0
 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);
     }
 }
Beispiel #6
0
 private void open_url(Browser b)
 {
     if (b.exec == "edge"){
         //edge is a universal app , which means we can't just run it like other browsers
         Process.Start("microsoft-edge:"+Program.url
             .Replace(" ","%20")
             .Replace("\"", "%22"));
     }
     else
         Process.Start(b.exec, "\""+Program.url.Replace("\"","%22")+"\"");
     Application.Exit();
 }