This class can convert a full Score instance to a simple JavaScript object and back for further JSON serialization.
コード例 #1
0
 private void HandleWorkerMessage(DOMEvent e)
 {
     var data = e.As<MessageEvent>().data;
     var cmd = data.Member("cmd").As<string>();
     switch (cmd)
     {
         case "preRender":
             OnPreRender();
             break;
         case "partialRenderFinished":
             OnPartialRenderFinished(data.Member("result").As<RenderFinishedEventArgs>());
             break;
         case "renderFinished":
             OnRenderFinished(data.Member("result").As<RenderFinishedEventArgs>());
             break;
         case "postRenderFinished":
             OnPostRenderFinished();
             break;
         case "error":
             console.error(data.Member("exception"));
             break;
         case "loaded":
             var score = data.Member("score").As<Score>();
             if (score.As<bool>())
             {
                 var jsonConverter = new JsonConverter();
                 score = jsonConverter.JsObjectToScore(score);
             }
             _workerApi.TriggerEvent("loaded", score);
             break;
     }
 }
コード例 #2
0
ファイル: JsWorkerApi.cs プロジェクト: CoderLine/alphaTab
 private void ScoreLoaded(Score score)
 {
     Score = score;
     var json = new JsonConverter();
     PostMessage(new { cmd = "loaded", score = json.ScoreToJsObject(score) });
     Render();
 }
コード例 #3
0
ファイル: JsWorkerApi.cs プロジェクト: eriser/alphaTab
        private void ScoreLoaded(Score score)
        {
            Score = score;
            if (_includeScoreInLoadedEvent)
            {
                var json = new JsonConverter();
                PostMessage(new { cmd = "loaded", score = json.ScoreToJsObject(score) });
            }
            else
            {
                PostMessage(new { cmd = "loaded" });
            }

            Render();
        }