mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
Merge pull request #799 from lhhxxxxx/feat/drag_and_drop
[New Feature] 允许拖拽导入作业
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user