Example #1
0
 /// <summary>
 /// OnAfterRenderAsync 方法
 /// </summary>
 /// <param name="firstRender"></param>
 /// <returns></returns>
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender && JSRuntime != null)
     {
         Interop = new JSInterop <BarcodeReader>(JSRuntime);
         await Interop.Invoke(this, ScannerElement, "bb_barcode", "init");
     }
 }
 /// <summary>
 /// Dispose 方法
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && Interop != null)
     {
         Interop.Dispose();
         Interop = null;
     }
 }
 private async Task Generate()
 {
     if (Interop == null)
     {
         Interop = new JSInterop <QRCode>(JSRuntime);
     }
     await Interop.Invoke(this, QRCodeElement, "bb_qrcode", "generate");
 }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <MultiSelect <TValue> >(JSRuntime);
                await Interop.Invoke(this, SelectElement, "bb_multi_select", nameof(Close));
            }
        }
Example #5
0
        /// <summary>
        /// Dispose 方法
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                Interop?.Dispose();
                Interop = null;
            }
        }
Example #6
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <ModalDialog>(JSRuntime);
                await Interop.InvokeVoidAsync(this, DialogElement, "bb_modal_dialog", nameof(Close));
            }
        }
        /// <summary>
        /// 重置组件方法
        /// </summary>
        protected override void Reset()
        {
            var option = GetCaptchaOption();

            if (Interop == null)
            {
                Interop = new JSInterop <CaptchaBase>(JSRuntime);
            }
            Interop?.Invoke(this, CaptchaElement, "captcha", nameof(Verify), option);
        }
Example #8
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <Slider>(JSRuntime);
                await Interop.InvokeVoidAsync(this, SliderElement, "bb_slider", nameof(SetValue));
            }
        }
Example #9
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <TableFilter>(JSRuntime);
                await Interop.InvokeVoidAsync(this, FilterElement, "bb_filter", nameof(Close));
            }
        }
Example #10
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender && JSRuntime != null)
            {
                Interop = new JSInterop <SliderBase>(JSRuntime);
                Interop.Invoke(this, Slider, "slider", nameof(SliderBase.SetValue));
            }
        }
Example #11
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <SliderBase>(JSRuntime);
                await Interop.Invoke(this, Slider, "slider", nameof(SliderBase.SetValue));
            }
        }
Example #12
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <ModalDialog>(JSRuntime);
                await Interop.Invoke(this, DialogElement, "bb_dialog", "init");
            }
        }
Example #13
0
        /// <summary>
        /// 重置组件方法
        /// </summary>
        public void Reset()
        {
            var option = GetCaptchaOption();

            if (Interop == null)
            {
                Interop = new JSInterop <CaptchaBase>(JSRuntime);
            }
            Interop?.Invoke(this, Captcha, "captcha", nameof(Verify), option);
        }
Example #14
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && Message != null)
            {
                _interop = new JSInterop <MessageBase>(JSRuntime);
                await _interop.Invoke(Message, MessageItemElement, "showMessage", nameof(MessageBase.Clear));
            }
        }
Example #15
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <Layout>(JSRuntime);
                await Interop.InvokeVoidAsync(this, null, "bb_layout", nameof(SetCollapsed));
            }
        }
Example #16
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && JSRuntime != null)
            {
                Interop = new JSInterop <Camera>(JSRuntime);
                await Interop.Invoke(this, CameraElement, "bb_camera", "init");
            }
        }
Example #17
0
        /// <summary>
        /// 重置组件方法
        /// </summary>
        public override void Reset()
        {
            var option = GetCaptchaOption();

            if (Interop == null)
            {
                Interop = new JSInterop <Captcha>(JSRuntime);
            }

            var _ = Interop?.InvokeVoidAsync(this, CaptchaElement, "captcha", nameof(Verify), option);
        }
Example #18
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (Interop == null && JSRuntime != null)
                {
                    Interop = new JSInterop <RateBase>(JSRuntime);
                }
                Interop?.Invoke(this, RateElement, "rate", nameof(Clicked));
            }
        }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (Interop == null)
                {
                    Interop = new JSInterop <Select <TValue> >(JSRuntime);
                }
                await Interop.Invoke(this, SelectElement, "bb_select", nameof(ConfirmSelectedItem));
            }
        }
Example #20
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender)
            {
                if (Interop == null && JSRuntime != null)
                {
                    Interop = new JSInterop <UploadBase>(JSRuntime);
                }
                Interop?.Invoke(this, UploaderElement, "uploader", nameof(Completed), nameof(CheckFiles), nameof(Removed), nameof(Failed));
            }
        }
Example #21
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            // 执行客户端动画
            if (firstRender && JSRuntime != null)
            {
                if (Toast != null && !string.IsNullOrEmpty(Id))
                {
                    _interop = new JSInterop <Toast>(JSRuntime);
                    await _interop.Invoke(Toast, Id, "showToast", nameof(ToastBase.Clear));
                }
            }
        }
Example #22
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            // 执行客户端动画
            if (firstRender)
            {
                if (Toast != null)
                {
                    Interop = new JSInterop <Toast>(JSRuntime);
                    await Interop.Invoke(Toast, ToastBoxElement, "showToast", nameof(Toast.Clear));
                }
            }
        }
Example #23
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender)
            {
                if (OnInit == null) throw new InvalidOperationException("OnInit paramenter must be set");

                if (Interop == null) Interop = new JSInterop<Chart>(JSRuntime);

                var ds = await OnInit.Invoke();

                await Interop.InvokeVoidAsync(this, ChartElement, "chart", nameof(Completed), ds, "", ChartType.ToDescriptionString());
            }
        }
Example #24
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interope = new JSInterop <Editor>(JSRuntime);
                await Interope.Invoke(this, EditorElement, "editor", nameof(Update), Height, Value ?? "");
            }
            if (_renderValue)
            {
                _renderValue = false;
                await JSRuntime.InvokeVoidAsync(EditorElement, "editor", "code", "", "", Value ?? "");
            }
        }
Example #25
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (Interop == null)
                {
                    Interop = new JSInterop <UploadBase>(JSRuntime);
                }
                if (Interop != null)
                {
                    await Interop.Invoke(this, UploaderElement, "uploader", nameof(Completed), nameof(CheckFiles), nameof(Removed), nameof(Failed), nameof(SetHeaders));
                }
            }
        }
Example #26
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (Interop == null)
                {
                    Interop = new JSInterop <Rate>(JSRuntime);
                }
                if (Interop != null)
                {
                    await Interop.Invoke(this, RateElement, "bb_rate", nameof(Clicked));
                }
            }
        }
Example #27
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (Interop == null)
                {
                    Interop = new JSInterop <Select <TValue> >(JSRuntime);
                }
                await Interop.InvokeVoidAsync(this, SelectElement, "bb_select", nameof(ConfirmSelectedItem));

                // 选项值不为 null 后者 string.Empty 时触发一次 OnSelectedItemChanged 回调
                if (SelectedItem != null && OnSelectedItemChanged != null && !string.IsNullOrEmpty(SelectedItem.Value))
                {
                    await OnSelectedItemChanged.Invoke(SelectedItem);
                }
            }
        }
Example #28
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interope = new JSInterop <Editor>(JSRuntime);
                var methodGetPluginAttrs  = "";
                var methodClickPluginItem = "";
                if (CustomerToolbarButtons.Any())
                {
                    methodGetPluginAttrs  = nameof(GetPluginAttrs);
                    methodClickPluginItem = nameof(ClickPluginItem);
                }
                await Interope.Invoke(this, EditorElement, "bb_editor", methodGetPluginAttrs, methodClickPluginItem, nameof(Update), Height, Value ?? "");
            }
            if (_renderValue)
            {
                _renderValue = false;
                await JSRuntime.InvokeVoidAsync(EditorElement, "bb_editor", "code", "", "", "", "", Value ?? "");
            }
        }
Example #29
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (OnSearchTextChanged == null)
                {
                    OnSearchTextChanged = text => Items.Where(i => i.Text.Contains(text, StringComparison.OrdinalIgnoreCase));
                }
                if (Interop == null)
                {
                    Interop = new JSInterop <Select <TValue> >(JSRuntime);
                }
                await Interop.Invoke(this, SelectElement, "bb_select", nameof(ConfirmSelectedItem));

                if (Initialized && SelectedItem != null && OnSelectedItemChanged != null)
                {
                    await OnSelectedItemChanged.Invoke(SelectedItem);
                }
            }
        }
Example #30
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (ShowSearch)
                {
                    // 注册 SeachBox 回调事件
                    Interop = new JSInterop <Table <TItem> >(JSRuntime);
                    await Interop.Invoke(this, TableElement, "bb_table_search", nameof(OnSearch), nameof(OnClearSearch));
                }

                FirstRender = false;
                methodName  = Height.HasValue ? "fixTableHeader" : "init";

                ScreenSize = await RetrieveWidth();

                // 初始化列
                if (AutoGenerateColumns)
                {
                    var cols = InternalTableColumn.GetProperties <TItem>(Columns);
                    Columns.Clear();
                    Columns.AddRange(cols);
                }

                ColumnVisibles = Columns.Select(i => new ColumnVisibleItem {
                    FieldName = i.GetFieldName(), Visible = i.Visible
                }).ToList();

                // set default sortName
                var col = Columns.FirstOrDefault(i => i.Sortable && i.DefaultSort);
                if (col != null)
                {
                    SortName  = col.GetFieldName();
                    SortOrder = col.DefaultSortOrder;
                }
                await QueryAsync();
            }

            if (!firstRender)
            {
                IsRendered = true;
            }

            if (IsRendered)
            {
                if (IsLoading)
                {
                    IsLoading = false;
                    var _ = JSRuntime.InvokeVoidAsync(TableElement, "bb_table_load", "hide");
                }

                // fix: https://gitee.com/LongbowEnterprise/BootstrapBlazor/issues/I2AYEH
                // PR: https://gitee.com/LongbowEnterprise/BootstrapBlazor/pulls/818
                if (Columns.Any(col => col.ShowTips) && string.IsNullOrEmpty(methodName))
                {
                    methodName = "tooltip";
                }

                if (!string.IsNullOrEmpty(methodName))
                {
                    await JSRuntime.InvokeVoidAsync(TableElement, "bb_table", methodName);

                    methodName = null;
                }

                if (IsAutoRefresh && AutoRefreshInterval > 500 && AutoRefreshCancelTokenSource == null)
                {
                    AutoRefreshCancelTokenSource = new CancellationTokenSource();

                    // 自动刷新功能
                    _ = Task.Run(async() =>
                    {
                        try
                        {
                            while (!(AutoRefreshCancelTokenSource?.IsCancellationRequested ?? true))
                            {
                                await InvokeAsync(QueryAsync);
                                await Task.Delay(AutoRefreshInterval, AutoRefreshCancelTokenSource?.Token ?? new CancellationToken(true));
                            }
                        }
                        catch (TaskCanceledException) { }
                    });
                }
            }
        }