54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AntdUIDemo.Views
|
|
{
|
|
public partial class UploadDraggerDemo : UserControl
|
|
{
|
|
private AntdUI.Window window;
|
|
public UploadDraggerDemo(AntdUI.Window _window)
|
|
{
|
|
window = _window;
|
|
InitializeComponent();
|
|
BindEventHandler();
|
|
}
|
|
|
|
private void BindEventHandler()
|
|
{
|
|
uploadDragger.DragChanged += UploadDragger_DragChanged;
|
|
uploadDragger.Click += UploadDragger_Click;
|
|
}
|
|
|
|
private void UploadDragger_Click(object sender, EventArgs e)
|
|
{
|
|
// 创建一个文件对话框实例
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
|
// 设置文件对话框的属性
|
|
openFileDialog.Filter = "All Files (*.*)|*.*"; // 过滤器,允许选择所有文件
|
|
openFileDialog.Title = "Select a File"; // 对话框标题
|
|
openFileDialog.Multiselect = false; // 不允许多选文件
|
|
|
|
// 显示文件对话框并检查用户是否选择了文件
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
// 获取用户选择的文件路径
|
|
string[] filePaths = openFileDialog.FileNames;
|
|
foreach (string path in filePaths)
|
|
{
|
|
AntdUI.Message.info(window, path, autoClose: 3);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UploadDragger_DragChanged(object sender, AntdUI.UploadDragger.StringsEventArgs e)
|
|
{
|
|
string[] filePaths = e.Value;
|
|
foreach (string path in filePaths)
|
|
{
|
|
AntdUI.Message.info(window, path, autoClose: 3);
|
|
}
|
|
}
|
|
}
|
|
}
|