mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
* feat: Add drag/drop functionality to the screenshot viewer * feat: Add arrow key controls for screenshot carousel
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using CefSharp.Enums;
|
|
using CefSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VRCX
|
|
{
|
|
/// <summary>
|
|
/// This class is used to 'handle' drag and drop events.
|
|
/// All it does is call a function in the app with the file name of the file being dragged into the window, since chromium doesn't have access to the full file path on regular drop events.
|
|
/// </summary>
|
|
public class CustomDragHandler : IDragHandler
|
|
{
|
|
public bool OnDragEnter(IWebBrowser chromiumWebBrowser, IBrowser browser, IDragData dragData, DragOperationsMask mask)
|
|
{
|
|
if (dragData.IsFile && dragData.FileNames != null && dragData.FileNames.Count > 0)
|
|
{
|
|
string file = dragData.FileNames[0];
|
|
if (!file.EndsWith(".png") && !file.EndsWith(".jpg") && !file.EndsWith(".jpeg"))
|
|
{
|
|
dragData.Dispose();
|
|
return true;
|
|
}
|
|
|
|
// forgive me father for i have sinned once again
|
|
AppApi.Instance.ExecuteAppFunction("dragEnterCef", dragData.FileNames[0]);
|
|
dragData.Dispose();
|
|
return false;
|
|
}
|
|
|
|
dragData.Dispose();
|
|
return true;
|
|
}
|
|
|
|
public void OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList<DraggableRegion> regions)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|