Beispiel #1
0
 /// <summary>
 /// Update drawer
 /// </summary>
 /// <param name="drawerRef"></param>
 /// <returns></returns>
 private async Task DrawerService_OnUpdateEvent(DrawerRef drawerRef)
 {
     if (_drawerRefs.Contains(drawerRef))
     {
         await InvokeStateHasChangedAsync();
     }
 }
Beispiel #2
0
 internal Task CloseAsync(DrawerRef drawerRef)
 {
     if (OnCloseEvent != null)
     {
         return(OnCloseEvent.Invoke(drawerRef));
     }
     return(Task.CompletedTask);
 }
Beispiel #3
0
 internal Task OpenAsync(DrawerRef drawerRef)
 {
     if (OnOpenEvent != null)
     {
         return(OnOpenEvent.Invoke(drawerRef));
     }
     return(Task.CompletedTask);
 }
Beispiel #4
0
        /// <summary>
        /// 创建并打开一个简单抽屉,没有返回值
        /// </summary>
        /// <param name="config">抽屉参数</param>
        /// <returns></returns>
        public async Task <DrawerRef> CreateAsync(DrawerConfig config)
        {
            CheckIsNull(config);
            DrawerRef drawerRef = new DrawerRef(config, this);
            await OnOpenEvent.Invoke(drawerRef);

            return(drawerRef);
        }
Beispiel #5
0
        /// <summary>
        /// Create and open a simple drawer without result
        /// </summary>
        /// <param name="options">drawer options</param>
        /// <returns>The reference of drawer</returns>
        public async Task <DrawerRef> CreateAsync(DrawerOptions options)
        {
            CheckIsNull(options);
            var drawerRef = new DrawerRef <object>(options, this);

            await(OnOpenEvent?.Invoke(drawerRef) ?? Task.CompletedTask);
            return(drawerRef);
        }
Beispiel #6
0
        /// <summary>
        /// Create and open a simple drawer without result
        /// </summary>
        /// <param name="options">drawer options</param>
        /// <returns>The reference of drawer</returns>
        public async Task <IDrawerRef> CreateAsync(DrawerOptions options)
        {
            CheckIsNull(options);
            IDrawerRef drawerRef = new DrawerRef <object>(options, this);
            await OnOpenEvent.Invoke(drawerRef);

            return(drawerRef);
        }
Beispiel #7
0
 /// <summary>
 /// Create and Open a drawer
 /// </summary>
 private async Task DrawerService_OnCreate(DrawerRef drawerRef)
 {
     drawerRef.Config.Visible = true;
     if (!_drawerRefs.Contains(drawerRef))
     {
         _drawerRefs.Add(drawerRef);
     }
     await InvokeAsync(StateHasChanged);
 }
Beispiel #8
0
        /// <summary>
        /// Close the drawer
        /// </summary>
        private async Task DrawerService_OnClose(DrawerRef drawerRef)
        {
            drawerRef.Config.Visible = false;
            await InvokeAsync(StateHasChanged);

            await Task.Delay(300);

            if (_drawerRefs.Contains(drawerRef))
            {
                _drawerRefs.Remove(drawerRef);
            }
        }
        private async Task <DrawerRef> HandleCreate(DrawerConfig config)
        {
            if (OnCreate != null)
            {
                config.DrawerService = this;
                await OnCreate.Invoke(config);

                DrawerRef drawerRef = new DrawerRef(config, this);
                return(drawerRef);
            }
            return(null);
        }
Beispiel #10
0
        /// <summary>
        /// 创建并打开一个模板抽屉
        /// </summary>
        /// <typeparam name="TComponent"></typeparam>
        /// <typeparam name="TContentParams"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="config"></param>
        /// <param name="contentParams"></param>
        /// <returns></returns>
        public async Task <DrawerRef <TResult> > CreateAsync <TComponent, TContentParams, TResult>(DrawerConfig config, TContentParams contentParams) where TComponent : DrawerTemplate <TContentParams, TResult>
        {
            CheckIsNull(config);

            DrawerRef <TResult> drawerRef = new DrawerRef <TResult>(config, this);
            await OnOpenEvent.Invoke(drawerRef);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <TComponent>(0);
                builder.AddAttribute(1, "DrawerRef", drawerRef);
                builder.AddAttribute(2, "Config", contentParams);
                builder.CloseComponent();
            };

            config.ChildContent = child;

            return(drawerRef);
        }
Beispiel #11
0
        /// <summary>
        /// Create and open a drawer with the template
        /// </summary>
        /// <typeparam name="TComponent">The type of DrawerTemplate implement</typeparam>
        /// <typeparam name="TComponentOptions">The </typeparam>
        /// <typeparam name="TResult">The type of return value</typeparam>
        /// <param name="config"></param>
        /// <param name="options"></param>
        /// <returns>The reference of drawer</returns>
        public async Task <DrawerRef <TResult> > CreateAsync <TComponent, TComponentOptions, TResult>(DrawerOptions config, TComponentOptions options) where TComponent : FeedbackComponent <TComponentOptions, TResult>
        {
            CheckIsNull(config);

            DrawerRef <TResult> drawerRef = new DrawerRef <TResult>(config, this);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <TComponent>(0);
                builder.AddAttribute(1, "FeedbackRef", drawerRef);
                builder.AddAttribute(2, "Options", options);
                builder.CloseComponent();
            };

            config.ChildContent = child;

            await(OnOpenEvent?.Invoke(drawerRef) ?? Task.CompletedTask);
            return(drawerRef);
        }
Beispiel #12
0
        public async Task <TResult> CreateDialogAsync <TComponent, TComponentOptions, TResult>(DrawerOptions config, TComponentOptions options) where TComponent : DrawerTemplate <TComponentOptions, TResult>
        {
            CheckIsNull(config);
            DrawerRef <TResult> drawerRef = new DrawerRef <TResult>(config, this);

            drawerRef.TaskCompletionSource = new TaskCompletionSource <TResult>();;
            await OnOpenEvent.Invoke(drawerRef);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <TComponent>(0);
                builder.AddAttribute(1, "DrawerRef", drawerRef);
                builder.AddAttribute(2, "Options", options);
                builder.CloseComponent();
            };

            config.ChildContent = child;

            return(await drawerRef.TaskCompletionSource.Task);
        }
Beispiel #13
0
 /// <summary>
 /// Update a drawer
 /// </summary>
 /// <param name="drawerRef"></param>
 /// <returns></returns>
 public async Task UpdateAsync(DrawerRef drawerRef)
 {
     await(OnUpdateEvent?.Invoke(drawerRef) ?? Task.CompletedTask);
 }