mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Made the Win10 share work, at least somewhat.
This commit is contained in:
parent
4da8f223da
commit
5779d2ac2b
7 changed files with 365 additions and 4 deletions
64
GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs
Normal file
64
GreenshotWin10Plugin/Native/DataTransferManagerHelper.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
|
||||
namespace GreenshotWin10Plugin.Native
|
||||
{
|
||||
public class DataTransferManagerHelper
|
||||
{
|
||||
private const string DataTransferManagerId = "a5caee9b-8708-49d1-8d36-67d25a8da00c";
|
||||
private readonly IDataTransferManagerInterOp _dataTransferManagerInterOp;
|
||||
private readonly IntPtr _windowHandle;
|
||||
|
||||
public DataTransferManager DataTransferManager
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public DataTransferManagerHelper(IntPtr handle)
|
||||
{
|
||||
//TODO: Add a check for failure here. This will fail for versions of Windows below Windows 10
|
||||
IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(DataTransferManager));
|
||||
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
_dataTransferManagerInterOp = (IDataTransferManagerInterOp)activationFactory;
|
||||
|
||||
_windowHandle = handle;
|
||||
var riid = new Guid(DataTransferManagerId);
|
||||
DataTransferManager dataTransferManager;
|
||||
_dataTransferManagerInterOp.GetForWindow(_windowHandle, riid, out dataTransferManager);
|
||||
DataTransferManager = dataTransferManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the share UI
|
||||
/// </summary>
|
||||
public void ShowShareUi()
|
||||
{
|
||||
_dataTransferManagerInterOp.ShowShareUIForWindow(_windowHandle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue