Example #1
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                try
                {
                    if (IsWebAssembley)
                    {
                        module = await _jsInProcessRuntime.InvokeAsync <IJSInProcessObjectReference>("import", "./Scripts/BasicCanvas.js");

                        module.InvokeVoid("initializeBasicCanvas", CanvasId, IsWebAssembley, IsTransparent, IsDesyncronized);
                    }
                    else
                    {
                        asyncModule = await JS_Runtime.InvokeAsync <IJSObjectReference>("import", "./Scripts/BasicCanvas.js");

                        await asyncModule.InvokeVoidAsync("initializeBasicCanvas", CanvasId, IsWebAssembley, IsTransparent, IsDesyncronized);
                    }

                    if (CanvasInitComplete != null)
                    {
                        CanvasInitComplete(this);
                    }
                }
                catch (Exception ex)
                {
                    var crap = ex.Message;
                }
            }
        }
Example #2
0
        private async void InitConfig(NeuralNetworkOptions options, bool isCallBack = true)
        {
            DotNet      = DotNetObjectReference.Create(this);
            JSReference = await Runtime.InvokeAsync <IJSInProcessObjectReference>("import", "./_content/BlazorML5/ml5NeuralNetwork.js");

            JSReference.InvokeVoid("createNNConfigML5", Hash, options, isCallBack, DotNet);
        }
Example #3
0
 public OsmMarker(
     string markerId,
     IJSInProcessObjectReference jsModule,
     Hooks hooks) : base(markerId, jsModule)
 {
     _hooks = hooks ?? new Hooks();
 }
Example #4
0
        /// <summary>
        /// This Initializes the IJSRuntime ,dependencies automatically , fetches required Scripts, It should be Called First
        /// </summary>
        /// <param name="runtime">Reference to IJSRuntime , use @inject IJSRuntime Runtime to obtain one from Razor Page</param>
        /// <param name="cdnURL">An updated CDN Version URL , can be null</param>
        /// <returns>a Task that must be awaited..</returns>
        public static async Task Init([NotNull] IJSRuntime runtime, string cdnURL = null)
        {
            Runtime = runtime;

            if (Runtime == null)
            {
                throw new ArgumentNullException(paramName: nameof(runtime), message: "runtime parameter can't be null");
            }

            cdnURL ??= "https://unpkg.com/@ffmpeg/[email protected]/dist/ffmpeg.min.js";

            await Runtime.InvokeVoidAsync("import", cdnURL);

            await Runtime.InvokeVoidAsync("import", "./_content/FFmpegBlazor/blazorFfmpeg.js");


            dotNetObjectReference = DotNetObjectReference.Create(new FFmpegFactory());

            reference = ((IJSUnmarshalledRuntime)Runtime)
                        .InvokeUnmarshalled <IJSUnmarshalledObjectReference>("FfmpegBlazorReference");


            processReference = await((IJSInProcessRuntime)Runtime)
                               .InvokeAsync <IJSInProcessObjectReference>("FfmpegBlazorReference");
        }
Example #5
0
        private async void Init(int inputs, int outputs)
        {
            DotNet      = DotNetObjectReference.Create(this);
            JSReference = await Runtime.InvokeAsync <IJSInProcessObjectReference>("import", "./_content/BlazorML5/ml5NeuralNetwork.js");

            JSReference.InvokeVoid("createNNML5", Hash, inputs, outputs, DotNet);
        }
Example #6
0
        private async void Init(string model, object opt = null)
        {
            Hash        = Helper.UIDGenerator();
            DotNet      = DotNetObjectReference.Create(this);
            JSReference = await Runtime.InvokeAsync <IJSInProcessObjectReference>("import", "./_content/BlazorML5/ml5ObjectDetector.js");

            JSReference.InvokeVoid("initObjectDetectorML5", Hash, DotNet, model, opt);
        }
        /// <summary>
        /// Invokes the specified JavaScript function synchronously.
        /// </summary>
        /// <param name="jsObjectReference">The <see cref="IJSInProcessObjectReference"/>.</param>
        /// <param name="identifier">An identifier for the function to invoke. For example, the value <c>"someScope.someFunction"</c> will invoke the function <c>someScope.someFunction</c> on the target instance.</param>
        /// <param name="args">JSON-serializable arguments.</param>
        public static void InvokeVoid(this IJSInProcessObjectReference jsObjectReference, string identifier, params object?[] args)
        {
            if (jsObjectReference == null)
            {
                throw new ArgumentNullException(nameof(jsObjectReference));
            }

            jsObjectReference.Invoke <object>(identifier, args);
        }
Example #8
0
        private async void Init(IJSInProcessRuntime runtime, ElementReference?element, PoseNetOptions options, DetectionType?type)
        {
            Runtime         = runtime;
            DotNetObjectRef = DotNetObjectReference.Create(this);
            JSReference     = await Runtime.InvokeAsync <IJSInProcessObjectReference>("import", "./_content/BlazorML5/ml5PoseNet.js");

            Hash = PoseNetHash++;
            JSReference.InvokeVoid("poseNetML5", Hash.ToString(), DotNetObjectRef, element, options, type);
        }
Example #9
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                functionsModule = await JS.InvokeAsync <IJSInProcessObjectReference>("import", "./_content/Vidazor/functions.min.js");

                foreach (var e in events)
                {
                    SubscribeToEvent(e.Key);
                }
            }
        }
Example #10
0
 public static string InvokeDisposedJSObjectReferenceException(IJSInProcessObjectReference jsObjectReference)
 {
     try
     {
         jsObjectReference.Invoke <object>("noop");
         return("No exception thrown");
     }
     catch (JSException e)
     {
         return(e.Message);
     }
 }
Example #11
0
 public JSStorageFolder(IJSInProcessObjectReference fileHandle) : base(fileHandle)
 {
 }
 public Attachment(IJSInProcessObjectReference native, IPlatformHandle handle)
 {
     _native = native;
     _native.InvokeVoid(InitializeWithChildHandleSymbol, ((JSObjectControlHandle)handle).Object);
 }
Example #13
0
 protected MarkerBase(string markerId, IJSInProcessObjectReference jsModule) : base(jsModule)
 {
     _jsCallback     = new MarkerJsCallback(this.Push);
     this.JsCallback = DotNetObjectReference.Create(_jsCallback);
     this.MarkerId   = markerId;
 }
Example #14
0
 protected ApiBaseObject(IJSInProcessObjectReference jsModule) : base(jsModule)
 {
     this.SelfRef = DotNetObjectReference.Create((T)this);
 }
Example #15
0
 protected JSStorageItem(IJSInProcessObjectReference fileHandle)
 {
     _fileHandle = fileHandle ?? throw new ArgumentNullException(nameof(fileHandle));
 }
Example #16
0
 protected MapBase(string mapId, IJSInProcessObjectReference jsModule) : base(jsModule)
 {
     this.MapId         = mapId;
     _mapJsCallback     = new MapJsCallback(this.Push);
     this.MapJsCallback = DotNetObjectReference.Create(_mapJsCallback);
 }
Example #17
0
 internal JSWriteableStream(IJSInProcessObjectReference jSReference, long initialLength)
 {
     _jSReference = jSReference;
     _length      = initialLength;
 }