Exemple #1
0
        /// <summary>
        /// Creates an evergreen WebView2 Environment using the installed Edge version.
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static int CreateEnvironment(Action <EnvironmentCreatedEventArgs> callback)
        {
            EnvironmentCompletedHandler handler = new EnvironmentCompletedHandler(callback);
            int hr = Globals.CreateCoreWebView2Environment(handler);

            if (hr != 0 && callback != null)
            {
                EnvironmentCreatedEventArgs args = new EnvironmentCreatedEventArgs(hr, null);
                callback.Invoke(args);
            }
            return(hr);
        }
Exemple #2
0
        /// <summary>
        /// Create a WebView2 environment with a custom version of Edge, user data directory and/or additional browser switches.
        /// </summary>
        /// <param name="browserExecutableFolder">relative path to the folder that contains the embedded Edge</param>
        /// <param name="userDataFolder">specified to change the default user data folder location for WebView2</param>
        /// <param name="additionalBrowserArguments">Specified to change the behavior of the WebView. These will be passed to the browser process as part of the command line.</param>
        /// <param name="callback">Callback when complete</param>
        /// <returns></returns>
        public static int CreateEnvironmentWithDetails(
            string browserExecutableFolder,
            string userDataFolder,
            string additionalBrowserArguments,
            Action <EnvironmentCreatedEventArgs> callback)
        {
            EnvironmentCompletedHandler handler = new EnvironmentCompletedHandler(callback);
            int hr = Globals.CreateCoreWebView2EnvironmentWithDetails(browserExecutableFolder,
                                                                      userDataFolder,
                                                                      additionalBrowserArguments,
                                                                      handler);

            if (hr != 0 && callback != null)
            {
                EnvironmentCreatedEventArgs args = new EnvironmentCreatedEventArgs(hr, null);
                callback.Invoke(args);
            }
            return(hr);
        }