Esempio n. 1
0
        public bool OnJSAlert(IWebBrowser browserControl, string url, string message)
        {
            var notShow = false;

            var chromiumWebBrowser = browserControl as ChromiumWebBrowser;

            if (chromiumWebBrowser != null)
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    try
                    {
                        var mainWindow = Application.Current.MainWindow;
                        if (mainWindow != null && mainWindow.DataContext is MainViewModel)
                        {
                            var mainViewModel    = (MainViewModel)mainWindow.DataContext;
                            var selectedTabIndex = -1;
                            for (var i = 0; i < mainViewModel.BrowserTabs.Count; i++)
                            {
                                var browser =
                                    ((BrowserTabUserControl)
                                     mainViewModel.BrowserTabs[i].BrowserTabView.BrowserHost.Child).Browser;
                                if (browserControl.Equals(browser))
                                {
                                    selectedTabIndex = i;
                                }
                            }

                            if (-1 != selectedTabIndex)
                            {
                                mainViewModel.SelectedTabIndex = selectedTabIndex;
                                notShow = false;
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        _loggor.Error(exception);
                        notShow = false;
                    }
                }));
            }

            return(notShow);
        }