-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
54 lines (44 loc) · 1.57 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using MahApps.Metro.Controls;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
namespace touhouSSRen
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
CommandBindings.AddRange(MyCommands.BindingMyCommands());
DragOver += (s, e) =>
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effects = DragDropEffects.Move;
};
Drop += (s, e) =>
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
return;
var fnames = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Directory.Exists(fnames[0]))
fnames = Directory.GetFiles(fnames[0], "*.bmp");
var dir = Path.GetDirectoryName(fnames[0]);
var num = 0;
foreach (var fname in fnames.OrderBy(x => x))
{
var res = FnPattern().Match(fname);
if (res.Success)
{
var dest = Path.Combine(dir!, $"{res.Groups[1].Value}{num++:000}.bmp");
File.Move(fname, dest);
}
}
};
}
[GeneratedRegex(@"(th[0-9_]*?)[0-9]{3,}\.bmp$")]
private static partial Regex FnPattern();
}
}