Beispiel #1
0
        private void ResizeTracks(double width)
        {
            int newWidth = (int)width;

            if (Interlocked.Exchange(ref _isRendering, 1) == 1)
            {
                _redrawPending = true;
            }
            else if (width > 0)
            {
                _redrawPending = false;
                if (!_initialRenderCompleted)
                {
                    InvalidateTracks(true);
                }
                else if (newWidth != _renderer.Settings.Width)
                {
                    Task.Factory.StartNew(() =>
                    {
                        _renderer.Resize(newWidth);
                    });
                }
                else
                {
                    _isRendering = 0;
                }
            }
        }
Beispiel #2
0
        private void Resize(int width)
        {
            if (_isRendering)
            {
                _redrawPending = true;
            }
            else if (width > 0)
            {
                _redrawPending = false;

                if (!_initialRenderCompleted)
                {
                    InvalidateTracks();
                }
                else
                {
                    if (width != _renderer.Settings.Width)
                    {
                        _renderer.Settings.Width = width;
                        _isRendering             = true;
                        Task.Factory.StartNew(() =>
                        {
                            _renderer.Resize(width);
                        });
                    }
                }
            }
        }
Beispiel #3
0
        private void HandleMessage(DOMEvent e)
        {
            var data = e.As <MessageEvent>().data;
            var cmd  = data.Member("cmd").As <string>();

            switch (cmd)
            {
            case "load":
                Load(data.Member("data"), data.Member("indexes").As <int[]>());
                break;

            case "invalidate":
                _renderer.Invalidate();
                break;

            case "resize":
                _renderer.Resize(data.Member("width").As <int>());
                break;

            case "tex":
                Tex(data.Member("data").As <string>());
                break;

            case "renderMultiple":
                RenderMultiple(data.Member("data").As <int[]>());
                break;

            case "updateSettings":
                UpdateSettings(data.Member("settings"));
                break;
            }
        }
Beispiel #4
0
        private void HandleMessage(DOMEvent e)
        {
            var data = e.As <MessageEvent>().data;
            var cmd  = data.Member("cmd").As <string>();

            switch (cmd)
            {
            case "alphaTab.initialize":
                var settings = Settings.FromJson(data.Member("settings"), null);
                _renderer = new ScoreRenderer(settings);
                _renderer.PartialRenderFinished += result => PostMessage(new { cmd = "alphaTab.partialRenderFinished", result = result });
                _renderer.RenderFinished        += result => PostMessage(new { cmd = "alphaTab.renderFinished", result = result });
                _renderer.PostRenderFinished    += () => PostMessage(new { cmd = "alphaTab.postRenderFinished", boundsLookup = _renderer.BoundsLookup.ToJson() });
                _renderer.PreRender             += result => PostMessage(new { cmd = "alphaTab.preRender", result = result });
                break;

            case "alphaTab.load":
                Load(data.Member("data"), data.Member("indexes").As <int[]>());
                break;

            case "alphaTab.invalidate":
                _renderer.Invalidate();
                break;

            case "alphaTab.resize":
                _renderer.Resize(data.Member("width").As <int>());
                break;

            case "alphaTab.tex":
                Tex(data.Member("data").As <string>());
                break;

            case "alphaTab.renderMultiple":
                RenderMultiple(data.Member("data").As <int[]>());
                break;

            case "alphaTab.score":
                var converter = new JsonConverter();
                var score     = converter.JsObjectToScore(data.Member("score").As <Score>());
                Score = score;
                break;

            case "alphaTab.updateSettings":
                UpdateSettings(data.Member("settings"));
                break;
            }
        }
Beispiel #5
0
        private void HandleMessage(Event e)
        {
            var data = ((MessageEvent)e).Data;
            var cmd  = data ? data.cmd : "";

            switch (cmd)
            {
            case "alphaTab.initialize":
                Settings settings = Settings.FromJson(data.settings, null);
                Logger.LogLevel = settings.LogLevel;
                _renderer       = new ScoreRenderer(settings);
                _renderer.PartialRenderFinished += result => _main.PostMessage(new { cmd = "alphaTab.partialRenderFinished", result = result });
                _renderer.RenderFinished        += result => _main.PostMessage(new { cmd = "alphaTab.renderFinished", result = result });
                _renderer.PostRenderFinished    += () => _main.PostMessage(new { cmd = "alphaTab.postRenderFinished", boundsLookup = _renderer.BoundsLookup.ToJson() });
                _renderer.PreRender             += result => _main.PostMessage(new { cmd = "alphaTab.preRender", result = result });
                _renderer.Error += Error;
                break;

            case "alphaTab.invalidate":
                _renderer.Invalidate();
                break;

            case "alphaTab.resize":
                _renderer.Resize(data.width);
                break;

            case "alphaTab.render":
                var score = JsonConverter.JsObjectToScore(data.score, _renderer.Settings);
                RenderMultiple(score, data.trackIndexes);
                break;

            case "alphaTab.updateSettings":
                UpdateSettings(data.settings);
                break;
            }
        }