public async Task <ModalRef> Confirm(ConfirmOptions props) { ModalRef modalRef = new ModalRef(props, this); await OnOpenEvent?.Invoke(modalRef); return(modalRef); }
private async Task Modal_OnUpdate(ModalRef modalRef) { if (modalRef.Config.Visible) { await InvokeAsync(StateHasChanged); } }
internal Task OpenAsync(ModalRef modalRef) { if (OnOpenEvent != null) { OnOpenEvent.Invoke(modalRef); } return(Task.CompletedTask); }
private async Task OnAfterHide() { _hasFocus = false; if (ModalRef?.OnClose != null) { await ModalRef.OnClose(); } }
public ModalRef Confirm(ConfirmOptions props) { ModalRef modalRef = new ModalRef(props, this); modalRef.TaskCompletionSource = new TaskCompletionSource <ConfirmResult>(); OnOpenEvent?.Invoke(modalRef); return(modalRef); }
/// <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); }
/// <summary> /// close modal dialog /// </summary> /// <param name="modalRef"></param> /// <returns></returns> internal Task CloseModalAsync(ModalRef modalRef) { if (OnModalCloseEvent != null) { return(OnModalCloseEvent.Invoke(modalRef)); } return(Task.CompletedTask); }
private async Task ModalService_OnModalOpenEvent(ModalRef modalRef) { if (!_modalRefs.Contains(modalRef)) { _modalRefs.Add(modalRef); } await InvokeAsync(StateHasChanged); }
/// <summary> /// 创建并打开窗体 /// </summary> private async Task Modal_OnOpen(ModalRef modalRef) { modalRef.Config.Visible = true; if (!_modalRefs.Contains(modalRef)) { _modalRefs.Add(modalRef); } await InvokeAsync(StateHasChanged); }
/// <summary> /// 创建并打开窗体 /// </summary> private async Task Modal_OnOpen(ModalRef modalRef) { modalRef.Config.Visible = true; if (!_modalRefs.Contains(modalRef)) { modalRef.Config.BuildButtonsDefaultOptions(); _modalRefs.Add(modalRef); } await InvokeAsync(StateHasChanged); }
/// <summary> /// Create and open a Modal /// </summary> /// <returns></returns> public Task <ModalRef <TResult> > CreateModalAsync <TResult>(ModalOptions config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } var modalRef = new ModalRef <TResult>(config, this); config.ModalRef = modalRef; return(CreateOrOpenModalAsync(modalRef)); }
private async Task ModalService_OnModalCloseEvent(ModalRef modalRef) { modalRef.Config.Visible = false; await InvokeAsync(StateHasChanged); await Task.Delay(250); if (modalRef.Config.DestroyOnClose && _modalRefs.Contains(modalRef)) { _modalRefs.Remove(modalRef); } }
private async Task Modal_OnDestroy(ModalRef modalRef) { modalRef.Config.Visible = false; await InvokeAsync(StateHasChanged); await Task.Delay(250); if (_modalRefs.Contains(modalRef)) { _modalRefs.Remove(modalRef); } modalRef.OnDestroy?.Invoke(); }
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)); }
private async Task OnAfterDialogShow() { if (!_hasFocus) { await JsInvokeAsync(JSInteropConstants.FocusDialog, $"#{_dialogWrapper.Dialog.SentinelStart}"); _hasFocus = true; if (ModalRef?.OnOpen != null) { await ModalRef.OnOpen(); } } }
/// <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 ModalRef(confirmOptions) { TaskCompletionSource = new TaskCompletionSource <ConfirmResult>() }; if (OnOpenEvent != null) { await OnOpenEvent.Invoke(modalRef); } return(await modalRef.TaskCompletionSource.Task); }
/// <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); }
/// <summary> /// Create and open a Modal with template /// </summary> /// <typeparam name="TComponent"></typeparam> /// <typeparam name="TComponentOptions"></typeparam> /// <param name="config"></param> /// <param name="componentOptions"></param> /// <returns></returns> public Task <ModalRef> CreateModalAsync <TComponent, TComponentOptions>(ModalOptions config, TComponentOptions componentOptions) where TComponent : FeedbackComponent <TComponentOptions> { if (config == null) { throw new ArgumentNullException(nameof(config)); } ModalRef modalRef = new ModalRef(config, this); void Child(RenderTreeBuilder builder) { builder.OpenComponent <TComponent>(0); builder.AddAttribute(1, "FeedbackRef", modalRef); builder.AddAttribute(2, "Options", componentOptions); builder.CloseComponent(); } config.Content = Child; config.ModalRef = modalRef; return(CreateOrOpenModalAsync(modalRef)); }
internal Task <ModalRef> CreateOrOpenModalAsync(ModalRef modalRef) { OnModalOpenEvent?.Invoke(modalRef); return(Task.FromResult(modalRef)); }
public Task Update(ModalRef modalRef) { return(OnUpdateEvent?.Invoke(modalRef)); }
public async Task UpdateModalAsync(ModalRef modalRef) { await(OnModalUpdateEvent?.Invoke(modalRef) ?? Task.CompletedTask); }
public Task Destroy(ModalRef modalRef) { return(OnDestroyEvent?.Invoke(modalRef)); }
/// <summary> /// create or open a Modal dialog /// </summary> /// <param name="modalRef"></param> /// <returns></returns> internal Task <ModalRef <TResult> > CreateOrOpenModalAsync <TResult>(ModalRef <TResult> modalRef) { OnModalOpenEvent?.Invoke(modalRef); ReusedModals.Add(modalRef); return(Task.FromResult(modalRef)); }
private async Task ModalService_OnModalUpdateEvent(ModalRef arg) { await InvokeStateHasChangedAsync(); }