public EsriSerializer() { serializer = new XMLSerializerClass(); }
private void Preload() { var loading = "loading".AttachToDocument(); loading.style.fontFamily = IStyle.FontFamilyEnum.Consolas; var ToBeLoaded = 0; var AlreadyLoaded = 0; Action refresh = delegate { }; Action<IHTMLImage> LoadImage = img => { ToBeLoaded++; refresh(); img.InvokeOnComplete( delegate { AlreadyLoaded++; refresh(); } ); }; // load me an imp //LoadImage("assets/NatureBoy/alpha/2.png"); //LoadImage("assets/NatureBoy/alpha/power.png"); //LoadImage("assets/NatureBoy/alpha/green-ring.png"); //LoadImage("assets/NatureBoy/alpha/yellow-ring-50.png"); var dude = new DudeAnimationInfo { Frames_Stand = Frames.DoomImp, Frames_Walk = Frames.DoomImp_Walk }; dude.Images.ForEach(LoadImage); var scene = "LostInTime.xml"; Action<Scene.Document> SceneDownloaded = delegate { }; Action ResetImageLoader = delegate { refresh = delegate { }; ToBeLoaded = 0; AlreadyLoaded = 0; }; Func<Action, Action> CreateImageLoader = done => delegate { if (ToBeLoaded == AlreadyLoaded) { if (ToBeLoaded > 0) { ResetImageLoader(); done(); return; } } loading.innerText = "loading: " + AlreadyLoaded + " images of " + ToBeLoaded + " loaded"; }; refresh += CreateImageLoader( delegate { loading.innerText = "loading: " + scene; ImpAdventures.Data.LostInTime.Create( e => { Console.WriteLine(e.Document.ToString()); var s = new IXMLSerializer<Scene.Document>(Scene.Settings.KnownTypes); var doc = s.Deserialize(e.Document.AsIXMLDocument()); SceneDownloaded(doc); } ); } ); SceneDownloaded = doc => { //loading.innerText = "loading: done"; //doc.Frames.ForEach( // f => // { // LoadImage(f.Image.Source); // } //); new ImpAdventures.HTML.Pages.LostInTimeImages().Images.ForEach(LoadImage); refresh += CreateImageLoader( delegate { loading.Hide(); // now we have an imp, the xml file, and all the frames we need Spawn(dude, doc); } ); refresh(); }; refresh(); }
private void Preload() { var loading = "loading".AttachToDocument(); loading.style.fontFamily = IStyle.FontFamilyEnum.Consolas; var ToBeLoaded = 0; var AlreadyLoaded = 0; Action refresh = delegate { }; Action <IHTMLImage> LoadImage = img => { ToBeLoaded++; refresh(); img.InvokeOnComplete( delegate { AlreadyLoaded++; refresh(); } ); }; // load me an imp //LoadImage("assets/NatureBoy/alpha/2.png"); //LoadImage("assets/NatureBoy/alpha/power.png"); //LoadImage("assets/NatureBoy/alpha/green-ring.png"); //LoadImage("assets/NatureBoy/alpha/yellow-ring-50.png"); var dude = new DudeAnimationInfo { Frames_Stand = Frames.DoomImp, Frames_Walk = Frames.DoomImp_Walk }; dude.Images.ForEach(LoadImage); var scene = "LostInTime.xml"; Action <Scene.Document> SceneDownloaded = delegate { }; Action ResetImageLoader = delegate { refresh = delegate { }; ToBeLoaded = 0; AlreadyLoaded = 0; }; Func <Action, Action> CreateImageLoader = done => delegate { if (ToBeLoaded == AlreadyLoaded) { if (ToBeLoaded > 0) { ResetImageLoader(); done(); return; } } loading.innerText = "loading: " + AlreadyLoaded + " images of " + ToBeLoaded + " loaded"; }; refresh += CreateImageLoader( delegate { loading.innerText = "loading: " + scene; ImpAdventures.Data.LostInTime.Create( e => { Console.WriteLine(e.Document.ToString()); var s = new IXMLSerializer <Scene.Document>(Scene.Settings.KnownTypes); var doc = s.Deserialize(e.Document.AsIXMLDocument()); SceneDownloaded(doc); } ); } ); SceneDownloaded = doc => { //loading.innerText = "loading: done"; //doc.Frames.ForEach( // f => // { // LoadImage(f.Image.Source); // } //); new ImpAdventures.HTML.Pages.LostInTimeImages().Images.ForEach(LoadImage); refresh += CreateImageLoader( delegate { loading.Hide(); // now we have an imp, the xml file, and all the frames we need Spawn(dude, doc); } ); refresh(); }; refresh(); }
public EsriSerializer() { serializer = new XMLSerializerClass(); }