Beispiel #1
0
        void ISupportInitialize.EndInit()
        {
            if (!Initializing)
            {
                // Cannot complete WebView initialization that is not being initialized
                throw new InvalidOperationException(DesignerUI.E_WEBVIEW_NOT_INITIALIZING);
            }

            if (!DesignMode)
            {
                OSVersionHelper.ThrowIfBeforeWindows10April2018();
            }

            try
            {
                Initialize();
            }
            catch (TypeLoadException)
            {
                // Some types are exposed that the designer tries to reflect over, throwing TypeLoadException
                // We're okay to ignore this if we're not in design mode
                if (!DesignMode)
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        private void Initialize()
        {
            Verify.AreEqual(_initializationState, InitializationState.IsInitializing);

            // This is causing freezing
            if (!DesignMode)
            {
                OSVersionHelper.ThrowIfBeforeWindows10April2018();

                if (!WebViewControlInitialized)
                {
                    if (Process == null)
                    {
                        // Was not injected via ctor, create using defaults
                        var options = new Win32.UI.Controls.Interop.WinRT.WebViewControlProcessOptions()
                        {
                            PrivateNetworkClientServerCapability =
                                (Win32.UI.Controls.Interop.WinRT.WebViewControlProcessCapabilityState)(_delayedPrivateNetworkEnabled
                                    ? WebViewControlProcessCapabilityState.Enabled
                                    : WebViewControlProcessCapabilityState.Disabled),
                            EnterpriseId = _delayedEnterpriseId
                        };

                        Process = new WebViewControlProcess(options);
                    }
                    else
                    {
                        Verify.IsNotNull(Process);

                        _delayedPrivateNetworkEnabled = Process.IsPrivateNetworkClientServerCapabilityEnabled;
                        _delayedEnterpriseId          = Process.EnterpriseId;
                    }

                    Verify.IsNotNull(Process);

                    _webViewControl = Process.CreateWebViewControlHost(Handle, ClientRectangle);
                    SubscribeEvents();

                    // Set values. They could have been changed in the designer
                    IsScriptNotifyAllowed = _delayedIsScriptNotifyAllowed;
                    IsIndexedDBEnabled    = _delayedIsIndexDbEnabled;
                    IsJavaScriptEnabled   = _delayedIsJavaScriptEnabled;

                    // This will cause a navigation
                    Source = _delayedSource;
                }
                else
                {
                    // Already provided control
                    SubscribeEvents();
                }

                _webViewControl.IsVisible = true;
            }

            _initializationState = InitializationState.IsInitialized;
        }