示例#1
0
        public void NavigateToAddressBar()
        {
            string url       = _toolbar.Url;
            bool   navigated = false;

            try
            {
                _webView2.Navigate(url);
                navigated = true;
            }
            catch (Exception)
            {
            }
            if (!navigated)
            {
                if (!url.Contains(' ') &&
                    url.Contains('.'))
                {
                    // If it contains a dot and no spaces, try tacking http:// on the front.
                    _webView2.Navigate("http://" + url);
                }
                else
                {
                    // Otherwise treat it as a web search. We aren't bothering to escape
                    // URL syntax characters such as & and #
                    _webView2.Navigate("https://bing.com/search?q=" + url);
                }
            }
        }
        private void _webView2Control_BrowserCreated(object sender, EventArgs e)
        {
            _settingsComponent = new SettingsComponent(_environment, _webView2Control);
            _fileComponent     = new FileComponent(this, _webView2Control);
            _processComponent  = new ProcessComponent(this, _webView2Control);
            _scriptComponent   = new ScriptComponent(this, _webView2Control);
            _controlComponent  = new ControlComponent(this, navigationToolBar, _webView2Control);
            _viewComponent     = new ViewComponent(this, _webView2Control);

            if (_onWebViewFirstInitialized != null)
            {
                _onWebViewFirstInitialized.Invoke();
                _onWebViewFirstInitialized = null;
            }

            if (!string.IsNullOrEmpty(_initialUrl))
            {
                _webView2Control.Navigate(_initialUrl);
            }

            if (_newWindowRequestedEventArgs != null)
            {
                _newWindowRequestedEventArgs.NewWindow = _webView2Control.InnerWebView2WebView;
                _newWindowRequestedEventArgs.Handled   = true;
                _newWindowDeferral.Complete();
                _newWindowRequestedEventArgs = null;
                _newWindowDeferral           = null;
            }
        }
示例#3
0
        public ScenarioAddRemoteObject(MainForm parent, WebView2Control webView2)
        {
            _parent   = parent;
            _webView2 = webView2;

            _sampleUri = FileUtil.GetLocalUri(_samplePath);

            _webView2.IsWebMessageEnabled = true;

            _webView2.NavigationStarting += _webView2_NavigationStarting;

            // Changes to IWebView2Settings::IsWebMessageEnabled apply to the next document
            // to which we navigate.
            _webView2.Navigate(_sampleUri);
        }
        public ScenarioWebMessage(MainWindow parent, WebView2Control webView2)
        {
            _parent   = parent;
            _webView2 = webView2;

            _sampleUri = FileUtil.GetLocalUri(_samplePath);

            _webView2.IsWebMessageEnabled = true;

            _webView2.WebMessageRecieved += WebView2WebMessageRecieved;

            // Changes to IWebView2Settings::IsWebMessageEnabled apply to the next document
            // to which we navigate.
            _webView2.Navigate(_sampleUri);
        }
示例#5
0
        private void CreateBrowserOptionsWebView()
        {
            _optionsWebView                     = new WebView2Control(_controlEnvironment);
            _optionsWebView.Visible             = false;
            _optionsWebView.AreDevToolsEnabled  = false;
            _optionsWebView.ZoomFactorChanged  += _optionsWebView_ZoomFactorChanged;
            _optionsWebView.WebMessageRecieved += _optionsWebView_WebMessageRecieved;
            _optionsWebView.LostFocus          += _optionsWebView_LostFocus;
            _optionsWebView.BrowserCreated     += (s, e) => {
                ResizeUIWebViews();
            };

            Controls.Add(_optionsWebView);

            string optionsPath = GetFullPathFor("Content\\controls_ui\\options.html");

            _optionsWebView.Navigate(optionsPath);
        }
示例#6
0
 public void CrashBrowserProcess()
 {
     // Crash the browser's process on command, to test crash handlers.
     _webView2.Navigate("edge://inducebrowsercrashforrealz");
 }
        public void NavigateToAddressBar()
        {
            string url = _toolbar.Url;

            _webView2.Navigate(url);
        }