diff --git a/XLSX2RESW.sln b/XLSX2RESW.sln
index c3fdcf5..14f55b2 100644
--- a/XLSX2RESW.sln
+++ b/XLSX2RESW.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.25123.0
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XLSX2RESW", "XLSX2RESW\XLSX2RESW.csproj", "{9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XLSX2RESW", "XLSX2RESW\XLSX2RESW.csproj", "{72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,10 +11,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}.Release|Any CPU.Build.0 = Release|Any CPU
+ {72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/XLSX2RESW/App.config b/XLSX2RESW/App.config
index 45a2cc5..8324aa6 100644
--- a/XLSX2RESW/App.config
+++ b/XLSX2RESW/App.config
@@ -1,14 +1,6 @@
-
+
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/XLSX2RESW/App.xaml b/XLSX2RESW/App.xaml
new file mode 100644
index 0000000..28d737c
--- /dev/null
+++ b/XLSX2RESW/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/XLSX2RESW/App.xaml.cs b/XLSX2RESW/App.xaml.cs
new file mode 100644
index 0000000..354839f
--- /dev/null
+++ b/XLSX2RESW/App.xaml.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using System.Windows;
+using XLSX2RESW.Classes;
+
+namespace XLSX2RESW
+{
+ public partial class App : Application
+ {
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ //no double instance!
+ if(Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
+ {
+ Current.Shutdown();
+ return;
+ }
+
+ //check parameters
+ if(e.Args.Length > 0)
+ {
+ var files = e.Args;
+
+ //convert files
+ Elaborator.Convert(files);
+
+ //exit from application
+ Current.Shutdown();
+ return;
+ }
+
+ }
+ }
+}
diff --git a/XLSX2RESW/Classes/Constants.cs b/XLSX2RESW/Classes/Constants.cs
new file mode 100644
index 0000000..6ebba8c
--- /dev/null
+++ b/XLSX2RESW/Classes/Constants.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace XLSX2RESW.Classes
+{
+ public class Constants
+ {
+ public static readonly string InputExtension = ".xlsx";
+ public static readonly string InputExtensionFilter = "Excel Files (*.xlsx)|*.xlsx";
+ public static readonly string OutputFileName = "Resources.resw";
+ public static readonly string OutputFileNameSuffix = "_XLSX2RESW";
+ }
+}
diff --git a/XLSX2RESW/Program.cs b/XLSX2RESW/Classes/Elaborator.cs
similarity index 53%
rename from XLSX2RESW/Program.cs
rename to XLSX2RESW/Classes/Elaborator.cs
index 987d6ca..b0b4207 100644
--- a/XLSX2RESW/Program.cs
+++ b/XLSX2RESW/Classes/Elaborator.cs
@@ -6,43 +6,36 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using System.Windows.Forms;
+using System.Windows;
using Excel;
-namespace XLSX2RESW
+namespace XLSX2RESW.Classes
{
- static class Program
+ public class Elaborator
{
- private static string filePath = null;
- private static string supportedExtension = "xlsx";
- private static string outputFileName = "Resources.resw";
- private static string suffixOutputFileName = "_XLSX2RESW";
+ private static List errors = new List();
- [STAThread]
- static void Main(string[] args)
+ public static void Convert(string[] files)
{
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- try
+ //iterate all files
+ foreach(var file in files)
{
- //check args
- if(args.Length == 1)
+ try
{
- filePath = args[0];
-
- //check if item dropped is a file
- if(!File.GetAttributes(filePath).HasFlag(FileAttributes.Directory))
+ //check if item is a file
+ if(!File.GetAttributes(file).HasFlag(FileAttributes.Directory))
{
- //check if file is a .csv
- if(Path.GetExtension(filePath) == "." + supportedExtension)
+ //check if file is supported
+ if(Path.GetExtension(file) == Constants.InputExtension)
{
- string folderPath = Path.GetDirectoryName(filePath);
+ //get folder path
+ string FolderPath = Path.GetDirectoryName(file);
- List myoutput = ReadFile();
+ //read file into JLanguage
+ List myoutput = ReadFile(file);
//elaborate file
- string outputFolder = folderPath + "\\" + Path.GetFileNameWithoutExtension(filePath) + suffixOutputFileName;
+ string outputFolder = FolderPath + "\\" + Path.GetFileNameWithoutExtension(file) + Constants.OutputFileNameSuffix;
if(!Directory.Exists(outputFolder))
{
@@ -52,63 +45,72 @@ static void Main(string[] args)
{
Directory.CreateDirectory(outputFolder + "\\" + items.code);
- File.AppendAllText(outputFolder + "\\" + items.code + "\\" + outputFileName, Properties.Resources.resw_start);
+ File.AppendAllText(outputFolder + "\\" + items.code + "\\" + Constants.OutputFileName,
+ Properties.Resources.resw_start);
foreach(var item in items.values)
{
- File.AppendAllText(outputFolder + "\\" + items.code + "\\" + outputFileName, "\n" + String.Format(Properties.Resources.resw_value, item.id, item.value));
+ File.AppendAllText(outputFolder + "\\" + items.code + "\\" + Constants.OutputFileName,
+ "\n" + String.Format(Properties.Resources.resw_value, item.id, item.value));
}
- File.AppendAllText(outputFolder + "\\" + items.code + "\\" + outputFileName, "\n" + Properties.Resources.resw_end);
+ File.AppendAllText(outputFolder + "\\" + items.code + "\\" + Constants.OutputFileName,
+ "\n" + Properties.Resources.resw_end);
}
//DONE!
}
else
{
- MessageBox.Show("The " + Path.GetFileNameWithoutExtension(filePath) + suffixOutputFileName + " folder already exist.\nPlease delete it and retry.", "Error");
+ errors.Add(Path.GetFileName(file) + " not converted. " + Path.GetFileName(outputFolder) + " folder already exist. Please delete it and retry.");
}
}
- else
+ else
{
- MessageBox.Show("This application only supports drag & drop of 1 " + supportedExtension + " file!", "Error");
+ errors.Add(Path.GetFileName(file) + " not converted. This program supports only " + Constants.InputExtension + " files.");
}
}
else
{
- MessageBox.Show("This application only supports drag & drop of 1 " + supportedExtension + " file!", "Error");
+ errors.Add(Path.GetFileName(file) + " not converted. This program supports only files.");
}
}
- else
+ catch(Exception ex)
{
- MessageBox.Show("This application only supports drag & drop of 1 " + supportedExtension + " file!", "Error");
+ switch(ex.HResult)
+ {
+ case -2147024864:
+ errors.Add(Path.GetFileName(file) + " not converted. Please close your " + Constants.InputExtension + " file from excel first!");
+ break;
+
+ default:
+ errors.Add(Path.GetFileName(file) + " not converted. "+ ex.Message);
+ Debug.WriteLine(ex.Message + "\n\n" + ex.StackTrace, "Exception " + ex.HResult);
+ break;
+ }
}
-
}
- catch(Exception ex)
+
+ //check any errors
+ if(errors.Count > 0)
{
- switch(ex.HResult)
+ StringBuilder message = new StringBuilder();
+ message.AppendLine("The following items were not converted:");
+ message.AppendLine();
+ foreach(var error in errors)
{
- case -2147024864:
- MessageBox.Show("Please close your xlsx file from excel first!","Error");
- break;
-
- default:
- MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Exception " + ex.HResult);
- Debug.WriteLine(ex.Message + "\n\n" + ex.StackTrace, "Exception " + ex.HResult);
- break;
+ message.AppendLine("- " + error);
}
-
- }
- //exit
- Application.Exit();
+ //print all errors
+ MessageBox.Show(message.ToString(), "Warning");
+ }
}
- private static List ReadFile()
+ private static List ReadFile(string file)
{
- //open xlsx file
- FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
+ //open file
+ FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();
@@ -119,7 +121,7 @@ private static List ReadFile()
int totalRows = GetTotalRows(result);
//output to return
- List projects = new List();
+ List projects = new List();
//iterate languages
for(int i = 1; i <= totalLanguages; i++)
@@ -138,7 +140,7 @@ private static List ReadFile()
});
}
- projects.Add(new JProject() { code = project_code, values = project_values });
+ projects.Add(new JLanguage() { code = project_code, values = project_values });
}
excelReader.Close();
@@ -189,6 +191,5 @@ private static string FixValue(string value)
{
return value.Replace("&", "&");
}
-
}
}
diff --git a/XLSX2RESW/JProject.cs b/XLSX2RESW/Classes/JLanguage.cs
similarity index 86%
rename from XLSX2RESW/JProject.cs
rename to XLSX2RESW/Classes/JLanguage.cs
index f20f8c5..f70273c 100644
--- a/XLSX2RESW/JProject.cs
+++ b/XLSX2RESW/Classes/JLanguage.cs
@@ -4,9 +4,9 @@
using System.Text;
using System.Threading.Tasks;
-namespace XLSX2RESW
+namespace XLSX2RESW.Classes
{
- public class JProject
+ public class JLanguage
{
public string code { get; set; }
public List values { get; set; }
diff --git a/XLSX2RESW/Properties/AssemblyInfo.cs b/XLSX2RESW/Properties/AssemblyInfo.cs
index b5d40d2..4dc8121 100644
--- a/XLSX2RESW/Properties/AssemblyInfo.cs
+++ b/XLSX2RESW/Properties/AssemblyInfo.cs
@@ -1,10 +1,12 @@
using System.Reflection;
+using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Windows;
-// Le informazioni generali relative a un assembly sono controllate dal seguente
-// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
-// associate a un assembly.
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
[assembly: AssemblyTitle("XLSX2RESW")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -14,23 +16,40 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
-// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
-// COM, impostare su true l'attributo ComVisible per tale tipo.
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
-// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
-[assembly: Guid("9da5c8e7-60ac-43de-a1b9-4a78f2e7c263")]
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
-// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[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)
+)]
+
+
+// Version information for an assembly consists of the following four values:
//
-// Versione principale
-// Versione secondaria
-// Numero di build
-// Revisione
+// Major Version
+// Minor Version
+// Build Number
+// Revision
//
-// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
-// usando l'asterisco '*' come illustrato di seguito:
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.0.0")]
-[assembly: AssemblyFileVersion("1.2.0.0")]
+[assembly: AssemblyVersion("2.0.0.0")]
+[assembly: AssemblyFileVersion("2.0.0.0")]
diff --git a/XLSX2RESW/Properties/Settings.settings b/XLSX2RESW/Properties/Settings.settings
index 3964565..033d7a5 100644
--- a/XLSX2RESW/Properties/Settings.settings
+++ b/XLSX2RESW/Properties/Settings.settings
@@ -1,7 +1,7 @@
-
+
-
+
\ No newline at end of file
diff --git a/XLSX2RESW/Windows/Home.xaml b/XLSX2RESW/Windows/Home.xaml
new file mode 100644
index 0000000..55a9466
--- /dev/null
+++ b/XLSX2RESW/Windows/Home.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/XLSX2RESW/Windows/Home.xaml.cs b/XLSX2RESW/Windows/Home.xaml.cs
new file mode 100644
index 0000000..62321bf
--- /dev/null
+++ b/XLSX2RESW/Windows/Home.xaml.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+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;
+using Microsoft.Win32;
+using XLSX2RESW.Classes;
+
+namespace XLSX2RESW.Windows
+{
+ public partial class Home : Window
+ {
+ public Home()
+ {
+ InitializeComponent();
+
+ dropzone.AllowDrop = true;
+ dropzone.Drop += Dropzone_Drop;
+ dropzone_browse.Click += Dropzone_browse_Click;
+ }
+
+ private void Dropzone_browse_Click(object sender, RoutedEventArgs e)
+ {
+ //create openfiledialog
+ OpenFileDialog dlg = new OpenFileDialog();
+
+ //set filter for file extension and default file extension
+ dlg.DefaultExt = Constants.InputExtension;
+ dlg.Filter = Constants.InputExtensionFilter;
+ dlg.Multiselect = true;
+
+ //display openfiledialog by calling ShowDialog method
+ Nullable result = dlg.ShowDialog();
+
+ //get the selected file name and display in a TextBox
+ if(result == true)
+ {
+ //open document
+ var files = dlg.FileNames;
+
+ //convert files
+ Elaborator.Convert(files);
+ }
+ }
+
+ private void Dropzone_Drop(object sender, DragEventArgs e)
+ {
+ if(e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ //get files from dropzone
+ var files = (string[])e.Data.GetData(DataFormats.FileDrop);
+
+ //convert files
+ Elaborator.Convert(files);
+ }
+ }
+ }
+}
diff --git a/XLSX2RESW/XLSX2RESW.csproj b/XLSX2RESW/XLSX2RESW.csproj
index fb01989..b190d6f 100644
--- a/XLSX2RESW/XLSX2RESW.csproj
+++ b/XLSX2RESW/XLSX2RESW.csproj
@@ -4,15 +4,16 @@
Debug
AnyCPU
- {9DA5C8E7-60AC-43DE-A1B9-4A78F2E7C263}
+ {72AE7E4D-F197-422B-A9F3-0D7C27FA4FDB}
WinExe
Properties
XLSX2RESW
XLSX2RESW
v4.6
512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
true
- false
publish\
true
Disk
@@ -24,7 +25,8 @@
false
true
0
- 1.2.0.0
+ 2.0.0.%2a
+ false
false
true
@@ -54,48 +56,71 @@
..\packages\ExcelDataReader.2.1.2.3\lib\net45\Excel.dll
True
- False
..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
True
+
+
+
-
-
-
-
-
-
+
+ 4.0
+
+
+
+
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
+
+ MSBuild:Compile
Designer
-
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+
+
+ Home.xaml
+ Code
+
+
+
+
+ Code
+
True
- Resources.resx
True
+ Resources.resx
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
True
Settings.settings
True
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
@@ -104,13 +129,13 @@
-
+
-
+
-
+