Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <param name="targetDirectory"></param>
        /// <returns>true if need firefox, false if selected another browser</returns>
        private static bool SelectFirefoxOrInstalled(string[] args, string targetDirectory, out Browser browser)
        {
            browser = null;
            if (args.Contains("--firefox"))
            {
                return(true);
            }
            var browsers = PlatformBrowser
                           .GetInstalledBrowsers()
                           .Where(b => !b.Name.Contains("Explorer"))
                           .Where(b => !b.Name.Contains("Firefox"))
                           .DistinctBy(b => b.Name)
                           .ToArray();
            var browsersList = new List <string> {
                "Use Firefox (install if not present)"
            };

            browsersList.AddRange(browsers.Select(b => b.Name));

            var browserMode = ConsoleHelper.SelectOneFromArray($"Select run option. Selected excursion: {targetDirectory}", browsersList.ToArray());

            Console.Clear();
            if (browserMode == 0) // Use furefox
            {
                return(true);
            }
            else
            {
                browser = browsers[browserMode - 1];
                return(false);
            }
        }
Example #2
0
        private void Setup(string passedUri = "")
        {
#if TRACE
            Trace.WriteLine("Now let us begin!");
#endif
            Build_Browser_Name_Dict();
            Build_KeyMap_Dict();
            _defaultBrowser = PlatformBrowser.GetDefaultBrowser();
            _browsers       = new List <Browser>();
            _browserPaths   = new Dictionary <string, string>();
            foreach (var installedBrowser in PlatformBrowser.GetInstalledBrowsers())
            {
                this._browsers.Add(installedBrowser);
                // ReSharper disable once PossibleNullReferenceException
                foreach (var(browserName, altNames) in _browserNames.Where(browserName => _browserNames
                                                                           .GetValueOrDefault(browserName.Key)
                                                                           .Contains(installedBrowser.Name)))
                {
                    if (!_browserPaths.ContainsKey(browserName))
                    {
                        _browserPaths.Add(browserName, installedBrowser.ExecutablePath);
                    }
                    break;
                }
#if TRACE
                Trace.WriteLine($"Browser: {installedBrowser.Name}");
                Trace.WriteLine($"Executable: {installedBrowser.ExecutablePath}");
                Trace.WriteLine($"Icon path: {installedBrowser.IconPath}");
                Trace.WriteLine($"Icon index: {installedBrowser.IconIndex}");
                Trace.WriteLine("");
#endif
            }
            // for browser in PlatformBrowser.GetInstalledBrowsers();

            Brave_Detector();

#if TRACE
            // Trace.WriteLine(_browserPaths);

            foreach (var(name, names) in _browserNames)
            {
                Trace.WriteLine($"{name}: {string.Join(", ", names)}");
            }
            Trace.WriteLine("");

            foreach (var(name, path) in _browserPaths)
            {
                Trace.WriteLine($"{name}: {path}");
            }
            Trace.WriteLine("");
#endif

            DataContext = this;
            PassedUri   = passedUri != "" ? passedUri : "(URL not received)";

            InitializeComponent();
        }
Example #3
0
        static void Main(string[] args)
        {
            var browsers = PlatformBrowser.GetInstalledBrowsers();

            foreach (var browser in browsers)
            {
                Console.WriteLine($"Browser: {browser.Name}");
                Console.WriteLine($"Executable: {browser.ExecutablePath}");
                Console.WriteLine($"Version: {browser.Version.ProductVersion}");
                Console.WriteLine($"Icon path: {browser.IconPath}");
                Console.WriteLine($"Icon index: {browser.IconIndex}");
                Console.WriteLine();
            }

            try
            {
                var httpDefaultBrowser = PlatformBrowser.GetDefaultBrowser(browsers, Enums.eProtocolType.Http);
                Console.WriteLine($"HTTP default browser: {httpDefaultBrowser.Name}");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }

            try
            {
                var htmlDefaultBrowser = PlatformBrowser.GetDefaultBrowser(browsers, Enums.eFileType.html);
                Console.WriteLine($"HTML default browser: {htmlDefaultBrowser.Name}");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
            Console.ReadKey();
        }