/// <summary> /// Loads the view. Called internally. /// </summary> protected void LoadInternal(bool initiatedLoad) { if (IsLoaded) { return; } if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad) { return; } BeforeLoad(); foreach (var child in LayoutChildren.ToList()) { child.LoadInternal(false); } _isLoaded = true; AfterChildrenLoaded(); Initialize(); LoadDependencyProperties(); UpdateBindings(); AfterLoad(); Loaded?.Invoke(this); }
/// <summary> /// Shows the dialog on the next render after a show action. Also on the next render after the dialog is initiated each /// embedded Material.Blazor component is initiated here. /// </summary> /// <param name="firstRender"></param> /// <returns></returns> protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (AfterRenderShowAction) { try { AfterRenderShowAction = false; Tcs.SetResult(await JsRuntime.InvokeAsync <string>("material_blazor.dialog.show", DialogElem, ObjectReference, EscapeKeyAction, ScrimClickAction)); IsOpen = false; StateHasChanged(); } catch { Tcs?.SetCanceled(); } } else if (AfterDialogInitialization) { AfterDialogInitialization = false; foreach (var child in LayoutChildren) { child.RequestInstantiation(); } LayoutChildren.Clear(); hasInstantiated = true; StateHasChanged(); } }
/// <summary> /// Loads the view asynchronously. /// </summary> protected async Task LoadAsyncInternal(bool initiatedLoad, bool parentAwaitAssets) { if (IsLoaded) { return; } if (LoadMode.HasFlag(LoadMode.Manual) && !initiatedLoad) { return; } BeforeLoad(); bool awaitAssets = parentAwaitAssets || LoadMode.HasFlag(LoadMode.AwaitAssets); await Task.WhenAll(LayoutChildren.ToList().Select(x => x.LoadAsyncInternal(false, awaitAssets))); _isLoaded = true; AfterChildrenLoaded(); Initialize(); if (awaitAssets) { await LoadDependencyPropertiesAsync(); } else { LoadDependencyProperties(); } UpdateBindings(); AfterLoad(); Loaded?.Invoke(this); }
public void Remove(LayoutItemWrapper childLayout) { LayoutPINVOKE.LayoutGroupWrapper_Remove__SWIG_1(swigCPtr, LayoutItemWrapper.getCPtr(childLayout)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } LayoutChildren.Remove(childLayout); }
public uint Add(LayoutItemWrapper childLayout) { uint ret = LayoutPINVOKE.LayoutGroupWrapper_Add(swigCPtr, LayoutItemWrapper.getCPtr(childLayout)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } LayoutChildren.Add(childLayout); return(ret); }
/// <summary> /// Shows the dialog. This first renders the Blazor markup and then allows /// Material Theme to open the dialog, subsequently intiating all embedded Blazor components. /// </summary> /// <returns>The action string resulting form dialog closure</returns> public async Task <string> ShowAsync() { if (IsOpen) { throw new InvalidOperationException("Cannot show MBDialog that is already open"); } else { LayoutChildren.Clear(); Key = Utilities.GenerateUniqueElementName(); IsOpen = true; AfterRenderShowAction = true; StateHasChanged(); Tcs = new TaskCompletionSource <string>(); var ret = await Tcs.Task; hasInstantiated = false; return(ret); } }
/// <summary> /// Unloads the view. /// </summary> protected void UnloadInternal() { if (!IsLoaded) { return; } BeforeUnload(); foreach (var child in LayoutChildren.ToList()) { child.UnloadInternal(); } AfterUnload(); UnloadDependencyProperties(); _isLoaded = false; if (IsDynamic) { Destroy(); } }
/// <inheritdoc/> void IMBDialog.RegisterLayoutAction(IMBDialogChild child) { LayoutChildren.Add(child); }
/// <inheritdoc/> void IMBDialog.RegisterLayoutAction(DialogChildComponent child) { LayoutChildren.Add(child); }