Exemplo n.º 1
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (AdditionalAttributes == null)
            {
                AdditionalAttributes = new Dictionary <string, object>();
            }

            if (!AdditionalAttributes.TryGetValue("type", out var _))
            {
                AdditionalAttributes["type"] = "button";
            }

            var onClick = OnClick;

            OnClick = EventCallback.Factory.Create <MouseEventArgs>(this, async e =>
            {
                if (!IsDisabled)
                {
                    if (OnClickWithoutRender != null)
                    {
                        await OnClickWithoutRender.Invoke();
                    }
                    if (onClick.HasDelegate)
                    {
                        await onClick.InvokeAsync(e);
                    }
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (AdditionalAttributes == null)
            {
                AdditionalAttributes = new Dictionary <string, object>();
            }

            if (!AdditionalAttributes.TryGetValue("type", out var _))
            {
                AdditionalAttributes["type"] = "button";
            }

            ButtonIcon = Icon;

            OnClickButton = EventCallback.Factory.Create <MouseEventArgs>(this, async() =>
            {
                if (IsAsync && ButtonType == ButtonType.Button)
                {
                    IsAsyncLoading = true;
                    ButtonIcon     = LoadingIcon;
                    IsDisabled     = true;
                }
                if (IsAsync)
                {
                    await Task.Run(async() => await InvokeAsync(HandlerClick));
                }
                else
                {
                    await HandlerClick();
                }
                if (IsAsync && ButtonType == ButtonType.Button)
                {
                    ButtonIcon     = Icon;
                    IsDisabled     = false;
                    IsAsyncLoading = false;
                }
            });

            async Task HandlerClick()
            {
                if (OnClickWithoutRender != null)
                {
                    await OnClickWithoutRender.Invoke();
                }
                if (OnClick.HasDelegate)
                {
                    await OnClick.InvokeAsync();
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 处理点击方法
 /// </summary>
 /// <returns></returns>
 protected virtual async Task HandlerClick()
 {
     if (OnClickWithoutRender != null)
     {
         if (!IsAsync)
         {
             IsNotRender = true;
         }
         await OnClickWithoutRender.Invoke();
     }
     if (OnClick.HasDelegate)
     {
         await OnClick.InvokeAsync();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (Size == Size.None)
            {
                Size = Size.ExtraSmall;
            }

            OnClickButton = EventCallback.Factory.Create <MouseEventArgs>(this, async e =>
            {
                if (IsAsync)
                {
                    ButtonIcon = LoadingIcon;
                    IsDisabled = true;
                }
                if (OnClickWithoutRender != null)
                {
                    await OnClickWithoutRender.Invoke();
                }
                if (OnClick.HasDelegate)
                {
                    await OnClick.InvokeAsync(e);
                }
                if (OnClickWithoutRender != null)
                {
                    await OnClickWithoutRender();
                }
                if (OnClickCallback != null)
                {
                    await OnClickCallback();
                }
                if (IsAsync)
                {
                    ButtonIcon = Icon;
                    IsDisabled = false;
                }
            });
        }