我想创建并编译一个小程序,允许某人从浏览器中运行,拖放图像。然后我想让这个程序挑出这个图像的源URL并将其粘贴到文本框中。我需要这样做,因为我稍后将使程序通过使用API单击按钮将上述URL图像上传到Imgur,但现在我正在寻找一种方法来使用拖放功能我的优势。我也不知道是否会更容易使用VB.net或C#。Visual Basic或C#拖放图像源地址
有人可以给我任何线索,我可以做到这一点吗?
这里是我迄今为止..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Imgur_Album_Upload
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
WireDragDrop(this.Controls);
}
private void WireDragDrop(Control.ControlCollection ctls)
{
foreach (Control ctl in ctls)
{
ctl.AllowDrop = true;
ctl.DragEnter += ctl_DragEnter;
ctl.DragDrop += ctl_DragDrop;
WireDragDrop(ctl.Controls);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ctl_DragDrop(object sender, DragEventArgs e)
{
var textData = e.Data.GetData(DataFormats.Text) as string;
if (textData == null)
return;
messagebox.Text = textData;
// Validate the URL in textData here
}
private void ctl_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}
在这种情况下,您需要浏览器本身的帮助。 –
我已经做了很多研究,没有什么比较有效的,只是想知道是否有人有任何想法,因为我运气不佳 – user4191887
我认为它会像剪贴板抓取一样工作很多,但这次是一个拖-drop – user4191887