Beispiel #1
0
        /// <summary>
        /// Song2014 to ASCII Tablature
        /// </summary>
        /// <param name="rs2014Song"></param>
        /// <param name="outputDir"></param>
        /// <param name="allDif"></param>
        public void Song2014ToAsciiTab(Song2014 rs2014Song, string outputDir, bool allDif)
        {
            if (rs2014Song == null || String.IsNullOrEmpty(outputDir))
            {
                return;
            }
            // convert to Song
            Song rs1Song;

            using (var obj = new Rs2014Converter())
                rs1Song = obj.Song2014ToSong(rs2014Song);
            Console.WriteLine("Converted Song2014 To Song");

            //if (false) // write Xml files for debugging
            //{
            //    using (Rs2014Converter obj = new Rs2014Converter())
            //        obj.Song2014ToXml(rs2014Song, outputDir, true);
            //    using (Rs1Converter obj = new Rs1Converter())
            //        obj.SongToXml(rs1Song, outputDir, true);
            //}

            // convert to SngFile
            string rs1SngFilePath;

            using (var obj = new Rs1Converter())
                rs1SngFilePath = obj.SongToSngFilePath(rs1Song, outputDir);
            Console.WriteLine("Converted Song To SngFile");

            // convert to AsciiTab
            using (var s2Tab = new Sng2Tab())
                s2Tab.Convert(rs1SngFilePath, outputDir, allDif);
            Console.WriteLine("Converted SngFile To AsciiTab");

            if (File.Exists(rs1SngFilePath))
            {
                File.Delete(rs1SngFilePath);
            }
        }
Beispiel #2
0
        public string Song2014File2SongFile(string songFilePath, bool overWrite)
        {
            Song song;

            using (var obj = new Rs2014Converter())
                song = obj.Song2014ToSong(Song2014.LoadFromFile(songFilePath));

            if (!overWrite)
            {
                var srcDir        = Path.GetDirectoryName(songFilePath);
                var srcName       = Path.GetFileNameWithoutExtension(songFilePath);
                var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS2014");

                // backup original RS1 file
                File.Copy(songFilePath, backupSrcPath);
            }

            // write converted RS1 file
            using (FileStream stream = new FileStream(songFilePath, FileMode.Create))
                song.Serialize(stream, true);

            return(songFilePath);
        }