-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragDropHandler.cs
More file actions
63 lines (55 loc) · 2.1 KB
/
Copy pathDragDropHandler.cs
File metadata and controls
63 lines (55 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using CefSharp;
using CefSharp.Enums;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace Optimade
{
public class DragDropHandler : IDragHandler
{
public Region draggableRegion = new Region();
public event Action<Region> RegionsChanged;
public bool OnDragEnter(IWebBrowser browserControl, IBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return false;
}
public void OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IList<DraggableRegion> regions)
{
if (browser.IsPopup == false)
{
draggableRegion = null;
if (regions.Count > 0)
{
foreach (var region in regions)
{
// Console.WriteLine(region.X + " - " + region.Y + " - " + region.Width + " - " + region.Height);
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);
}
}
}
}
RegionsChanged?.Invoke(draggableRegion);
}
}
public void Dispose()
{
RegionsChanged = null;
}
}
}