82 lines
2.2 KiB
C#
82 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace Txt2Bib
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
DropArea.AllowDrop = true;
|
|
}
|
|
|
|
private void DropArea_Drop(object sender, DragEventArgs e)
|
|
{
|
|
// Get data object
|
|
var dataObject = e.Data as DataObject;
|
|
|
|
if (dataObject == null )
|
|
{
|
|
MessageBox.Show("Nessun percorso disponibile...");
|
|
return;
|
|
}
|
|
|
|
// Check for file list
|
|
if (dataObject.ContainsFileDropList())
|
|
{
|
|
// Clear values
|
|
DropArea.Text = string.Empty;
|
|
|
|
// Process file names
|
|
var fileNames = dataObject.GetFileDropList();
|
|
StringBuilder bd = new StringBuilder();
|
|
foreach (var fileName in fileNames)
|
|
{
|
|
bd.Append(fileName + "\n");
|
|
}
|
|
// Set text
|
|
DropArea.Text = bd.ToString();
|
|
}
|
|
}
|
|
|
|
private void DropArea_PreviewDragEnter(object sender, DragEventArgs e)
|
|
{
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
{
|
|
e.Effects = DragDropEffects.Copy;
|
|
}
|
|
else
|
|
{
|
|
e.Effects = DragDropEffects.None;
|
|
}
|
|
}
|
|
|
|
private void DropArea_PreviewDragOver(object sender, DragEventArgs e)
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
|
|
private void GoBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var txt2bib = new Text2Bib();
|
|
Debug.Text = txt2bib.Generate(DropArea.Text);
|
|
}
|
|
}
|
|
}
|