Exemplo n.º 1
0
        private void InvalidateTracks()
        {
            if (Tracks == null)
            {
                return;
            }

            if (Width > 0)
            {
                _renderer.Settings.Width = (int)(Width / _displayDensity);

                _initialRenderCompleted = false;
                _isRendering            = true;
                var tracks = Tracks.ToArray();
                if (tracks.Length > 0)
                {
                    ModelUtils.ApplyPitchOffsets(_renderer.Settings, tracks[0].Score);
                }

                Task.Factory.StartNew(() =>
                {
                    _renderer.RenderMultiple(tracks);
                });
            }
            else
            {
                _initialRenderCompleted = false;
                _redrawPending          = true;
            }
        }
Exemplo n.º 2
0
        public void InvalidateTracks(bool force)
        {
            var trackArray = Tracks?.ToArray();

            if (trackArray == null || trackArray.Length == 0)
            {
                return;
            }

            var width = RenderWidth;

            if (width > 0)
            {
                if (trackArray == Renderer.Tracks && !force)
                {
                    return;
                }

                var settings = Renderer.Settings;
                settings.Width        = width;
                settings.Engine       = RenderEngine;
                settings.Height       = ScoreHeight;
                settings.Scale        = Scale;
                settings.Layout.Mode  = LayoutMode;
                settings.StretchForce = StretchForce;
                settings.Staves.Id    = StavesMode;
                Renderer.UpdateSettings(settings);
                ModelUtils.ApplyPitchOffsets(settings, trackArray[0].Score);

                _initialRenderCompleted = false;
                _isRendering            = 1;

                Task.Factory.StartNew(() =>
                {
                    Renderer.RenderMultiple(trackArray);
                });
            }
            else
            {
                _initialRenderCompleted = false;
                _redrawPending          = true;
                _isRendering            = 0;
            }
        }
        protected void Render(Track[] tracks, string path, string renderLayout)
        {
            var settings = Settings.Defaults;

            settings.Engine = "gdi";
            settings.Layout = new LayoutSettings
            {
                Mode = renderLayout
            };
            var renderer    = new ScoreRenderer(settings);
            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.RenderMultiple(tracks);
            using (var bmp = new Bitmap(totalWidth, totalHeight))
            {
                int y = 0;
                using (var g = Graphics.FromImage(bmp))
                {
                    g.Clear(Color.White);
                    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);
            }
        }
 private void Render()
 {
     _renderer.RenderMultiple(Tracks);
 }