Beispiel #1
0
        private static int ReswToAndroidCommand(ReswToAndroidParameters parameters)
        {
            if (!File.Exists(parameters.Input))
            {
                Console.WriteLine($"The file {parameters.Input} doesn't exist");
                return(-1);
            }

            var reswContent = File.ReadAllText(parameters.Input);
            var resw        = ReswParser.Parse(reswContent);

            if (resw == null)
            {
                Console.WriteLine($"Can't parse the resw file: {parameters.Input}");
                return(-1);
            }
            var androidXML = AndroidXMLConverter.ReswToAndroidXML(resw, parameters.SupportPluralization);

            if (androidXML == null)
            {
                Console.WriteLine($"Error during the conversion of the file: {parameters.Input}");
                return(-1);
            }
            androidXML.Save(parameters.OutputFilePath);
            return(0);
        }
Beispiel #2
0
 private void ExportAndroidCommandExecute(object sender, EventArgs e)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         var projectItem = GetCurrentProjectItem();
         if (projectItem.Name.EndsWith(".resw") &&
             projectItem.Properties.Item("FullPath").Value is string filepath)
         {
             var reswContent = File.ReadAllText(filepath);
             var androidFile = AndroidXMLConverter.ReswToAndroidXML(ReswParser.Parse(reswContent), true);
             using (var saveFileDialog = new SaveFileDialog()
             {
                 FileName = Path.GetFileNameWithoutExtension(projectItem.Name) + ".xml"
             })
             {
                 if (saveFileDialog.ShowDialog() == DialogResult.OK)
                 {
                     androidFile.Save(saveFileDialog.FileName);
                 }
             }
             return;
         }
     }
     catch
     { }
     VsShellUtilities.ShowMessageBox(
         package,
         "Can't convert this resw file",
         "ReswPlus",
         OLEMSGICON.OLEMSGICON_INFO,
         OLEMSGBUTTON.OLEMSGBUTTON_OK,
         OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
 }
Beispiel #3
0
 private static int AndroidToReswCommand(AndroidToReswParameters parameters)
 {
     if (Directory.Exists(parameters.Input))
     {
         var success = AndroidXMLConverter.AndroidXMLDirectoryToResw(parameters.Input, parameters.OutputPath);
         if (success)
         {
             Console.WriteLine($"Directory created: {parameters.OutputPath}");
             return(0);
         }
         else
         {
             Console.WriteLine($"Error during the conversion");
             return(-1);
         }
     }
     else if (File.Exists(parameters.Input))
     {
         var success = AndroidXMLConverter.AndroidXMLFileToResw(parameters.Input, parameters.OutputPath);
         if (success)
         {
             Console.WriteLine($"File created: {parameters.OutputPath}");
             return(0);
         }
         else
         {
             Console.WriteLine($"Error during the conversion");
             return(-1);
         }
     }
     else
     {
         Console.WriteLine($"The file {parameters.Input} doesn't exist");
         return(-1);
     }
 }