示例#1
0
            protected override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
            {
                var filesDragging = OwnerWebView.FilesDragging;

                if (filesDragging != null)
                {
                    var fileNames = dragData.GetFileNames();
                    if (fileNames != null)
                    {
                        filesDragging(fileNames);
                    }
                }

                var textDragging = OwnerWebView.TextDragging;

                if (textDragging != null)
                {
                    var textContent = dragData.FragmentText;
                    if (!string.IsNullOrEmpty(textContent))
                    {
                        textDragging(textContent);
                    }
                }

                return(false);
            }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StartDraggingEventArgs"/> class.
 /// </summary>
 /// <param name="data">The data associated with this event.</param>
 /// <param name="allowedOps">Drag-and-drop operations which allowed by the source of the drag event.</param>
 /// <param name="x">The X-location in screen coordinates.</param>
 /// <param name="y">The Y-location in screen coordinates.</param>
 public StartDraggingEventArgs(CefDragData data, CefDragOperationsMask allowedOps, int x, int y)
 {
     this.Data           = data;
     this.AllowedEffects = allowedOps;
     this.X = x;
     this.Y = y;
 }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CefNetDragData"/> class.
        /// </summary>
        /// <param name="source">The source of the drag event.</param>
        /// <param name="data">The original drag data.</param>
        public CefNetDragData(WebView source, CefDragData data)
        {
            var formats = new HashSet <string>();

            formats.Add(DataFormatCefNetDragData);
            formats.Add(DataFormatCefDragData);
            if (data.IsFile)
            {
                formats.Add(DataFormats.FileDrop);
            }
            if (data.IsLink)
            {
                formats.Add(DataFormatUnicodeUrl);
                formats.Add(DataFormats.UnicodeText);
            }
            if (data.IsFragment)
            {
                formats.Add(DataFormats.UnicodeText);
                formats.Add(DataFormats.Html);
                formats.Add(DataFormatTextHtml);
            }

            _source   = new WeakReference <WebView>(source);
            _formats  = formats;
            this.Data = data;
        }
示例#4
0
        /// <summary>
        /// Called when the user starts dragging content in the web view. OS APIs that run a system message
        /// loop may be used within the StartDragging call. Don't call any of CefBrowserHost::DragSource*Ended*
        /// methods after returning false. Call CefBrowserHost::DragSourceEndedAt and DragSourceSystemDragEnded
        /// either synchronously or asynchronously to inform the web view that the drag operation has ended.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="dragData">The contextual information about the dragged content.</param>
        /// <param name="allowedOps"></param>
        /// <param name="x">The X-location in screen coordinates.</param>
        /// <param name="y">The Y-location in screen coordinates.</param>
        /// <returns>Return false to abort the drag operation or true to handle the drag operation.</returns>
        protected override bool StartDragging(CefBrowser browser, CefDragData dragData, CefDragOperationsMask allowedOps, int x, int y)
        {
            var e = new StartDraggingEventArgs(dragData, allowedOps, x, y);

            WebView.RaiseStartDragging(e);
            return(e.Handled);
        }
示例#5
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);
        }
示例#6
0
        public bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
        {
            var handler = this.DragEnter;

            if (handler != null)
            {
                handler(this.owner, new CefDragEventArgs(browser, dragData, mask));
            }

            return(false);
        }
        /// <summary>
        /// Call this function when the user drags the mouse into the web view.
        /// <para/>This function is only used when window rendering is disabled.
        /// </summary>
        /// <param name="dragData">
        /// The <paramref name="dragData"/> should not contain file contents as this type of data is not allowed to be
        /// dragged into the web view. File contents can be removed using <see cref="CefDragData.ResetFileContents"/>
        /// (for example, if <paramref name="dragData"/> comes from the <see cref="StartDragging"/> event).
        /// </param>
        public void SendDragEnterEvent(int x, int y, CefEventFlags modifiers, CefDragData dragData, CefDragOperationsMask allowedOps)
        {
            if (dragData is null)
            {
                throw new ArgumentNullException(nameof(dragData));
            }

            CefBrowserHost browserHost = this.BrowserObject?.Host;

            if (browserHost is null)
            {
                return;
            }

            InitMouseEvent(x, y, modifiers);
            browserHost.DragTargetDragEnter(dragData, _mouseEventProxy, allowedOps);
        }
示例#8
0
 protected internal unsafe override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
 {
     return(_implementation.OnDragEnter(browser, dragData, mask));
 }
示例#9
0
 internal protected virtual bool StartDragging(CefBrowser browser, CefDragData dragData, CefDragOperationsMask allowedOps, int x, int y)
 {
     return(false);
 }
示例#10
0
 protected internal unsafe override bool StartDragging(CefBrowser browser, CefDragData dragData, CefDragOperationsMask allowedOps, int x, int y)
 {
     return(_implementation.StartDragging(browser, dragData, allowedOps, x, y));
 }
 protected override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
 {
     //throw new NotImplementedException();
     return(true);
 }
 internal protected virtual bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
 {
     return(false);
 }
示例#13
0
        protected override Boolean OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
        {
            Log.Trace("DownloadHandler.OnDragEnter( browser: {0} )", browser.Identifier);

            return(false);
        }
示例#14
0
 protected override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
 {
     return(false);
 }
示例#15
0
 public CefDragEventArgs(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
 {
     this.browser  = browser;
     this.dragData = dragData;
     this.mask     = mask;
 }
 /// <summary>
 /// Call this method when the user drags the mouse into the web view (before
 /// calling DragTargetDragOver/DragTargetLeave/DragTargetDrop).
 /// |drag_data| should not contain file contents as this type of data is not
 /// allowed to be dragged into the web view. File contents can be removed using
 /// CefDragData::ResetFileContents (for example, if |drag_data| comes from
 /// CefRenderHandler::StartDragging).
 /// This method is only used when window rendering is disabled.
 /// </summary>
 public void DragTargetDragEnter(CefDragData dragData, CefMouseEvent mouseEvent, CefDragOperationsMask allowedOps)
 {
     BrowserHost?.DragTargetDragEnter(dragData, mouseEvent, allowedOps);
 }
示例#17
0
        public bool OnDragStart(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
        {
            var handler = this.DragStart;
            if (handler != null)
            {
                handler(this.owner, new CefDragEventArgs(browser, dragData, mask));
            }

            return false;
        }
示例#18
0
 internal DragEnterEventArgs(CefDragData dragData, CefDragOperationsMask mask)
 {
     DragData = dragData;
     Mask     = mask;
 }
示例#19
0
 protected override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
 {
     return(context.OnDragEnter(browser, dragData, mask));
 }
示例#20
0
 protected override bool OnDragStart(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
 {
     return context.OnDragStart(browser, dragData, mask);
 }
        /// <summary>
        /// Gets the drag data.
        /// </summary>
        /// <param name="e">The <see cref="DragEventArgs"/> instance containing the event data.</param>
        public static CefDragData GetCefDragData(this DragEventArgs e)
        {
            CefDragData dragData;

            if (e.Data.Contains(nameof(CefDragData)))
            {
                dragData = (CefDragData)e.Data.Get(nameof(CefDragData));
                if (dragData != null)
                {
                    dragData.ResetFileContents();
                    return(dragData);
                }
            }

            dragData = new CefDragData();

            string[] formats = e.Data.GetDataFormats().ToArray();

            if (TryGetFileDropData(e.Data, out IEnumerable <string> fileNames))
            {
                foreach (string filePath in fileNames)
                {
                    dragData.AddFile(filePath.Replace("\\", "/"), Path.GetFileName(filePath));
                }
            }


            bool   isUrl = false;
            string s     = GetUrlString(e.Data, formats);

            if (!string.IsNullOrWhiteSpace(s))
            {
                isUrl            = true;
                dragData.LinkUrl = s;
            }

            if (formats.Contains(CefNetDragData.DataFormatUnicodeText))
            {
                s = (string)e.Data.Get(CefNetDragData.DataFormatUnicodeText);

                if (!isUrl && Uri.IsWellFormedUriString(s, UriKind.Absolute))
                {
                    dragData.LinkUrl = s;
                }
                dragData.FragmentText = s;
            }
            else if (formats.Contains(DataFormats.Text))
            {
                s = (string)e.Data.Get(DataFormats.Text);

                if (!isUrl && Uri.IsWellFormedUriString(s, UriKind.Absolute))
                {
                    dragData.LinkUrl = s;
                }
                dragData.FragmentText = s;
            }

            if (formats.Contains(CefNetDragData.DataFormatHtml))
            {
                dragData.FragmentHtml = Encoding.UTF8.GetString((byte[])e.Data.Get(CefNetDragData.DataFormatHtml));
            }
            else if (formats.Contains(CefNetDragData.DataFormatTextHtml))
            {
                dragData.FragmentHtml = Encoding.UTF8.GetString((byte[])e.Data.Get(CefNetDragData.DataFormatTextHtml));
            }

            return(dragData);
        }
 /// <summary>
 /// Creates a new <see cref="DragEnterEventArgs"/> with Cancel set to false as default.
 /// </summary>
 /// <param name="dragData"></param>
 /// <param name="mask"></param>
 public DragEnterEventArgs(CefDragData dragData, CefDragOperationsMask mask)
     : base(false)
 {
     Data   = dragData;
     Effect = mask;
 }
 protected override bool StartDragging(CefBrowser browser, CefDragData dragData, CefDragOperationsMask allowedOps, int x, int y)
 {
     return(base.StartDragging(browser, dragData, allowedOps, x, y));
 }
示例#24
0
 public CefDragEventArgs(CefBrowser browser, CefDragData dragData, CefDragOperations mask)
 {
     this.browser = browser;
     this.dragData = dragData;
     this.mask = mask;
 }
示例#25
0
 public override bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask)
 {
     return(_implementation.OnDragEnter(browser, dragData, mask));
 }