コード例 #1
0
        public virtual void ShowDevTools(CefPoint inspectElementAt)
        {
            var windowInfo = new CefWindowInfo();

            windowInfo.SetAsPopup(IntPtr.Zero, "DevTools");
            AliveBrowserHost.ShowDevTools(windowInfo, null, BrowserSettings, inspectElementAt);
            windowInfo.Dispose();
        }
コード例 #2
0
        private void InitMouseEvent(int x, int y, CefEventFlags modifiers)
        {
            CefPoint point = PointToViewport(new CefPoint(x, y));

            _mouseEventProxy.X         = point.X;
            _mouseEventProxy.Y         = point.Y;
            _mouseEventProxy.Modifiers = (uint)modifiers;
        }
コード例 #3
0
        internal protected virtual bool GetScreenPoint(CefBrowser browser, int viewX, int viewY, ref int screenX, ref int screenY)
        {
            var point = new CefPoint(viewX, viewY);

            if (WebView.CefPointToScreen(ref point))
            {
                screenX = point.X;
                screenY = point.Y;
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: WebView.Offscreen.cs プロジェクト: jingyiliu/CefNet
        protected virtual CefPoint PointToViewport(CefPoint point)
        {
            float         scale    = OffscreenGraphics.PixelsPerDip;
            VirtualDevice viewport = Device;

            if (viewport != null)
            {
                scale = scale * viewport.Scale;
            }
            CefRect viewportRect = GetViewportRect();

            return(new CefPoint((int)((point.X - viewportRect.X) / scale), (int)((point.Y - viewportRect.Y) / scale)));
        }
コード例 #5
0
ファイル: CustomCursor.cs プロジェクト: wuzlai/CefNet
        public unsafe static Cursor Create(ref CefCursorInfo cursorInfo)
        {
            CefSize size = cursorInfo.Size;

            if (size.Width > 0 && size.Height > 0 && cursorInfo.Buffer != IntPtr.Zero)
            {
                try
                {
                    var bufferSize       = size.Width * size.Height * 4;
                    int ICON_HEADER_SIZE = sizeof(ICONDIR);
                    var stream           = new MemoryStream();
                    {
                        DpiScale dpi    = OffscreenGraphics.DpiScale;
                        var      source = BitmapSource.Create(size.Width, size.Height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Bgra32, null, cursorInfo.Buffer, bufferSize, size.Width << 2);
                        if (stream.Seek(ICON_HEADER_SIZE, SeekOrigin.Begin) != ICON_HEADER_SIZE)
                        {
                            stream.Seek(0, SeekOrigin.Begin);
                            stream.Write(new byte[ICON_HEADER_SIZE], 0, ICON_HEADER_SIZE);
                        }

                        var png = new PngBitmapEncoder();
                        png.Frames.Add(BitmapFrame.Create(source));
                        png.Save(stream);
                        stream.Seek(0, SeekOrigin.Begin);
                    }

                    CefPoint hotSpot = cursorInfo.Hotspot;

                    var icon = new ICONDIR();
                    icon.IconType    = 2;
                    icon.ImagesCount = 1;
                    icon.Width       = (byte)size.Width;
                    icon.Height      = (byte)size.Height;
                    icon.HotSpotX    = (short)hotSpot.X;
                    icon.HotSpotY    = (short)hotSpot.Y;
                    icon.BytesInRes  = (int)stream.Length - ICON_HEADER_SIZE;
                    icon.ImageOffset = ICON_HEADER_SIZE;

                    using (var iconHead = new UnmanagedMemoryStream(icon._data, ICON_HEADER_SIZE))
                    {
                        iconHead.CopyTo(stream);
                        stream.Seek(0, SeekOrigin.Begin);
                    }

                    return(new Cursor(stream));
                }
                catch (AccessViolationException) { throw; }
                catch { }
            }
            return(Cursors.Arrow);
        }
コード例 #6
0
ファイル: WebView.Offscreen.cs プロジェクト: jingyiliu/CefNet
        protected virtual bool CefPointToScreen(ref CefPoint point)
        {
            VirtualDevice device = Device;

            if (device == null)
            {
                point.Scale(OffscreenGraphics.PixelsPerDip);
                NativeMethods.MapWindowPoints(OffscreenGraphics.WidgetHandle, IntPtr.Zero, ref point, 1);
                return(true);
            }
            else
            {
                return(device.PointToScreen(ref point));
            }
        }
コード例 #7
0
        public IDisposable GetDeveloperToolsControl(CefPoint element, CefWindowInfo info = null, CefBrowserSettings settings = null)
        {
            if (_browser != null)
            {
                var ctl = new DevToolsWebBrowser();

                ctl.Disposed += (sender, args) =>
                {
                    if (_browser != null)
                    {
                        _browser.GetHost().CloseDevTools();
                    }
                };

                ctl.CreateControl();

                if (info == null)
                {
                    info        = CefWindowInfo.Create();
                    info.Width  = (int)ActualWidth;
                    info.Height = (int)ActualHeight;
                }
                if (ctl.ParentHandle != IntPtr.Zero)
                {
                    info.SetAsChild(ctl.ParentHandle, new CefRectangle(0, 0, info.Width, info.Height));
                }

                if (settings == null)
                {
                    settings = new CefBrowserSettings();
                }

                if (element.X > int.MinValue && element.Y > int.MinValue)
                {
                    _browser.GetHost().ShowDevTools(info, ctl.Client, settings, element);
                }
                else
                {
                    var defaultCefPoint = new CefPoint(0, 0);
                    _browser.GetHost().ShowDevTools(info, ctl.Client, settings, defaultCefPoint);
                }

                return(ctl);
            }

            return(null);
        }
コード例 #8
0
ファイル: CustomCursor.cs プロジェクト: CefNet/CefNet
        public unsafe static Cursor Create(ref CefCursorInfo cursorInfo)
        {
            CefSize size = cursorInfo.Size;

            if (size.Width > 0 && size.Height > 0 && cursorInfo.Buffer != IntPtr.Zero)
            {
                try
                {
                    CefPoint hotSpot = cursorInfo.Hotspot;
                    using (var bitmap = new Bitmap(PixelFormat.Bgra8888, AlphaFormat.Premul, cursorInfo.Buffer,
                                                   new PixelSize(size.Width, size.Height), OffscreenGraphics.DpiScale.Dpi, size.Width * 4))
                    {
                        return(new Cursor(bitmap, new PixelPoint(hotSpot.X, hotSpot.Y)));
                    }
                }
                catch (AccessViolationException) { throw; }
                catch { }
            }
            return(Cursor.Default);
        }
コード例 #9
0
 /// <summary>
 /// Open developer tools (DevTools) in its own browser. The DevTools browser
 /// will remain associated with this browser. If the DevTools browser is
 /// already open then it will be focused, in which case the |windowInfo|,
 /// |client| and |settings| parameters will be ignored. If |inspect_element_at|
 /// is non-empty then the element at the specified (x,y) location will be
 /// inspected. The |windowInfo| parameter will be ignored if this browser is
 /// wrapped in a CefBrowserView.
 /// </summary>
 public void ShowDevTools(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings browserSettings, CefPoint inspectElementAt)
 {
     BrowserHost?.ShowDevTools(windowInfo, client, browserSettings, inspectElementAt);
 }
コード例 #10
0
 public override void MouseOutsideMenu(CefMenuModel menuModel, CefPoint screenPoint)
 {
     _implementation.MouseOutsideMenu(menuModel, screenPoint);
 }
コード例 #11
0
        /// <summary>
        /// Inform the web view that the drag operation started by a CefRenderHandler::StartDragging call
        /// has ended either in a drop or by being cancelled. If the web view is both the drag source and the
        /// drag target then all Drag* functions should be called before DragSource* methods.
        /// <para/>This function is only used when window rendering is disabled.
        /// </summary>
        /// <param name="x">The x-coordinate of the mouse pointer relative to the left edge of the view.</param>
        /// <param name="y">The y-coordinate of the mouse pointer relative to the upper edge of the view.</param>
        /// <param name="effects"></param>
        public void DragSourceEndedAt(int x, int y, CefDragOperationsMask effects)
        {
            CefPoint point = PointToViewport(new CefPoint(x, y));

            this.BrowserObject?.Host?.DragSourceEndedAt(point.X, point.Y, effects);
        }
コード例 #12
0
 public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref CefPoint pt, int cPoints);
コード例 #13
0
ファイル: WebView.Offscreen.cs プロジェクト: jingyiliu/CefNet
 bool IChromiumWebViewPrivate.CefPointToScreen(ref CefPoint point)
 {
     return(CefPointToScreen(ref point));
 }
コード例 #14
0
 protected internal unsafe override void MouseOutsideMenu(CefMenuModel menuModel, CefPoint screenPoint)
 {
     _implementation.MouseOutsideMenu(menuModel, screenPoint);
 }