/// <summary> /// Default constructor /// </summary> public WindowsFormsWebAuthenticationDialog(object ownerWindow, EmbeddedWebViewOptions embeddedWebViewOptions) : base(ownerWindow) { Shown += FormShownHandler; _embeddedWebViewOptions = embeddedWebViewOptions ?? EmbeddedWebViewOptions.GetDefaultOptions(); if (string.IsNullOrEmpty(_embeddedWebViewOptions.Title)) { WebBrowser.DocumentTitleChanged += WebBrowserDocumentTitleChangedHandler; } else { Text = _embeddedWebViewOptions.Title; } WebBrowser.ObjectForScripting = this; }
public WinFormsPanelWithWebView2( object ownerWindow, EmbeddedWebViewOptions embeddedWebViewOptions, ICoreLogger logger, Uri startUri, Uri endUri) { _embeddedWebViewOptions = embeddedWebViewOptions ?? EmbeddedWebViewOptions.GetDefaultOptions(); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _startUri = startUri ?? throw new ArgumentNullException(nameof(startUri)); _endUri = endUri ?? throw new ArgumentNullException(nameof(endUri)); if (ownerWindow == null) { _ownerWindow = null; } else if (ownerWindow is IWin32Window) { _ownerWindow = (IWin32Window)ownerWindow; } else if (ownerWindow is IntPtr) { _ownerWindow = new Win32Window((IntPtr)ownerWindow); } else { throw new MsalException(MsalError.InvalidOwnerWindowType, "Invalid owner window type. Expected types are IWin32Window or IntPtr (for window handle)."); } InitializeComponent(); _webView2.CreationProperties = new CoreWebView2CreationProperties() { BrowserExecutableFolder = _embeddedWebViewOptions.WebView2BrowserExecutableFolder }; }
public WinFormsPanelWithWebView2( object ownerWindow, EmbeddedWebViewOptions embeddedWebViewOptions, ICoreLogger logger, Uri startUri, Uri endUri) { _embeddedWebViewOptions = embeddedWebViewOptions ?? EmbeddedWebViewOptions.GetDefaultOptions(); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _startUri = startUri ?? throw new ArgumentNullException(nameof(startUri)); _endUri = endUri ?? throw new ArgumentNullException(nameof(endUri)); if (ownerWindow == null) { _ownerWindow = null; } else if (ownerWindow is IWin32Window) { _ownerWindow = (IWin32Window)ownerWindow; } else if (ownerWindow is IntPtr ptr && ptr != IntPtr.Zero) { _ownerWindow = new Win32Window(ptr); }