예제 #1
0
 protected override void OnOpen()
 {
     _serverSocket.ExecuteOnUpdate(() =>
     {
         OnOpenEvent?.Invoke();
     });
 }
예제 #2
0
        public async Task <ModalRef> Confirm(ConfirmOptions props)
        {
            ModalRef modalRef = new ModalRef(props, this);
            await OnOpenEvent?.Invoke(modalRef);

            return(modalRef);
        }
예제 #3
0
        /// <summary>
        /// show a confirm dialog like MessageBox of Windows
        /// </summary>
        /// <param name="content">the content of dialog</param>
        /// <param name="title">the title of dialog</param>
        /// <param name="confirmButtons">the buttons of dialog</param>
        /// <param name="confirmIcon">the icon of dialog</param>
        /// <param name="options">the configuration options for dialog</param>
        /// <param name="autoFocusButton">the autofocus button</param>
        /// <returns></returns>
        public async Task <ConfirmResult> Show(
            OneOf <string, RenderFragment> content,
            OneOf <string, RenderFragment> title,
            ConfirmButtons confirmButtons,
            ConfirmIcon confirmIcon,
            ConfirmButtonOptions options,
            ConfirmAutoFocusButton?autoFocusButton = ConfirmAutoFocusButton.Ok)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            ConfirmOptions confirmOptions = new ConfirmOptions()
            {
                Content        = content,
                ConfirmButtons = confirmButtons,
                ConfirmIcon    = confirmIcon,
            };

            if (autoFocusButton != null)
            {
                confirmOptions.AutoFocusButton = (ConfirmAutoFocusButton)autoFocusButton;
            }

            if (title.IsT0)
            {
                confirmOptions.Title = title.AsT0;
            }
            else
            {
                confirmOptions.TitleTemplate = title.AsT1;
            }

            #region config button default properties

            if (options.Button1Props != null)
            {
                confirmOptions.Button1Props = options.Button1Props;
            }
            if (options.Button2Props != null)
            {
                confirmOptions.Button2Props = options.Button2Props;
            }
            if (options.Button3Props != null)
            {
                confirmOptions.Button3Props = options.Button3Props;
            }

            #endregion

            var confirmRef = new ConfirmRef(confirmOptions)
            {
                TaskCompletionSource = new TaskCompletionSource <ConfirmResult>()
            };
            if (OnOpenEvent != null)
            {
                await OnOpenEvent.Invoke(confirmRef);
            }
            return(await confirmRef.TaskCompletionSource.Task);
        }
예제 #4
0
        public ConfirmRef Confirm(ConfirmOptions props)
        {
            ConfirmRef confirmRef = new ConfirmRef(props, this);

            confirmRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>();
            OnOpenEvent?.Invoke(confirmRef);
            return(confirmRef);
        }
예제 #5
0
 internal Task OpenAsync(ConfirmRef confirmRef)
 {
     if (OnOpenEvent != null)
     {
         OnOpenEvent.Invoke(confirmRef);
     }
     return(Task.CompletedTask);
 }
예제 #6
0
        /// <summary>
        /// Create and open a Moal
        /// </summary>
        /// <param name="config">Options</param>
        /// <returns></returns>
        public Task <ConfirmRef> CreateAsync(ConfirmOptions config)
        {
            CheckIsNull(config);
            ConfirmRef confirmRef = new ConfirmRef(config, this);

            OnOpenEvent?.Invoke(confirmRef);
            return(Task.FromResult(confirmRef));
        }
예제 #7
0
 internal Task OpenAsync(DrawerRef drawerRef)
 {
     if (OnOpenEvent != null)
     {
         return(OnOpenEvent.Invoke(drawerRef));
     }
     return(Task.CompletedTask);
 }
예제 #8
0
        public ModalRef Confirm(ConfirmOptions props)
        {
            ModalRef modalRef = new ModalRef(props, this);

            modalRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>();
            OnOpenEvent?.Invoke(modalRef);
            return(modalRef);
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
 internal Task OpenAsync(ModalRef modalRef)
 {
     if (OnOpenEvent != null)
     {
         OnOpenEvent.Invoke(modalRef);
     }
     return(Task.CompletedTask);
 }
예제 #13
0
        /// <summary>
        /// 创建并打开一个简单窗口
        /// </summary>
        /// <param name="config">抽屉参数</param>
        /// <returns></returns>
        public async Task <ModalRef> CreateAsync(ConfirmOptions config)
        {
            CheckIsNull(config);
            ModalRef modalRef = new ModalRef(config, this);

            OnOpenEvent.Invoke(modalRef);
            return(modalRef);
        }
예제 #14
0
 protected override void OnOpen()
 {
     _serverSocket.ExecuteOnUpdate(() =>
     {
         if (OnOpenEvent != null)
             OnOpenEvent.Invoke();
     });
 }
예제 #15
0
        public async Task <bool> ConfirmAsync(ConfirmOptions props)
        {
            ModalRef modalRef = new ModalRef(props, this);

            modalRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>();
            await OnOpenEvent?.Invoke(modalRef);

            return(await modalRef.TaskCompletionSource.Task
                   .ContinueWith(t =>
            {
                return t.Result == ConfirmResult.OK;
            }, TaskScheduler.Default));
        }
예제 #16
0
 private void OnOperateHandle(int type, int code)
 {
     if (code < 0)
     {
         return;
     }
     if (type == (int)OeipFFmpegMode.OEIP_DECODER_OPEN)
     {
         IsAudiio = OeipHelper.getMediaAudioInfo(MediaId, ref audioInfo);
         IsVideo  = OeipHelper.getMediaVideoInfo(MediaId, ref videoInfo);
         OnOpenEvent?.Invoke(IsVideo, IsVideo);
     }
 }
예제 #17
0
        public async Task <bool> ConfirmAsync(ConfirmOptions props)
        {
            ConfirmRef confirmRef = new ConfirmRef(props, this);

            confirmRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>();
            if (OnOpenEvent != null)
            {
                await OnOpenEvent.Invoke(confirmRef);
            }

            return(await confirmRef.TaskCompletionSource.Task
                   .ContinueWith(t =>
            {
                return t.Result == ConfirmResult.OK;
            }, TaskScheduler.Default));
        }
예제 #18
0
        /// <summary>
        /// show a confirm dialog like MessageBox of Windows
        /// </summary>
        /// <param name="content">the content of dialog</param>
        /// <param name="title">the title of dialog</param>
        /// <param name="confirmButtons">the buttons of dialog</param>
        /// <param name="confirmIcon">the icon of dialog</param>
        /// <param name="options">the configuration options for dialog</param>
        /// <returns></returns>
        public async Task <ConfirmResult> Show(
            OneOf <string, RenderFragment> content,
            OneOf <string, RenderFragment> title,
            ConfirmButtons confirmButtons,
            ConfirmIcon confirmIcon,
            ConfirmButtonOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            ConfirmOptions confirmOptions = new ConfirmOptions()
            {
                Title          = title,
                Content        = content,
                ConfirmButtons = confirmButtons,
                ConfirmIcon    = confirmIcon,
            };

            #region config button default properties

            if (options.Button1Props != null)
            {
                confirmOptions.Button1Props = options.Button1Props;
            }
            if (options.Button2Props != null)
            {
                confirmOptions.Button2Props = options.Button2Props;
            }
            if (options.Button3Props != null)
            {
                confirmOptions.Button3Props = options.Button3Props;
            }

            #endregion

            var modalRef = new ConfirmRef(confirmOptions)
            {
                TaskCompletionSource = new TaskCompletionSource <ConfirmResult>()
            };
            if (OnOpenEvent != null)
            {
                await OnOpenEvent.Invoke(modalRef);
            }
            return(await modalRef.TaskCompletionSource.Task);
        }
예제 #19
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);
        }
예제 #20
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);
        }
예제 #21
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 <ModalRef <TResult> > CreateAsync <TComponent, TContentParams, TResult>(ConfirmOptions config, TContentParams contentParams) where TComponent : ModalTemplate <TContentParams, TResult>
        {
            CheckIsNull(config);

            ModalRef <TResult> modalRef = new ModalRef <TResult>(config, this);
            await OnOpenEvent.Invoke(modalRef);

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

            config.Content = child;

            return(modalRef);
        }
예제 #22
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);
        }
예제 #23
0
        /// <summary>
        /// Create and open template modal
        /// </summary>
        /// <typeparam name="TComponent"></typeparam>
        /// <typeparam name="TComponentOptions"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="config"></param>
        /// <param name="componentOptions"></param>
        /// <returns></returns>
        public Task <ConfirmRef <TResult> > CreateAsync <TComponent, TComponentOptions, TResult>(ConfirmOptions config, TComponentOptions componentOptions) where TComponent : ConfirmTemplate <TComponentOptions, TResult>
        {
            CheckIsNull(config);

            ConfirmRef <TResult> confirmRef = new ConfirmRef <TResult>(config, this);

            OnOpenEvent?.Invoke(confirmRef);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <TComponent>(0);
                builder.AddAttribute(1, "ConfirmRef", confirmRef);
                builder.AddAttribute(2, "Options", componentOptions);
                builder.CloseComponent();
            };

            config.Content = child;

            return(Task.FromResult(confirmRef));
        }