Initialize() public method

Initializes the activation context.
public Initialize ( ) : void
return void
        /// <summary>
        /// Initializes the specified host.
        /// </summary>
        /// <param name="host">The host.</param>
        public void Initialize(IWebKitBrowserHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            this.host = host;

            if (!host.InDesignMode)
            {
                // Control Events
                this.host.Load   += WebKitBrowser_Load;
                this.host.Resize += WebKitBrowser_Resize;

                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free.
                if (Interlocked.Increment(ref actCtxRefCount) == 1)
                {
                    FileInfo fi           = new FileInfo(Assembly.GetExecutingAssembly().Location);
                    string   manifestPath = Path.Combine(fi.DirectoryName, "WebKitBrowser.dll.manifest");
                    if (string.IsNullOrEmpty(manifestPath))
                    {
                        throw new ApplicationException("Failed to locate 'WebKitBrowser.dll.manifest' file.");
                    }

                    activationContext = new ActivationContext(manifestPath);
                    activationContext.Initialize();

                    // TODO: more error handling here

                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window.
                this.host.GotFocus += (s, e) => NativeMethods.SetFocus(webViewHWND);

                activationContext.Activate();
                webView = new WebViewClass();
                activationContext.Deactivate();
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the WebKitBrowser control.
        /// </summary>
        public WebKitBrowser()
        {
            InitializeComponent();

            PageSettings = new PageSettings();

            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                // Control Events
                this.Load   += new EventHandler(WebKitBrowser_Load);
                this.Resize += new EventHandler(WebKitBrowser_Resize);

                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free
                if ((actCtxRefCount++) == 0)
                {
                    FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    activationContext = new ActivationContext(Path.Combine(fi.DirectoryName, "WebKitBrowser.dll.manifest"));
                    activationContext.Initialize();

                    // TODO: more error handling here

                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window
                this.GotFocus += (s, e) =>
                {
                    NativeMethods.SetFocus(webViewHWND);
                };

                activationContext.Activate();
                webView = new WebViewClass();
                activationContext.Deactivate();
            }
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the WebKitBrowser control.
        /// </summary>
        public WebKitBrowser()
        {
            InitializeComponent();

            CheckForIllegalCrossThreadCalls = false; // this will prevent exceptions that occur when you use the favicon event 
            
            PageSettings = new PageSettings();
            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                LanguageLoader.Initialize();
                // Control Events
                this.Load += new EventHandler(WebKitBrowser_Load);
                this.Resize += new EventHandler(WebKitBrowser_Resize);
                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free
                if ((actCtxRefCount++) == 0)
                {
                    activationContext = new ActivationContext(GlobalPreferences.WebKitPath + "\\OpenWebKitSharp.manifest"); 
                    activationContext.Initialize();
                    // TODO: more error handling here
                    if (activationContext.Initialized != true)
                    {
                        return;
                    }
                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window
                this.GotFocus += (s, e) =>
                {
                    NativeMethods.SetFocus(webViewHWND);
                };
                activationContext.Activate();

                webView = new WebViewClass();

                contextmenumanager = new ContextMenuManager(this);
                Marshal.AddRef(Marshal.GetIUnknownForObject(contextmenumanager));
                
                activationContext.Deactivate();
            }
        }
示例#4
0
        /// <summary>
        /// Initializes the specified host.
        /// </summary>
        /// <param name="host">The host.</param>
        public void Initialize(IWebKitBrowserHost host)
        {
            if(host == null)
                throw new ArgumentNullException("host");

            this.host = host;

            if(!host.InDesignMode)
            {
                // Control Events            
                this.host.Load += new EventHandler(WebKitBrowser_Load);
                this.host.Resize += new EventHandler(WebKitBrowser_Resize);

                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free
                if((actCtxRefCount++) == 0)
                {
                    FileInfo fi = new FileInfo(Assembly.GetExecutingAssembly().Location);
                    activationContext = new ActivationContext(Path.Combine(fi.DirectoryName, "WebKitBrowser.dll.manifest"));
                    activationContext.Initialize();

                    // TODO: more error handling here

                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window
                this.host.GotFocus += (s, e) =>
                {
                    NativeMethods.SetFocus(webViewHWND);
                };

                activationContext.Activate();
                webView = new WebViewClass();
                activationContext.Deactivate();
            }
        }
        /// <summary>
        /// Initializes a new instance of the WebKitBrowser control.
        /// </summary>
        public WebKitBrowser()
        {
            InitializeComponent();

            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                // Control Events            
                this.Load += new EventHandler(WebKitBrowser_Load);
                this.Resize += new EventHandler(WebKitBrowser_Resize);

                // If this is the first time the library has been loaded,
                // initialize the activation context required to load the
                // WebKit COM component registration free
                if ((actCtxRefCount++) == 0)
                {
                    activationContext = new ActivationContext("WebKitBrowser.dll.manifest");
                    activationContext.Initialize();

                    // TODO: more error handling here

                    // Enable OLE for drag and drop functionality - WebKit
                    // will throw an OutOfMemory exception if we don't...
                    Application.OleRequired();
                }

                // If this control is brought to focus, focus our webkit child window
                this.GotFocus += (s, e) =>
                {
                    W32API.SetFocus(webViewHWND);
                };            

                activationContext.Activate();
                webView = new WebViewClass();
                activationContext.Deactivate();            
            }
        }