Example #1
0
        public IDialogReference Show(Type contentComponent, string title, DialogParameters parameters, DialogOptions options)
        {
            if (!typeof(ComponentBase).IsAssignableFrom(contentComponent))
            {
                throw new ArgumentException($"{contentComponent.FullName} must be a Blazor Component");
            }
            var             dialogInstanceId = Guid.NewGuid();
            DialogReference dialogReference  = null;
            var             dialogContent    = new RenderFragment(builder =>
            {
                var i = 0;
                builder.OpenComponent(i++, contentComponent);
                foreach (var parameter in parameters._parameters)
                {
                    builder.AddAttribute(i++, parameter.Key, parameter.Value);
                }
                builder.CloseComponent();
            });
            var dialogInstance = new RenderFragment(builder =>
            {
                builder.OpenComponent <MudDialogInstance>(0);
                builder.AddAttribute(1, "Options", options);
                builder.AddAttribute(2, "Title", title);
                builder.AddAttribute(3, "Content", dialogContent);
                builder.AddAttribute(4, "Id", dialogInstanceId);
                builder.CloseComponent();
            });

            dialogReference = new DialogReference(dialogInstanceId, dialogInstance, this);

            OnDialogInstanceAdded?.Invoke(dialogReference);

            return(dialogReference);
        }
 internal async Task DismissInstance(DialogReference dialog, DialogResult result)
 {
     if (dialog != null)
     {
         dialog.Dismiss(result);
         Dialogs.Remove(dialog);
         await InvokeAsync(StateHasChanged);
     }
 }
        private async void CancelDialogs(object sender, LocationChangedEventArgs e)
        {
            foreach (var DialogReference in Dialogs.ToList())
            {
                DialogReference.Dismiss(DialogResult.Cancel());
            }

            Dialogs.Clear();
            await InvokeAsync(StateHasChanged);
        }
Example #4
0
 public void Close(DialogReference dialog, DialogResult result)
 {
     OnDialogCloseRequested?.Invoke(dialog, result);
 }
Example #5
0
 public void Close(DialogReference dialog)
 {
     Close(dialog, DialogResult.Ok <object>(null));
 }
 private void DismissInstance(DialogReference dialog, DialogResult result)
 {
     dialog.Dismiss(result);
     _dialogs.Remove(dialog);
     StateHasChanged();
 }
 private void AddInstance(DialogReference dialog)
 {
     _dialogs.Add(dialog);
     StateHasChanged();
 }
 internal async void CloseInstance(DialogReference dialog, DialogResult result)
 {
     await DismissInstance(dialog, result);
 }
 private async void Update(DialogReference DialogReference)
 {
     Dialogs.Add(DialogReference);
     await InvokeAsync(StateHasChanged);
 }
Example #10
0
 internal void Close(DialogReference Dialog)
 {
     Close(Dialog, DialogResult.Ok <object>(null));
 }
Example #11
0
 internal void Close(DialogReference Dialog, DialogResult result)
 {
     OnDialogCloseRequested?.Invoke(Dialog, result);
 }