JsBlit.Content.LoadTextureAsync C# (CSharp) Method

LoadTextureAsync() private method

private LoadTextureAsync ( string uri, object token, ScriptObject completedDelegate ) : void
uri string
token object
completedDelegate ScriptObject
return void
        public void LoadTextureAsync(string uri, object token, ScriptObject completedDelegate)
        {
            BitmapImage bi = new BitmapImage();
            bi.ImageFailed += delegate(object sender, System.Windows.ExceptionRoutedEventArgs e)
            {
                completedDelegate.Invoke("loadTextureCompleted", -1, -1, -1, token, new Object());
            };
            bi.ImageOpened += delegate(object sender, System.Windows.RoutedEventArgs e)
            {
                Texture t = new Texture(bi);
                _textures[t.Id] = t;

                completedDelegate.Invoke("loadTextureCompleted", t.Id, t.Width, t.Height, token, null);
            };

            //Make sure we download the texture now, without it being part of the DOM
            bi.CreateOptions = BitmapCreateOptions.None;
            bi.UriSource = new Uri(uri, UriKind.Absolute);
        }