Files
cefsharp/CefSharp.Wpf.Example/Handlers/DragHandler.cs
T
amaitland 73a156fdc5 Initial version 75 upgrade and NetworkService changes
Compiles, that's about it at this point, there are major CEF breaking changes, and lots to be addressed.

Browser Process (main process)
- Removed IResourceHandlerFactory as it no longer fits with the structure that CEF provides
- New IResourceRequestHandler interface added, not plumbed in yet
- CefSettings - Add RootCachePath and ApplicationClientIdForFileScanning

BrowserSubprocess (render process)
- SendProcessMessage was moved from CefBrowser to CefFrame
- OnBrowserCreated added extraInfo param

The BrowserSubprocess changes for this upgrade should be complete
2019-06-25 19:24:57 +10:00

72 lines
2.5 KiB
C#

// Copyright © 2016 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.Drawing;
using CefSharp.Enums;
namespace CefSharp.Wpf.Example.Handlers
{
public class DragHandler : IDragHandler, IDisposable
{
public event Action<Region> RegionsChanged;
bool IDragHandler.OnDragEnter(IWebBrowser browserControl, IBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return false;
}
void IDragHandler.OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IList<DraggableRegion> regions)
{
//By default popup browers are native windows in WPF so we cannot handle their drag using this method
if (browser.IsPopup == false)
{
//NOTE: I haven't tested with dynamically adding removing regions so this may need some tweaking
Region draggableRegion = null;
if (regions.Count > 0)
{
//Take the individual Region and construct a complex Region that represents them all.
foreach (var region in regions)
{
var rect = new Rectangle(region.X, region.Y, region.Width, region.Height);
if (draggableRegion == null)
{
draggableRegion = new Region(rect);
}
else
{
if (region.Draggable)
{
draggableRegion.Union(rect);
}
else
{
//In the scenario where we have an outer region, that is draggable and it has
// an inner region that's not, we must exclude the non draggable.
// Not all scenarios are covered in this example.
draggableRegion.Exclude(rect);
}
}
}
}
var handler = RegionsChanged;
if (handler != null)
{
handler(draggableRegion);
}
}
}
public void Dispose()
{
RegionsChanged = null;
}
}
}