Ejemplo n.º 1
0
        protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
        {
            for (var index = model.Count - 1; index >= 0; index--)
            {
                var nCmd = model.GetCommandIdAt(index);

                if (!ContextMenuHelper.IsEdition(nCmd) && !ContextMenuHelper.IsUserDefined(nCmd))
                {
                    model.Remove(nCmd);
                }
            }

            if (WinFormium.Runtime.IsDebuggingMode && (state.ContextMenuType & CefContextMenuTypeFlags.Editable) != CefContextMenuTypeFlags.Editable)
            {
                if (model.Count > 0)
                {
                    model.AddSeparator();
                }

                model.AddItem((int)((CefMenuId)ContextMenuHelper.MenuIdentifier.MENU_ID_SHOW_DEVTOOLS), Resources.Messages.ContextMenu_ShowDevTools);
                model.AddItem((int)((CefMenuId)ContextMenuHelper.MenuIdentifier.MENU_ID_HIDE_DEVTOOLS), Resources.Messages.ContextMenu_CloseDevTools);
            }

            var e = new BeforeContextMenuEventArgs(frame, state, model);



            _owner.InvokeIfRequired(() => _owner.OnBeforeContextMenu(e));
        }
Ejemplo n.º 2
0
        protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect)
        {
            if (frame.IsMain)
            {
                var region = _owner.WebView?.DraggableRegion;

                if (region != null)
                {
                    region.Dispose();
                    _owner.WebView.DraggableRegion = null;
                }

                //_owner.WebView.WebViewIsReady = false;
            }

            _owner.WebView.ProcessMessageBridge.OnBeforeBrowse(browser, frame);


            var e = new BeforeBrowseEventArgs(browser, frame, request, userGesture, isRedirect);


            _owner.InvokeIfRequired(() => _owner.OnBeforeBrowse(e));

            return(e.Cancelled);
        }
Ejemplo n.º 3
0
        protected override bool DoClose(CefBrowser browser)
        {
            var e = new FormiumCloseEventArgs();

            _owner.InvokeIfRequired(() => _owner.OnBeforeClose(e));


            if (!e.Canceled)
            {
                _owner.Close(true);
            }

            return(e.Canceled);
        }
Ejemplo n.º 4
0
        protected override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
        {
            var e = new DragEnterEventArgs(dragData, mask);

            _owner.InvokeIfRequired(() => _owner.OnDragEnter(e));

            return(e.Handled);
        }
Ejemplo n.º 5
0
        protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url)
        {
            var e = new AddressChangedEventArgs(frame, url);


            _owner.InvokeIfRequired(() => _owner.OnAddressChanged(e));
        }
Ejemplo n.º 6
0
        protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message)
        {
            switch (dialogType)
            {
            case CefJSDialogType.Alert:
                _owner.InvokeIfRequired(() =>
                {
                    MessageBox.Show(_owner.HostWindow, message_text, Resources.Messages.JSDialog_AlertDialog_Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    callback.Continue(true, null);
                });

                suppress_message = false;
                return(true);

            case CefJSDialogType.Confirm:
                _owner.InvokeIfRequired(() =>
                {
                    var retval = MessageBox.Show(_owner.HostWindow, message_text, Resources.Messages.JSDialog_AlertDialog_Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (retval == DialogResult.Yes)
                    {
                        callback.Continue(true, null);
                    }
                    else
                    {
                        callback.Continue(false, null);
                    }
                });


                suppress_message = false;
                return(true);
            }

            suppress_message = false;
            return(false);
        }
Ejemplo n.º 7
0
        protected override void OnLoadStart(CefBrowser browser, CefFrame frame, CefTransitionType transitionType)
        {
            var e = new LoadStartEventArgs(frame, transitionType);

            _owner.InvokeIfRequired(() => _owner.OnLoadStart(e));
        }
 protected override void OnCursorChange(CefBrowser browser, IntPtr cursorHandle, CefCursorType type, CefCursorInfo customCursorInfo)
 {
     _owner.InvokeIfRequired(() => _owner.HostWindowInternal.Cursor = new Cursor(cursorHandle));
 }
Ejemplo n.º 9
0
        protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
        {
            var e = new BeforeDownloadEventArgs(downloadItem, suggestedName, callback);

            _owner.InvokeIfRequired(() => _owner.OnBeforeDownload(e));
        }
Ejemplo n.º 10
0
        protected override void OnBeforeClose(CefBrowser browser)
        {
            _owner.WebView.ProcessMessageBridge.OnBeforeClose(browser);

            _owner.InvokeIfRequired(() => _owner?.HostWindowInternal?.Close());
        }