private async Task SetVisibleValue(TItem value)
        {
            if (string.IsNullOrEmpty(Format))
            {
                VisibleValue = value.ToString();
            }
            else
            {
                VisibleValue = Convert.ToDecimal(value).ToString(Format);
            }

            var additionalFormatting = string.Empty;

            if (ConditionalFormatting != null)
            {
                additionalFormatting = ConditionalFormatting(value);
            }

            ActiveClass = ComputeClass(additionalFormatting);

            var currentValue = await JsModule.InvokeAsync <string>("GetNumericTextBoxValue", new string[] { "#" + Id });

            if (currentValue != VisibleValue)
            {
                await JsModule.InvokeVoidAsync("SetNumericTextBoxValue", new string[] { "#" + Id, VisibleValue });
            }
        }
Esempio n. 2
0
        public Task <IEnumerable <MapSearchModel> > SearchAsync(string searchQuery)
        {
            searchCompletion = new TaskCompletionSource <IEnumerable <MapSearchModel> >();
            _ = module.InvokeVoidAsync("search", editor.Container, searchQuery);

            return(searchCompletion.Task);
        }
Esempio n. 3
0
 /// <summary>
 /// Hides the offcanvas (if opened).
 /// </summary>
 public async Task HideAsync()
 {
     if (!opened)
     {
         // this might be a minor PERF benefit, if it turns out to be causing troubles, we can remove this or make it configurable through optional method parameter
         return;
     }
     await jsModule.InvokeVoidAsync("hide", offcanvasElement);
 }
Esempio n. 4
0
        public async Task RegisterTransitionEndedAsync(ElementReference elementRef, Func <TransitionEventArgs, Task> onEndedCallback, string transitionPropertyName = "")
        {
            await CheckJsObjectAsync();

            var info      = new TransitionEventInfo(elementRef, onEndedCallback, transitionPropertyName);
            var dotnetRef = DotNetObjectReference.Create <TransitionEventInfo>(info);

            _dotNetObjectReferences.Add(dotnetRef);
            await _transitionJs.InvokeVoidAsync("addTransitionEnd", elementRef, dotnetRef, transitionPropertyName);
        }
Esempio n. 5
0
        public async Task RegisterClickBoundariesAsync(ElementReference elementRef,
                                                       Func <MouseEventArgs, Task> outsideClickCallback = null,
                                                       Func <MouseEventArgs, Task> insideClickCallback  = null)
        {
            await CheckJsObjectAsync();

            var info      = new ClickBoundariesEventInfo(outsideClickCallback, insideClickCallback);
            var dotnetRef = DotNetObjectReference.Create <ClickBoundariesEventInfo>(info);

            await _clickJs.InvokeVoidAsync("addClickBoundariesHandler", elementRef, dotnetRef);

            _registeredElements.Add(elementRef);
        }
Esempio n. 6
0
        /// <inheritdoc/>
        public async Task InitializeAsync()
        {
            if (isInitialized)
            {
                return;
            }

            jsModule ??= await jsRuntime.InvokeAsync <IJSObjectReference>("import", "./_content/Havit.Blazor.GoogleTagManager/" + nameof(HxGoogleTagManager) + ".js");

            await jsModule.InvokeVoidAsync("initialize", gtmOptions.GtmId);

            isInitialized = true;
        }
Esempio n. 7
0
        /// <inheritdoc />
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && !initialized)
            {
                await EnsureJsModuleAsync();

                await jsModule.InvokeVoidAsync("initialize", scrollspyElement, TargetId);

                initialized = true;
            }
        }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            jsModule ??= await JSRuntime.ImportHavitBlazorBootstrapModuleAsync(nameof(HxInputDateRange));

            bool fromValid = !EditContext.GetValidationMessages(FieldIdentifier).Any() && !EditContext.GetValidationMessages(fromFieldIdentifier).Any();
            bool toValid   = !EditContext.GetValidationMessages(FieldIdentifier).Any() && !EditContext.GetValidationMessages(toFieldIdentifier).Any();

            // TODO PERF Combine into single JS call?
            await jsModule.InvokeVoidAsync(fromValid? "setInputValid" : "setInputInvalid", fromInputElement);

            await jsModule.InvokeVoidAsync(toValid? "setInputValid" : "setInputInvalid", toInputElement);
        }
Esempio n. 9
0
        public async Task GetCurrentPositionAsync(Func <GeolocationResult, Task> locationResultCallback, bool highAccuracy, TimeSpan?timeout, TimeSpan?cacheTime)
        {
            await CheckJsObjectAsync();

            var info      = new GeolocationEventCurrentPositionInfo(locationResultCallback);
            var dotnetRef = DotNetObjectReference.Create <GeolocationEventCurrentPositionInfo>(info);

            info.DotNetObjectReference = dotnetRef;             //Store ref to self dispose.

            await _geoJs.InvokeVoidAsync("getCurrentPosition", dotnetRef,
                                         highAccuracy,
                                         timeout?.TotalMilliseconds ?? DefaultTimeOut,
                                         cacheTime?.TotalMilliseconds ?? DefaultCacheTime);
        }
Esempio n. 10
0
        /// <summary>
        /// Initiates the upload (does not wait for upload completion). Use OnUploadCompleted event.
        /// </summary>
        /// <param name="accessToken">Authorization Bearer Token to be used for upload (i.e. use IAccessTokenProvider).</param>
        /// <remarks>
        /// We do not want to make the Havit.Blazor library dependant on WebAssembly libraries (IAccessTokenProvider and such). Therefor the accessToken here...
        /// </remarks>
        public async Task StartUploadAsync(string accessToken = null)
        {
            Contract.Requires <ArgumentException>(!String.IsNullOrWhiteSpace(UploadUrl), nameof(UploadUrl) + " has to be set.");

            await EnsureJsModuleAsync();

            filesUploaded = new ConcurrentBag <FileUploadedEventArgs>();

            if (disposed)
            {
                return;
            }
            await jsModule.InvokeVoidAsync("upload", Id, dotnetObjectReference, UploadUrl, accessToken, MaxFileSizeEffective == long.MaxValue?null : MaxFileSizeEffective, MaxParallelUploadsEffective);
        }
Esempio n. 11
0
        /// <inheritdoc />
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                jsModule ??= await JSRuntime.ImportHavitBlazorBootstrapModuleAsync(nameof(HxToast));

                if (disposed)
                {
                    return;
                }
                await jsModule.InvokeVoidAsync("show", toastElement, dotnetObjectReference);
            }
        }
Esempio n. 12
0
        /// <inheritdoc cref="ComponentBase.OnAfterRenderAsync(bool)" />
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                await EnsureJsModuleAsync();

                if (disposed)
                {
                    return;
                }
                await jsModule.InvokeVoidAsync("initialize", collapseHtmlElement, dotnetObjectReference);
            }
        }
Esempio n. 13
0
        public async Task RegisterAnimationsWhenAllEndedAsync(Func <AnimationEventArgs[], Task> onEndedCallback, params KeyValuePair <ElementReference, string>[] elementRefsWithProperties)
        {
            await CheckJsObjectAsync();

            var collection = new AnimationCollectionInfo(onEndedCallback);

            foreach (var item in elementRefsWithProperties)
            {
                var info = new AnimationEventInfo(item.Key, collection.WhenAllFinished, item.Value);
                collection.Add(info);
                var dotnetRef = DotNetObjectReference.Create <AnimationEventInfo>(info);
                _registeredEndEvents.Add(dotnetRef);

                await _animationJs.InvokeVoidAsync("addAnimationEnd", item.Key, dotnetRef, item.Value);
            }
        }
Esempio n. 14
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;
                }
            }
        }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                mediaQueryJs = await Js.InvokeAsync<IJSObjectReference>(
                    "import",
                    "./_content/BlazorPro.BlazorSize/blazorSizeMediaModule.js"
                    );

                DotNetInstance = DotNetObjectReference.Create(this);
                var result = mediaQueryJs.InvokeVoidAsync("addMediaQueryList", DotNetInstance);
                await result;
                // Because MediaQueries are added by the child component before IJSObjectReference completes.
                // We must cache the MediaQueries and load them after the JS module is imported.
                // On additional renders the module is already available and child components can self initialize.
                await InitializeCachedMediaQueries();
            }
            await base.OnAfterRenderAsync(firstRender);

            async Task InitializeCachedMediaQueries()
            {
                foreach (var item in mediaQueries)
                {
                    foreach (var mq in item.MediaQueries)
                    {
                        await Initialize(mq);
                    }
                }
            }
        }
Esempio n. 16
0
        /// <inheritdoc cref="ComponentBase.OnAfterRenderAsync(bool)" />
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                await EnsureJsModuleAsync();

                if (disposed)
                {
                    return;
                }
                await jsModule.InvokeVoidAsync("create", collapseHtmlElement, dotnetObjectReference, "#" + ParentAccordition.Id);
            }

            isInitialized = true;
        }
Esempio n. 17
0
        protected override async Task OnInitializedAsync()
        {
            Module = await JS.InvokeAsync <IJSObjectReference>("import", "./js/Utilitario.js");

            await Task.Delay(2000);

            await Module.InvokeVoidAsync("Obtener", DotNetObjectReference.Create(this));
        }
Esempio n. 18
0
        public async Task InitializeAsync(FileUpload editor, string bearerToken)
        {
            Editor = editor;

            module = await js.InvokeAsync <IJSObjectReference>("import", "./_content/Recollections.Blazor.Components/FileUpload.js");

            await module.InvokeVoidAsync("initialize", DotNetObjectReference.Create(this), editor.FormElement, bearerToken, editor.DragAndDropContainer);
        }
Esempio n. 19
0
 public async ValueTask OnCallback(
     DotNetObjectReference<Evented> eventedClass,
     IJSObjectReference evented, 
     string eventType)
 {
     IJSObjectReference module = await moduleTask.Value;
     await module.InvokeVoidAsync(onCallback, eventedClass, evented, eventType);
 }
Esempio n. 20
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         _pwaModule = await PwaModule;
         _objectRef = DotNetObjectReference.Create((MainLayout)this);
         await _pwaModule.InvokeVoidAsync("setLayoutRef", _objectRef);
     }
 }
Esempio n. 21
0
        public async Task ScrollToAnchorAsync(string anchor)
        {
            if (!String.IsNullOrEmpty(anchor))
            {
                jsModule ??= await JSRuntime.ImportHavitBlazorBootstrapModuleAsync(nameof(HxAnchorFragmentNavigation));

                await jsModule.InvokeVoidAsync("scrollToAnchor", anchor);
            }
        }
Esempio n. 22
0
 public async ValueTask DisposeAsync()
 {
     if (jsModule is null || buttonElement is null)
     {
         return;
     }
     await jsModule.InvokeVoidAsync("preventDefaultKeyBehaviorOnKeys", buttonElement.AsElementReference(), new List <string> {
     }, false);
 }
Esempio n. 23
0
        public static ValueTask LogConsole(IJSObjectReference jSObjectReference, string message, LogLevel logLevel)
        {
            if (jSObjectReference != null)
            {
                return(jSObjectReference.InvokeVoidAsync("consoleLogger", message, logLevel));
            }

            return(ValueTask.CompletedTask);
        }
 public async ValueTask DisposeAsync()
 {
     if (DotNetInstance != null)
     {
         await mediaQueryJs.InvokeVoidAsync("removeMediaQueryList", DotNetInstance);
         DotNetInstance.Dispose();
         DotNetInstance = null;
     }
 }
Esempio n. 25
0
        public async Task Print(PrintOptions options)
        {
            if (module is null)
            {
                await ImportModule();
            }

            await module.InvokeVoidAsync("print", new PrintOptionsAdapter(options));
        }
Esempio n. 26
0
        public async Task InitializedAsync(Gallery component, List <GalleryModel> models)
        {
            Ensure.NotNull(component, "component");
            this.component = component;

            module = await js.InvokeAsync <IJSObjectReference>("import", "./_content/Recollections.Blazor.Components/Gallery.js");

            await module.InvokeVoidAsync("initialize", DotNetObjectReference.Create(this), models);
        }
Esempio n. 27
0
        /// <summary>
        /// Ereignisbehandlung: Benutzer löscht Aufgabe
        /// </summary>
        public async System.Threading.Tasks.Task RemoveTask(BO.Task t)
        {
            IJSObjectReference skript = await js.InvokeAsync <IJSObjectReference>("import", "/_content/MiracleListRCL/JSUtil.js");

            // Rückfrage (Standard-Browser-Dialog via JS!)
            //if (!await js.InvokeAsync<bool>("confirmWithLog", "Remove Task #" + t.TaskID + ": " + t.Title + "?", true)) return;

            // Rückfrage (Bootstrap-Dialog via JS!)
            obj = DotNetObjectReference.Create(this);
            await skript.InvokeVoidAsync("confirmBootstrap", obj, t.TaskID, "Remove this Task?<br><br><b>#" + t.TaskID + ": " + t.Title, true);
        }
        public async Task IncrementCount()
        {
            modulo = await JS.InvokeAsync <IJSObjectReference>("import", "./js/Counter.js");

            await modulo.InvokeVoidAsync("mostrarAlerta", "Hola Mundo");

            currentCount++;

            currentCountStatic++;
            await JS.InvokeVoidAsync("pruebaPuntoNetStatic");
        }
Esempio n. 29
0
        public async Task IncrementCount()
        {
            module = await js.InvokeAsync <IJSObjectReference>("import", "./js/Counter.js");

            await module.InvokeVoidAsync("displayAlert", "hello world");

            currentCount++;
            singleton.Value += 1;
            transient.Value += 1;
            currentCountStatic++;
            await js.InvokeVoidAsync("dotnetStaticInvocation");
        }
Esempio n. 30
0
 protected async Task InstallClicked()
 {
     SfToastObjRef?.Hide();
     try
     {
         await _pwaModule.InvokeVoidAsync("installPWA");
     }
     catch (Exception e)
     {
         Log.Logger.Error(e, nameof(InstallClicked));
     }
 }