Пример #1
0
        static void PlatformInit()
        {
            RenderEngines["svg"]     = () => new FontSvgCanvas();
            RenderEngines["default"] = () => new FontSvgCanvas();
            RenderEngines["html5"]   = () => new Platform.JavaScript.Html5Canvas();
            FileLoaders["default"]   = () => new Platform.JavaScript.JsFileLoader();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();
                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement =
                                HtmlContext.document.querySelector("script[data-alphatab]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
Пример #2
0
        private static void PlatformInit()
        {
            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();

                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphasynth]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaSynth script file for worker, please add the data-alphasynth attribute to the script tag that includes alphaSynth or provide it when initializing alphaSynth");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
Пример #3
0
        static void PlatformInit()
        {
            RenderEngines["svg"] = () => new FontSvgCanvas();
            RenderEngines["default"] = () => new FontSvgCanvas();
            RenderEngines["html5"] = () => new Platform.JavaScript.Html5Canvas();
            FileLoaders["default"] = () => new Platform.JavaScript.JsFileLoader();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As<bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As<HtmlScriptElement>();

                if (!scriptElement.As<bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As<bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As<bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphatab]").As<HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As<bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
Пример #4
0
        private static void PlatformInit()
        {
            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As<bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As<HtmlScriptElement>();

                if (!scriptElement.As<bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As<bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As<bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphasynth]").As<HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (!string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As<bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaSynth script file for worker, please add the data-alphasynth attribute to the script tag that includes alphaSynth or provide it when initializing alphaSynth");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
Пример #5
0
        static void PlatformInit()
        {
            RenderEngines["svg"]     = () => new CssFontSvgCanvas();
            RenderEngines["default"] = () => new CssFontSvgCanvas();
            RenderEngines["html5"]   = () => new Platform.JavaScript.Html5Canvas();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                /**
                 * VB Loader For IE
                 * This code is based on the code of
                 *     http://nagoon97.com/reading-binary-files-using-ajax/
                 *     Copyright (c) 2008 Andy G.P. Na <*****@*****.**>
                 *     The source code is freely distributable under the terms of an MIT-style license.
                 */
                var vbAjaxLoader = new StringBuilder();
                vbAjaxLoader.AppendLine("<script type=\"text/vbscript\">");
                vbAjaxLoader.AppendLine("Function VbAjaxLoader(method, fileName)");
                vbAjaxLoader.AppendLine("    Dim xhr");
                vbAjaxLoader.AppendLine("    Set xhr = CreateObject(\"Microsoft.XMLHTTP\")");
                vbAjaxLoader.AppendLine("    xhr.Open method, fileName, False");
                vbAjaxLoader.AppendLine("    xhr.setRequestHeader \"Accept-Charset\", \"x-user-defined\"");
                vbAjaxLoader.AppendLine("    xhr.send");
                vbAjaxLoader.AppendLine("    Dim byteArray()");
                vbAjaxLoader.AppendLine("    if xhr.Status = 200 Then");
                vbAjaxLoader.AppendLine("        Dim byteString");
                vbAjaxLoader.AppendLine("        Dim i");
                vbAjaxLoader.AppendLine("        byteString=xhr.responseBody");
                vbAjaxLoader.AppendLine("        ReDim byteArray(LenB(byteString))");
                vbAjaxLoader.AppendLine("        For i = 1 To LenB(byteString)");
                vbAjaxLoader.AppendLine("            byteArray(i-1) = AscB(MidB(byteString, i, 1))");
                vbAjaxLoader.AppendLine("        Next");
                vbAjaxLoader.AppendLine("    End If");
                vbAjaxLoader.AppendLine("    VbAjaxLoader=byteArray");
                vbAjaxLoader.AppendLine("End Function");
                vbAjaxLoader.AppendLine("</script>");
                HtmlContext.document.write(vbAjaxLoader.ToString());

                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();
                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement =
                                HtmlContext.document.querySelector("script[data-alphatab]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }