void NotifyWebAppisHosted(string webAppVersionString)
{
WebAppVersion = webAppVersionString;
string jsResults;
using (var context = new AutoJSContext(_browser.Window.JSContext))
using (new JSAutoCompartment(context, (nsISupports)_browser.Window.DomWindow))
{
context.EvaluateScript("hostedAppSetup();", out jsResults);
}
//This loads the last saved program. We know at this point that everything should be working in Blockly.
if (!string.IsNullOrWhiteSpace(Settings.Default.SavedProgram))
{
string tempPath = IOPath.Combine(IOPath.GetTempPath(), IOPath.GetRandomFileName());
Directory.CreateDirectory(tempPath);
string tempLoadingFile = IOPath.Combine(tempPath, "temp_blocks.xml");
using (var file = File.OpenWrite(tempLoadingFile))
using (var sw = new StreamWriter(file))
{
sw.Write(Settings.Default.SavedProgram);
}
_tempPathsCreated.Add(tempPath);
string fileUri = "file://" + new FileInfo(tempLoadingFile).FullName;
using (var context = new AutoJSContext(_browser.Window.JSContext))
using (var compartment = new JSAutoCompartment(context, (nsISupports)_browser.Window.DomWindow))
{
string output;
context.EvaluateScript("load_by_url('" + fileUri.Replace("\\", "/") + "');", out output);
}
}
}