Esempio n. 1
0
 internal Gamepad(JSInvoker jsInvoker, string id, int index, bool connected)
 {
     this.JSInvoker  = jsInvoker;
     this.Id         = id;
     this.Index      = index;
     this._Connected = connected;
 }
Esempio n. 2
0
        private async ValueTask <JSInvoker> GetJSInvokerAsync()
        {
            if (this.JSInvoker != null)
            {
                return(this.JSInvoker);
            }

            await this.Syncer.WaitAsync();

            try
            {
                if (this.JSInvoker != null)
                {
                    return(this.JSInvoker);
                }

                var version = this.GetVersionText();
#if ENABLE_JSMODULE
                if (!this.Options.DisableClientScriptAutoInjection)
                {
                    var scriptPath = $"./_content/Toolbelt.Blazor.Gamepad/script.module.min.js?v={version}";
                    this.JSModule = await this.JSRuntime.InvokeAsync <IJSObjectReference>("import", scriptPath);

                    this.JSInvoker = new JSInvoker(this.JSRuntime, this.JSModule);
                }
                else
                {
                    try { await this.JSRuntime.InvokeVoidAsync("Toolbelt.Blazor.Gamepad.ready"); } catch { }
                    this.JSInvoker = new JSInvoker(this.JSRuntime, null);
                }
#else
                if (!this.Options.DisableClientScriptAutoInjection)
                {
                    const string scriptPath = "_content/Toolbelt.Blazor.Gamepad/script.min.js";
                    await this.JSRuntime.InvokeVoidAsync("eval", "new Promise(r=>((d,t,s,v)=>(h=>h.querySelector(t+`[src^=\"${s}\"]`)?r():(e=>(e.src=(s+v),e.onload=r,h.appendChild(e)))(d.createElement(t)))(d.head))(document,'script','" + scriptPath + "','?v=" + version + "'))");
                }
                try { await this.JSRuntime.InvokeVoidAsync("Toolbelt.Blazor.Gamepad.ready"); } catch { }
                this.JSInvoker = this.JSRuntime;
#endif
            }
            catch (Exception) { }
            finally { this.Syncer.Release(); }

            return(this.JSInvoker);
        }
 public ClientStorageService(Microsoft.JSInterop.IJSRuntime JSRuntimeContext)
 {
     this.JSRuntime          = JSRuntimeContext;
     this.JSInProcessRuntime = JSRuntimeContext as Microsoft.JSInterop.IJSInProcessRuntime;
 }
Esempio n. 4
0
 /// <summary>
 /// Should this be called in the property set of the model?
 /// </summary>
 /// <param name="jSRuntime"></param>
 /// <param name="categories"></param>
 /// <returns></returns>
 public static void SetCategories(this Microsoft.JSInterop.IJSRuntime jSRuntime, string[] categories)
 {
     jSRuntime.InvokeAsync <string>("SetCategories", new object[] { categories });
 }
Esempio n. 5
0
 public static async Task <string> ConfirmAsync(this Microsoft.JSInterop.IJSRuntime jSRuntime, string message)
 {
     return(await jSRuntime.InvokeAsync <string>("Confirm", new object[] { message }));
 }
Esempio n. 6
0
 public DocumentService(HttpClient httpClient, IJSRuntime js)
 {
     this.httpClient = httpClient;
     this.JS         = js;
 }
Esempio n. 7
0
 public ExampleJsInterop(Microsoft.JSInterop.IJSRuntime jsRuntime)
 {
     moduleTask =
         new(() => jsRuntime.InvokeAsync <Microsoft.JSInterop.IJSObjectReference>
                 ("import", "./_content/Dtx.Razor/exampleJsInterop.js").AsTask());
 }
Esempio n. 8
0
 public RenderingContext(ElementReference refCanv, IJSRuntime js)
 {
     Canvas     = refCanv;
     _jsRuntime = js;
 }
 public async static Task <bool> Confirm(this Microsoft.JSInterop.IJSRuntime js, string titulo, string mensaje, TipoMensajeSweetAlert tipoMensajeSweetAlert)
 {
     return(await js.InvokeAsync <bool>("CustomConfirm", titulo, mensaje, tipoMensajeSweetAlert.ToString()));
 }
Esempio n. 10
0
 public static Task MostrarMensaje(this Microsoft.JSInterop.IJSRuntime js, string titulo, string mensaje, TipoMensajeSweetAlert tipoMensajeSweetAlert)
 {
     return(js.InvokeAsync <object>("Swal.fire", titulo, mensaje, tipoMensajeSweetAlert.ToString()));
 }
Esempio n. 11
0
 public static Task MostrarMensaje(this Microsoft.JSInterop.IJSRuntime js, string mensaje)
 {
     return(js.InvokeAsync <object>("Swal.fire", mensaje));
 }
Esempio n. 12
0
 public static Task GuadarComo(this Microsoft.JSInterop.IJSRuntime js, string nombreArchivo, byte[] archivo)
 {
     return(js.InvokeAsync <object>("saveAsFile",
                                    nombreArchivo,
                                    Convert.ToBase64String(archivo)));
 }