Ejemplo n.º 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");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Dispose 方法
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && Interop != null)
     {
         Interop.Dispose();
         Interop = null;
     }
 }
Ejemplo n.º 3
0
 private async Task Generate()
 {
     if (Interop == null)
     {
         Interop = new JSInterop <QRCode>(JSRuntime);
     }
     await Interop.Invoke(this, QRCodeElement, "bb_qrcode", "generate");
 }
Ejemplo n.º 4
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 <MultiSelect <TValue> >(JSRuntime);
                await Interop.Invoke(this, SelectElement, "bb_multi_select", nameof(Close));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Dispose 方法
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                Interop?.Dispose();
                Interop = null;
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 19
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.Invoke(this, SelectElement, "bb_select", nameof(ConfirmSelectedItem));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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 ?? "");
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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 ?? "");
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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) { }
                    });
                }
            }
        }