AlphaTab.Collections.StringBuilder.AppendLine C# (CSharp) Méthode

AppendLine() public méthode

public AppendLine ( string s = "" ) : void
s string
Résultat void
        public void AppendLine(string s = "")
        {
            _sb.Append("s").Append("\r\n");
        }

Usage Example

Exemple #1
0
        static void PlatformInit()
        {
            RenderEngines["svg"]     = () => new CssFontSvgCanvas();
            RenderEngines["default"] = () => new CssFontSvgCanvas();
            RenderEngines["html5"]   = () => new Platform.JavaScript.Html5Canvas();

            RegisterJQueryPlugin();

            Script.Write("untyped __js__(\"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 (Lib.Global.document)
            {
                Script.Write("untyped __js__(\"window.AudioContext = window.AudioContext || window.webkitAudioContext;\");");

                var document = Browser.Document;

                /**
                 * 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("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");


                var vbAjaxLoaderScript = (ScriptElement)document.CreateElement("script");
                vbAjaxLoaderScript.SetAttribute("type", "text/vbscript");
                var inlineScript = document.CreateTextNode(vbAjaxLoader.ToString());
                vbAjaxLoaderScript.AppendChild(inlineScript);
                document.AddEventListener("DOMContentLoaded", new Action(() =>
                {
                    document.Body.AppendChild(vbAjaxLoaderScript);
                }), false);

                ScriptElement scriptElement = (ScriptElement)document.CurrentScript;
                if (!scriptElement.IsTruthy())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new Error();
                        var stack = error.Stack;
                        if (!stack.IsTruthy())
                        {
                            throw error;
                        }
                        ScriptFile = ScriptFileFromStack(stack);
                    }
                    catch (Error e)
                    {
                        var stack = e.Stack;
                        if (!stack.IsTruthy())
                        {
                            scriptElement = (ScriptElement)document.QuerySelector("script[data-alphatab]");
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack);
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.IsTruthy())
                    {
                        Logger.Warning("Environment", "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;
                    }
                }

                CheckForFontAvailability();
            }
            else
            {
                var isWebWorker = Script.Write <bool>("untyped __js__(\"typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope\")");
                if (isWebWorker)
                {
                    AlphaTabWebWorker.Init();
                    AlphaSynthWebWorker.Init();
                }
            }
        }