コード例 #1
0
        private void InternalOpenFile(string file)
        {
            try
            {
                // load the score from the filesystem
                Score = ScoreLoader.LoadScore(file);

                trackDetails.Controls.Clear();
                trackBars.Controls.Clear();
                for (int i = Score.Tracks.Count - 1; i >= 0; i--)
                {
                    TrackDetailsControl details = new TrackDetailsControl(Score.Tracks[i]);
                    details.Dock   = DockStyle.Top;
                    details.Height = 25;
                    trackDetails.Controls.Add(details);
                    details.Selected += details_Click;

                    TrackBarsControl bars = new TrackBarsControl(Score.Tracks[i]);
                    bars.Dock = DockStyle.Top;
                    trackBars.Controls.Add(bars);
                }

                UpdateSelectedTrack();
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "An error during opening the file occured", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage AlphaTab.ScoreDump.exe Path");
                return;
            }

            Score score = ScoreLoader.LoadScore(args[0]);

            // score info
            Console.WriteLine("Title: {0}", score.Title);
            Console.WriteLine("Subtitle: {0}", score.SubTitle);
            Console.WriteLine("Artist: {0}", score.Artist);
            Console.WriteLine("Tempo: {0}", score.Tempo);
            Console.WriteLine("Bars: {0}", score.MasterBars.Count);
            Console.WriteLine("Time Signature: {0}/{1}", score.MasterBars[0].TimeSignatureNumerator,
                              score.MasterBars[0].TimeSignatureDenominator);
            // tracks
            Console.WriteLine("Tracks: ");
            for (int i = 0; i < score.Tracks.Count; i++)
            {
                Track track = (Track)score.Tracks[i];
                Console.WriteLine("   {0} - {1} - {2}", i + 1, track.Name, track.IsPercussion ? "Percussion" : "Midi Instrument: " + track.PlaybackInfo.Program);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: zolnierowski/alphaTab
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage AlphaTab.ScoreDump.exe Path");
                return;
            }

            // we need to use english culture to have correct string variants of floating points (dot as decimal separator)
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-us");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            // load score
            Score score = ScoreLoader.LoadScore(args[0]);

            // render score with svg engine
            Settings settings = Settings.Defaults;

            settings.Engine = "svg";
            ScoreRenderer renderer = new ScoreRenderer(settings, null);

            // get iterate tracks
            for (int i = 0; i < score.Tracks.Count; i++)
            {
                Track track = score.Tracks[i];
                // render track
                Console.WriteLine("Rendering track {0} - {1}", i + 1, track.Name);
                var totalWidth  = 0;
                var totalHeight = 0;
                var merged      = XDocument.Parse("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"1px\" height=\"1px\"></svg>");
                var currentY    = 0f;
                renderer.PartialRenderFinished += r =>
                {
                    var subSvg  = XDocument.Parse(r.RenderResult.ToString());
                    var subRoot = subSvg.Root;
                    subRoot.SetAttributeValue("x", "0px");
                    subRoot.SetAttributeValue("y", ((int)currentY) + "px");
                    merged.Root.Add(subRoot);
                    currentY += r.Height;
                };
                renderer.RenderFinished += r =>
                {
                    totalWidth  = (int)r.TotalWidth;
                    totalHeight = (int)r.TotalHeight;
                };
                renderer.Render(track);

                merged.Root.Attribute("width").Value  = totalWidth + "px";
                merged.Root.Attribute("height").Value = totalHeight + "px";


                string svg = merged.ToString();

                FileInfo info = new FileInfo(args[0]);
                string   path = Path.Combine(info.DirectoryName, Path.GetFileNameWithoutExtension(info.Name) + "-" + i + ".svg");
                File.WriteAllText(path, svg);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: zolnierowski/alphaTab
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage AlphaTab.ScoreDump.exe Path");
                return;
            }

            // load score
            var score = ScoreLoader.LoadScore(args[0]);

            // render score with svg engine
            var settings = Settings.Defaults;

            settings.Engine = "gdi";
            var renderer = new ScoreRenderer(settings, null);

            // iterate tracks
            for (int i = 0, j = score.Tracks.Count; i < j; i++)
            {
                var track = score.Tracks[i];

                // render track
                Console.WriteLine("Rendering track {0} - {1}", i + 1, track.Name);
                var images      = new List <Image>();
                var totalWidth  = 0;
                var totalHeight = 0;
                renderer.PartialRenderFinished += r =>
                {
                    images.Add((Image)r.RenderResult);
                };
                renderer.RenderFinished += r =>
                {
                    totalWidth  = (int)r.TotalWidth;
                    totalHeight = (int)r.TotalHeight;
                };
                renderer.Render(track);

                // write png
                var info = new FileInfo(args[0]);
                var path = Path.Combine(info.DirectoryName, Path.GetFileNameWithoutExtension(info.Name) + "-" + i + ".png");

                using (var bmp = new Bitmap(totalWidth, totalHeight))
                {
                    int y = 0;
                    using (var g = Graphics.FromImage(bmp))
                    {
                        foreach (var image in images)
                        {
                            g.DrawImage(image, new Rectangle(0, y, image.Width, image.Height),
                                        new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                            y += image.Height;
                        }
                    }
                    bmp.Save(path, ImageFormat.Png);
                }
            }
        }
コード例 #5
0
        private void InternalOpenFile(string file)
        {
            //try
            {
                // load the score from the filesystem
                Score = ScoreLoader.LoadScore(file);

                // build the track info objects for the ui
                TrackViewModel[] trackInfos = new TrackViewModel[Score.Tracks.Count];
                for (int i = 0; i < trackInfos.Length; i++)
                {
                    trackInfos[i] = new TrackViewModel(Score.Tracks[i]);
                }
                TrackInfos = trackInfos;
            }
            //catch (Exception e)
            //{
            //    _errorService.OpenFailed(e);
            //}
        }
コード例 #6
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage AlphaTab.MidiDump.exe Path");
                return;
            }

            // load score
            Score score = ScoreLoader.LoadScore(args[0]);

            // generate midi
            MidiFile file = MidiFileGenerator.GenerateMidiFile(score);

            // write midi file
            string path = Path.ChangeExtension(args[0], "mid");

            using (var fs = new StreamWrapper(File.OpenWrite(path)))
            {
                file.WriteTo(fs);
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: weinyzhou/alphaTab
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage AlphaTab.ScoreDump.exe Path");
                return;
            }

            // we need to use english culture to have correct string variants of floating points (dot as decimal separator)
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-us");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            // load score
            Score score = ScoreLoader.LoadScore(args[0]);

            // render score with svg engine
            Settings settings = Settings.Defaults;

            settings.Engine = "svg";
            ScoreRenderer renderer = new ScoreRenderer(settings);

            // get iterate tracks
            for (int i = 0; i < 1; i++)
            {
                Track track = score.Tracks[i];
                // render track
                Console.WriteLine("Rendering track {0} - {1}", i + 1, track.Name);
                var       totalWidth  = 0;
                var       totalHeight = 0;
                XDocument merged      = null;
                var       currentY    = 0f;
                renderer.PreRender += r =>
                {
                    // append the svg close tag which would be part of the RenderFinished event
                    var svgString = r.RenderResult.ToString() + "</svg>";
                    merged = XDocument.Parse(svgString);
                };
                renderer.PartialRenderFinished += r =>
                {
                    var subSvg  = XDocument.Parse(r.RenderResult.ToString());
                    var subRoot = subSvg.Root;
                    subRoot.SetAttributeValue("x", "0px");
                    subRoot.SetAttributeValue("y", ((int)currentY) + "px");
                    merged.Root.Add(subRoot);
                    currentY += r.Height;
                };
                renderer.RenderFinished += r =>
                {
                    totalWidth  = (int)r.TotalWidth;
                    totalHeight = (int)r.TotalHeight;
                };
                renderer.Render(track);

                merged.Root.SetAttributeValue("width", totalWidth + "px");
                merged.Root.SetAttributeValue("height", totalHeight + "px");


                var svg       = new StringWriter();
                var xmlWriter = new EntitizingXmlWriter(svg);
                merged.Save(xmlWriter);

                FileInfo info = new FileInfo(args[0]);
                string   path = Path.Combine(info.DirectoryName, Path.GetFileNameWithoutExtension(info.Name) + "-" + i + ".svg");
                File.WriteAllText(path, svg.ToString());
            }
        }