public override void DoLayout() { base.DoLayout(); if (Index == 0) { Staff.TopSpacing = 5; Staff.BottomSpacing = 4; } Height = Resources.WordsFont.Size; var endingsStrings = new StringBuilder(); for (int i = 0, j = _endings.Count; i < j; i++) { endingsStrings.Append(_endings[i] + 1); endingsStrings.Append(". "); } _endingsString = endingsStrings.ToString(); }
public void NextToken() { var token = new StringBuilder(); int c; bool skipChar; // skip leading spaces and separators do { c = NextChar(); skipChar = Std.IsWhiteSpace(c) || c == 0x20; } while (!Eof && skipChar); // read token itself if (!Eof || !skipChar) { token.AppendChar(c); if (Std.IsCharNumber(c)) // do we have a number? { c = PeekChar(); // get first upcoming character while (!Eof && (Std.IsCharNumber(c, false) || c == 0x2E)) // while we have number characters add them { token.AppendChar(NextChar()); // peek next character for check c = PeekChar(); } } else { LastCommand = token.ToString(); } } CurrentToken = token.ToString(); }
public static void FillFromJson(Settings settings, dynamic json) { if (!json) return; if (Std.JsonExists(json, "scale")) settings.Scale = json.scale; if (Std.JsonExists(json, "width")) settings.Width = json.width; if (Std.JsonExists(json, "height")) settings.Height = json.height; if (Std.JsonExists(json, "engine")) settings.Engine = json.engine; if (Std.JsonExists(json, "stretchForce")) settings.StretchForce = json.stretchForce; if (Std.JsonExists(json, "forcePianoFingering")) settings.ForcePianoFingering = json.forcePianoFingering; if (Std.JsonExists(json, "atRoot")) { settings.ScriptFile = json.atRoot; // append script name if (!settings.ScriptFile.EndsWith(".js")) { if (!settings.ScriptFile.EndsWith("/")) { settings.ScriptFile += "/"; } settings.ScriptFile += "AlphaTab.js"; } if (!settings.ScriptFile.StartsWith("http") && !settings.ScriptFile.StartsWith("https")) { var root = new StringBuilder(); root.Append(HtmlContext.window.location.protocol); root.Append("//"); root.Append(HtmlContext.window.location.hostname); if (HtmlContext.window.location.port.As<bool>()) { root.Append(":"); root.Append(HtmlContext.window.location.port); } root.Append(settings.ScriptFile); settings.ScriptFile = root.ToString(); } } else { settings.ScriptFile = Environment.ScriptFile; } if (Std.JsonExists(json, "layout")) { if (JsContext.@typeof(json.layout) == "string") { settings.Layout.Mode = json.layout; } else { if (json.layout.mode) settings.Layout.Mode = json.layout.mode; if (json.layout.additionalSettings) { string[] keys = Std.JsonKeys(json.layout.additionalSettings); foreach (var key in keys) { settings.Layout.AdditionalSettings[key] = json.layout.additionalSettings[key]; } } } } if (Std.JsonExists(json, "staves")) { settings.Staves = new FastList<StaveSettings>(); string[] keys = Std.JsonKeys(json.staves); foreach (var key in keys) { var val = json.staves[key]; if (JsContext.@typeof(val) == "string") { settings.Staves.Add(new StaveSettings(val)); } else { if (val.id) { var staveSettings = new StaveSettings(val.id); if (val.additionalSettings) { string[] keys2 = Std.JsonKeys(val.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2] = val.additionalSettings[key2]; } } settings.Staves.Add(staveSettings); } } } } }
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(); } } }