Merge pull request #799 from lhhxxxxx/feat/drag_and_drop

[New Feature] 允许拖拽导入作业
This commit is contained in:
lhhxxxxx
2022-06-08 18:57:01 +08:00
committed by GitHub
2 changed files with 29 additions and 1 deletions

View File

@@ -18,12 +18,15 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Notification.Wpf.Constants;
using Notification.Wpf.Controls;
using Stylet;
using StyletIoC;
using DragEventArgs = System.Windows.DragEventArgs;
using Screen = Stylet.Screen;
namespace MeoAsstGui
{
@@ -182,6 +185,29 @@ namespace MeoAsstGui
}
}
public void DropFile(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
return;
}
var filename = ((Array)e.Data.GetData(DataFormats.FileDrop))?.GetValue(0).ToString();
if (filename == null)
{
return;
}
if (filename.EndsWith(".json"))
{
Filename = filename;
}
else
{
Filename = "";
ClearLog();
AddLog("此文件非json文件","darkred");
}
}
private bool _form = false;
public bool Form

View File

@@ -9,7 +9,9 @@
mc:Ignorable="d"
xmlns:vm="clr-namespace:MeoAsstGui;assembly=MeoAsstGui"
d:DataContext="{d:DesignInstance {x:Type vm:CopilotViewModel}}"
d:DesignHeight="495" d:DesignWidth="800">
d:DesignHeight="495" d:DesignWidth="800"
AllowDrop="True"
Drop="{s:Action DropFile}">
<Grid Margin="20">
<Grid.ColumnDefinitions>
<ColumnDefinition />