Add project files.
This commit is contained in:
parent
db2c09d5d3
commit
f5e3f92b08
9
App.xaml
Normal file
9
App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="Txt2Bib.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Txt2Bib"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
App.xaml.cs
Normal file
17
App.xaml.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Txt2Bib
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
AssemblyInfo.cs
Normal file
10
AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
25
MainWindow.xaml
Normal file
25
MainWindow.xaml
Normal file
@ -0,0 +1,25 @@
|
||||
<Window x:Class="Txt2Bib.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Txt2Bib"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="900" Width="800">
|
||||
<Grid Background="#FF38383E">
|
||||
<TextBox x:Name="DropArea" HorizontalAlignment="Left" Margin="48,82,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="431" Height="295" PreviewDragEnter="DropArea_PreviewDragEnter" PreviewDragOver="DropArea_PreviewDragOver" Drop="DropArea_Drop"/>
|
||||
<TextBox x:Name="Debug" HorizontalAlignment="Left" Margin="48,422,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="710" Height="429" RenderTransformOrigin="0.449,1.525"/>
|
||||
<Label Content="Txt2Bib" HorizontalAlignment="Center" Margin="0,10,0,0" VerticalAlignment="Top" Foreground="White" FontFamily="DejaVu Sans Light" FontSize="28"/>
|
||||
<Button x:Name="GoBtn" Content="Genera" HorizontalAlignment="Left" Margin="594,160,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Height="83" Width="131" Click="GoBtn_Click" BorderBrush="{x:Null}" Foreground="White" Background="#FF474671" FontFamily="Cascadia Code" FontSize="16">
|
||||
<Button.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform Angle="-0.415"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Button.RenderTransform>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
81
MainWindow.xaml.cs
Normal file
81
MainWindow.xaml.cs
Normal file
@ -0,0 +1,81 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
46
Text2Bib.cs
Normal file
46
Text2Bib.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows;
|
||||
|
||||
namespace Txt2Bib
|
||||
{
|
||||
internal class Text2Bib
|
||||
{
|
||||
public string Generate(string filenames)
|
||||
{
|
||||
var paths = filenames.Trim().Split('\n');
|
||||
string result = "";
|
||||
string output = "";
|
||||
|
||||
foreach (var path in paths)
|
||||
{
|
||||
var reader = File.OpenText(path);
|
||||
byte[] contentBytes = File.ReadAllBytes(path);
|
||||
|
||||
result += Encoding.Latin1.GetString(contentBytes);
|
||||
// How to determine actual encoding??
|
||||
/*
|
||||
result += reader.CurrentEncoding.CodePage switch
|
||||
{
|
||||
65001 => Encoding.UTF8.GetString(contentBytes),
|
||||
_ => Encoding.Latin1.GetString(contentBytes)
|
||||
};
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
//TODO process entry
|
||||
foreach (string item in result.Split('%'))
|
||||
{
|
||||
output += item;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
10
Txt2Bib.csproj
Normal file
10
Txt2Bib.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
25
Txt2Bib.sln
Normal file
25
Txt2Bib.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33712.159
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Txt2Bib", "Txt2Bib.csproj", "{FDD15141-8C8B-4499-B0CE-569228109AAD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FDD15141-8C8B-4499-B0CE-569228109AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FDD15141-8C8B-4499-B0CE-569228109AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FDD15141-8C8B-4499-B0CE-569228109AAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FDD15141-8C8B-4499-B0CE-569228109AAD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A9ECFA8F-BFA3-49CD-B5E8-BB8E1255596D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Loading…
Reference in New Issue
Block a user