Ejemplo n.º 1
0
        private void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e)
        {
            if ((webView == null) || !webView.IsLive)
            {
                return;
            }

            if (e.IsPopup)
            {
                // Create a WebView wrapping the view created by Awesomium.
                WebView view = new WebView(e.NewViewInstance);
                // ShowCreatedWebViewEventArgs.InitialPos indicates screen coordinates.
                Rectangle screenRect = e.Specs.InitialPosition.ToRectangle();
                // Create a new WebForm to render the new view and size it.
                WebForm childForm = new WebForm(view, screenRect.Width, screenRect.Height)
                {
                    ShowInTaskbar   = false,
                    FormBorderStyle = FormBorderStyle.FixedToolWindow,
                    ClientSize      = screenRect.Size != Size.Empty ? screenRect.Size : new Size(640, 480)
                };

                // Show the form.
                childForm.Show(this);

                if (screenRect.Location != Point.Empty)
                {
                    // Move it to the specified coordinates.
                    childForm.DesktopLocation = screenRect.Location;
                }
            }
            else if (e.IsWindowOpen || e.IsPost)
            {
                // Create a WebView wrapping the view created by Awesomium.
                WebView view = new WebView(e.NewViewInstance);
                // Create a new WebForm to render the new view and size it.
                WebForm childForm = new WebForm(view, 640, 480);
                // Show the form.
                childForm.Show(this);
            }
            else
            {
                // Let the new view be destroyed. It is important to set Cancel to true
                // if you are not wrapping the new view, to avoid keeping it alive along
                // with a reference to its parent.
                e.Cancel = true;

                // Load the url to the existing view.
                webView.Source = e.TargetURL;
            }
        }
Ejemplo n.º 2
0
        private void webControlContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if ((webView == null) || !webView.IsLive)
            {
                return;
            }

            // We only process the menu item added by us. The WebControlContextMenu
            // will handle the predefined items.
            if ((string)e.ClickedItem.Tag != "open")
            {
                return;
            }

            WebForm webForm = new WebForm(webView.Source);

            webForm.Show(this);
        }
Ejemplo n.º 3
0
        private void OnShowNewView( object sender, ShowCreatedWebViewEventArgs e )
        {
            if ( !webView.IsLive )
                return;

            if ( e.IsPopup )
            {
                // Create a WebView wrapping the view created by Awesomium.
                WebView view = new WebView( e.NewViewInstance );
                // ShowCreatedWebViewEventArgs.InitialPos indicates screen coordinates.
                Rectangle screenRect = e.InitialPos.ToRectangle();
                // Create a new WebForm to render the new view and size it.
                WebForm childForm = new WebForm( view, screenRect.Width, screenRect.Height )
                {
                    ShowInTaskbar = false,
                    FormBorderStyle = FormBorderStyle.FixedToolWindow,
                    Size = screenRect.Size
                };

                // Show the form.
                childForm.Show( this );
                // Move it to the specified coordinates.
                childForm.DesktopLocation = screenRect.Location;
            }
            else
            {
                // Let the new view be destroyed. It is important to set Cancel to true
                // if you are not wrapping the new view, to avoid keeping it alive along
                // with a reference to its parent.
                e.Cancel = true;

                // Load the url to the existing view.
                webView.LoadURL( e.TargetURL );
            }
        }