public SettingsComponent(WebView2Environment webView2Environment, WebView2Control webView2, SettingsComponent settingsComponent) { _webView2Environment = webView2Environment; _webView2 = webView2; if (settingsComponent != null) { _webView2.IsScriptEnabled = settingsComponent._webView2.IsScriptEnabled; _webView2.IsWebMessageEnabled = settingsComponent._webView2.IsWebMessageEnabled; _webView2.AreDefaultScriptDialogsEnabled = settingsComponent._webView2.AreDefaultScriptDialogsEnabled; _webView2.IsStatusBarEnabled = settingsComponent._webView2.IsStatusBarEnabled; _webView2.AreDevToolsEnabled = settingsComponent._webView2.AreDevToolsEnabled; SetBlockImages(settingsComponent._blockImages); SetUserAgent(settingsComponent._overridingUserAgent); _deferScriptDialogs = settingsComponent._deferScriptDialogs; _isScriptEnabled = settingsComponent._isScriptEnabled; _blockedSitesSet = settingsComponent._blockedSitesSet; foreach (string site in settingsComponent._blockedSites) { _blockedSites.Add(site); } _overridingUserAgent = settingsComponent._overridingUserAgent; } _webView2.NavigationStarting += WebView2NavigationStarting; _webView2.FrameNavigationStarting += WebView2FrameNavigationStarting; _webView2.ScriptDialogOpening += WebView2ScriptDialogOpening; _webView2.PermissionRequested += WebView2PermissionRequested; }
public FileComponent(MainWindow parent, WebView2Control webView2) { _parent = parent; _webView2 = webView2; _webView2.DocumentTitleChanged += WebView2DocumentTitleChanged; }
public ProcessComponent(MainWindow parent, WebView2Control webView2) { _parent = parent; _webView2 = webView2; _webView2.ProcessFailed += WebView2ProcessFailed; }
private void CloseWebView() { if (_webView2Control != null) { _webView2Control.Close(); _webView2Control.EnvironmentCreated -= webView2Control1_EnvironmentCreated; _webView2Control.BrowserCreated -= _webView2Control_BrowserCreated; _webView2Control.ContainsFullScreenElementChanged -= _webView2Control_ContainsFullScreenElementChanged; _webView2Control.NewWindowRequested -= _webView2Control_NewWindowRequested; _environment.UnregisterNewVersionAvailable(_newVersionToken); _settingsComponent.CleanUp(); _settingsComponent = null; _fileComponent.CleanUp(); _fileComponent = null; _processComponent.CleanUp(); _processComponent = null; _scriptComponent.CleanUp(); _scriptComponent = null; _controlComponent.CleanUp(); _controlComponent = null; _viewComponent.CleanUp(); _viewComponent = null; tableLayoutPanel1.Controls.Remove(_webView2Control); _webView2Control.Dispose(); _webView2Control = null; } }
public override void CleanUp() { _webView2.WebMessageRecieved -= WebView2WebMessageRecieved; _webView2 = null; _parent = null; }
public ScriptComponent(MainWindow parent, WebView2Control webView2) { _parent = parent; _webView2 = webView2; _webView2.DevToolsProtocolEventReceived += WebView2DevToolsProtocolEventReceived; }
public override void CleanUp() { _webView2.WebMessageRecieved -= WebView2WebMessageRecieved; _webView2.DocumentStateChanged -= WebView2DocumentStateChanged; _webView2 = null; _parent = null; }
private void PopupForm_Load(object sender, EventArgs e) { // Start the webview2 creation _childWebView = new WebView2Control(_environment); _childWebView.BrowserCreated += _childWebView_BrowserCreated; _childWebView.DocumentTitleChanged += _childWebView_DocumentTitleChanged; _childWebView.Dock = DockStyle.Fill; Controls.Add(_childWebView); }
public override void CleanUp() { _webView2.NavigationStarting -= WebView2NavigationStarting; _webView2.DocumentStateChanged -= WebView2DocumentStateChanged; _webView2.NavigationCompleted -= WebView2NavigationCompleted; _webView2.MoveFocusRequested -= WebView2MoveFocusRequested; _webView2.AcceleratorKeyPressed -= WebView2AcceleratorKeyPressed; _webView2 = null; _toolbar = null; _parent = null; }
public ControlComponent(MainWindow parent, NavigationToolBar toolbar, WebView2Control webView2) { _parent = parent; _toolbar = toolbar; _webView2 = webView2; _webView2.NavigationStarting += WebView2NavigationStarting; _webView2.DocumentStateChanged += WebView2DocumentStateChanged; _webView2.NavigationCompleted += WebView2NavigationCompleted; _webView2.MoveFocusRequested += WebView2MoveFocusRequested; _webView2.AcceleratorKeyPressed += WebView2AcceleratorKeyPressed; }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Start the webview2 creation _childWebView = new WebView2Control(_environment); _childWebView.BrowserCreated += _childWebView_BrowserCreated; _childWebView.DocumentTitleChanged += _childWebView_DocumentTitleChanged; Grid.SetRow(_childWebView, 1); Grid.SetColumn(_childWebView, 1); Grid.SetZIndex(_childWebView, 100); gridLayout.Children.Add(_childWebView); }
private string WebViewPropertiesToJsonString(WebView2Control webView) { string documentTitle = webView.DocumentTitle;; string source = webView.Source; string result = ", \"webview\": {" + "\"documentTitle\": " + EncodeQuote(documentTitle) + ", " + "\"source\": " + EncodeQuote(source) + " " + "}"; return(result); }
public void CleanUp() { _webView2.NavigationStarting -= WebView2NavigationStarting; _webView2.NavigationCompleted -= WebView2NavigationCompleted; _webView2.SourceChanged -= WebView2SourceChanged; _webView2.HistoryChanged -= WebView2HistoryChanged; _webView2.MoveFocusRequested -= WebView2MoveFocusRequested; _webView2.AcceleratorKeyPressed -= WebView2AcceleratorKeyPressed; _webView2 = null; _toolbar = null; _parent = null; }
public ControlComponent(MainForm parent, NavigationToolBar toolbar, WebView2Control webView2) { _parent = parent; _toolbar = toolbar; _webView2 = webView2; _webView2.NavigationStarting += WebView2NavigationStarting; _webView2.SourceChanged += WebView2SourceChanged; _webView2.HistoryChanged += WebView2HistoryChanged; _webView2.NavigationCompleted += WebView2NavigationCompleted; _webView2.MoveFocusRequested += WebView2MoveFocusRequested; _webView2.AcceleratorKeyPressed += WebView2AcceleratorKeyPressed; }
private void InitializeEventView(WebView2Control webView) { _webviewEventView = webView; _eventSourceWebView2.NavigationStarting += WebView2NavigationStarting; _eventSourceWebView2.NavigationCompleted += WebView2NavigationCompleted; _eventSourceWebView2.DocumentTitleChanged += WebView2DocumentTitleChanged; _eventSourceWebView2.WebMessageRecieved += WebView2WebMessageRecieved; _eventSourceWebView2.NewWindowRequested += WebView2NewWindowRequested; _eventSourceWebView2.FrameNavigationStarting += WebView2FrameNavigationStarting; _webviewEventView.WebMessageRecieved += EventViewWebMessageRecieved; }
public ScenarioWebViewEventMonitor(MainForm parent, WebView2Control eventSourceWebView2) { _parent = parent; _eventSourceWebView2 = eventSourceWebView2; _sampleUri = FileUtil.GetLocalUri(_samplePath); _appWindowEventView = new MainForm(_sampleUri, () => { InitializeEventView(_appWindowEventView.WebView); }); _appWindowEventView.Show(); //InitializeEventView(); }
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); }
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); }
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); }
private void InitializeWebView() { CloseWebView(); _webView2Control = new WebView2Control(); _webView2Control.Dock = DockStyle.Fill; _webView2Control.Location = new Point(3, 38); _webView2Control.Name = "webView2Control1"; _webView2Control.Size = new Size(1050, 381); _webView2Control.TabIndex = 3; _webView2Control.EnvironmentCreated += webView2Control1_EnvironmentCreated; _webView2Control.BrowserCreated += _webView2Control_BrowserCreated; _webView2Control.ContainsFullScreenElementChanged += _webView2Control_ContainsFullScreenElementChanged; _webView2Control.NewWindowRequested += _webView2Control_NewWindowRequested; tableLayoutPanel1.SetColumnSpan(_webView2Control, 6); tableLayoutPanel1.Controls.Add(_webView2Control, 0, 1); }
public ViewComponent(MainForm parent, WebView2Control webView2) { _parent = parent; _webView2 = webView2; _webView2.ZoomFactorChanged += WebView2ZoomFactorChanged; }
private void CloseWebView(bool cleanupUserDataFolder) { if (_webView2Control != null) { _webView2Control.Close(); _webView2Control.EnvironmentCreated -= webView2Control1_EnvironmentCreated; _webView2Control.BrowserCreated -= _webView2Control_BrowserCreated; _webView2Control.ContainsFullScreenElementChanged -= _webView2Control_ContainsFullScreenElementChanged; _webView2Control.NewWindowRequested -= _webView2Control_NewWindowRequested; _environment.UnregisterNewVersionAvailable(_newVersionToken); _settingsComponent.CleanUp(); _settingsComponent = null; _fileComponent.CleanUp(); _fileComponent = null; _processComponent.CleanUp(); _processComponent = null; _scriptComponent.CleanUp(); _scriptComponent = null; _controlComponent.CleanUp(); _controlComponent = null; _viewComponent.CleanUp(); _viewComponent = null; tableLayoutPanel1.Controls.Remove(_webView2Control); _webView2Control.Dispose(); _webView2Control = null; } if (cleanupUserDataFolder) { // For non-UWP apps, the default user data folder {Executable File Name}.WebView2 // is in the same directory next to the app executable. If end // developers specify userDataFolder during WebView environment // creation, they would need to pass in that explicit value here. // For more information about userDataFolder: // https://docs.microsoft.com/microsoft-edge/hosting/webview2/reference/webview2.idl#createwebview2environmentwithdetails string userDataFolder = Environment.CurrentDirectory; // Obtain the absolute path for relative paths that include "./" or "../" userDataFolder = Path.Combine(userDataFolder, "MtrDev.WebView2.WinForms.Sample.exe.WebView2"); string userDataFolderPath = userDataFolder; string message = "Are you sure you want to clean up the user data folder at\n"; message += userDataFolderPath; message += "\n?\nWarning: This action is not reversible.\n\n"; message += "Click No if there are other open WebView instnaces.\n"; if (MessageBox.Show(this, message, "Cleanup User Data Folder", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Directory.Delete(userDataFolderPath, true); } catch (Exception) { } } } }
public override void CleanUp() { _webView2.DevToolsProtocolEventReceived -= WebView2DevToolsProtocolEventReceived; _webView2 = null; _parent = null; }
public override void CleanUp() { _webView2.ProcessFailed -= WebView2ProcessFailed; _webView2 = null; _parent = null; }
public SettingsComponent(WebView2Environment webView2Environment, WebView2Control webView2) : this(webView2Environment, webView2, null) { }
public override void CleanUp() { _webView2 = null; _parent = null; }
private void PostJsonToWebView(JObject jObjectj, WebView2Control webview) { string json = jObjectj.ToString(); webview.PostWebMessageAsJson(json); }
public override void CleanUp() { _webView2.DocumentTitleChanged -= WebView2DocumentTitleChanged; _webView2 = null; _parent = null; }
private void PostJsonToWebView(string json, WebView2Control webview) { webview.PostWebMessageAsJson(json); }
public void CleanUp() { _webView2.ZoomFactorChanged -= WebView2ZoomFactorChanged; _webView2 = null; _parent = null; }