/// <summary>
 /// ContentChanged 方法
 /// </summary>
 /// <param name="reconnectingTemplate"></param>
 /// <param name="reconnectFailedTemplate"></param>
 /// <param name="reconnectRejectedTemplate"></param>
 private void ContentChanged(RenderFragment?reconnectingTemplate, RenderFragment?reconnectFailedTemplate, RenderFragment?reconnectRejectedTemplate)
 {
     ReconnectingTemplate      = reconnectingTemplate;
     ReconnectFailedTemplate   = reconnectFailedTemplate;
     ReconnectRejectedTemplate = reconnectRejectedTemplate;
     InvokeAsync(StateHasChanged);
 }
示例#2
0
        public void CloseModal()
        {
            IsVisible = false;
            Title     = "";
            Content   = null;

            StateHasChanged();
        }
示例#3
0
        public void ShowModal(string title, RenderFragment content)
        {
            Title     = title;
            Content   = content;
            IsVisible = true;

            StateHasChanged();
        }
示例#4
0
        private async Task OnPaneRespondedAsync(object sender, PaneResponseEventArgs args)
        {
            await InvokeAsync(() =>
            {
                Component = null;

                StateHasChanged();
            });
        }
示例#5
0
        // Is there even a good use for this?

        /*public void FormIsReady(EditContext e)
         * {
         *  EditContext = e;
         *  if (ValidateOnInit)
         *  {
         *      ForceValidate();
         *  }
         * }*/

        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (Model != null && Model.Equals(default(TValue)) && EditContext == null)
            {
                builder.OpenElement(0, "form");
                builder.AddAttribute(1, "class", ClassBuilder);
                builder.AddMultipleAttributes(2, Attributes);
                builder.AddContent(3, ChildContent);
                builder.CloseElement();
                return;
            }
            EditFormChildContent = content =>
            {
                if (content == null)
                {
                    throw new ArgumentNullException(nameof(content));
                }
                return(child =>
                {
                    if (EditContext != null)
                    {
                        content = EditContext;
                    }
                    child.AddContent(1, ChildContent);
                });
            };

            Form = formBuilder =>
            {
                formBuilder.OpenComponent <EditForm>(0);
                formBuilder.AddMultipleAttributes(1, Attributes);
                formBuilder.AddAttribute(2, "class", ClassBuilder);
                if (EditContext != null)
                {
                    formBuilder.AddAttribute(3, "EditContext", EditContext);
                }
                else
                {
                    formBuilder.AddAttribute(3, "Model", Model);
                }
                formBuilder.AddAttribute(4, "OnSubmit", OnSubmit);
                formBuilder.AddAttribute(5, "OnValidSubmit", OnValidSubmit);
                formBuilder.AddAttribute(6, "OnInvalidSubmit", OnInvalidSubmit);
                formBuilder.AddAttribute(7, "ChildContent", EditFormChildContent);
                formBuilder.CloseComponent();
            };

            builder.OpenComponent <CascadingValue <BSForm <TValue> > >(3);
            builder.AddAttribute(4, "IsFixed", true);
            builder.AddAttribute(5, "Value", this);
            builder.AddAttribute(6, "ChildContent", Form);
            builder.CloseComponent();
        }
示例#6
0
 /// <summary>
 /// Appends frames representing an arbitrary fragment of content.
 /// </summary>
 /// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
 /// <param name="fragment">Content to append.</param>
 public void AddContent(int sequence, RenderFragment?fragment)
 {
     if (fragment != null)
     {
         // We surround the fragment with a region delimiter to indicate that the
         // sequence numbers inside the fragment are unrelated to the sequence numbers
         // outside it. If we didn't do this, the diffing logic might produce inefficient
         // diffs depending on how the sequence numbers compared.
         OpenRegion(sequence);
         fragment(this);
         CloseRegion();
     }
 }
示例#7
0
        private async Task OnPaneRequestedAsync(object sender, PaneRequestEventArgs args)
        {
            await InvokeAsync(() =>
            {
                Component = builder =>
                {
                    builder.OpenComponent(1, args.PaneType);
                    builder.AddAttribute(2, nameof(BaseSidePane.EditContext), args.EditContext);
                    builder.AddAttribute(3, nameof(BaseSidePane.ButtonContext), args.ButtonContext);
                    builder.AddAttribute(4, nameof(BaseSidePane.RequestId), args.RequestId);
                    builder.CloseComponent();
                };

                StateHasChanged();
            });
        }
        public void AddOrUpdateHostedContent(string layerId, RenderFragment?renderFragment)
        {
            var foundPortalFragment = portalFragments.FirstOrDefault(x => x.Id == layerId);

            if (foundPortalFragment != null)
            {
                foundPortalFragment.Fragment = renderFragment;
                portals[layerId].Rerender();
            }
            else
            {
                if (layerId == null)
                {
                    throw new Exception("The Layer Id should not be null.");
                }
                portalFragments.Add(new PortalDetails {
                    Id = layerId, Fragment = renderFragment
                });                                                                                 //should render the first time and not after unless explicitly set.
                InvokeAsync(StateHasChanged);
            }
        }
        //public void SetVirtualParent(ElementReference parent, string childPortalId)
        //{
        //    if (portals.ContainsKey(childPortalId))
        //    {
        //        portals[childPortalId].SetVirtualParentAsync(parent);
        //    }
        //}

        //protected override void BuildRenderTree(RenderTreeBuilder builder)
        //{
        //    base.BuildRenderTree(builder);
        //    foreach (var portalPair in portalFragments)
        //    {
        //        int sequenceStart = 0;
        //        if (portalSequenceStarts.ContainsKey(portalPair.id))
        //            sequenceStart = portalSequenceStarts[portalPair.id];
        //        else
        //        {
        //            sequenceStart = sequenceCount;
        //            portalSequenceStarts.Add(portalPair.id, sequenceStart);
        //            sequenceCount += 5; //advance the count for the next new layerportal
        //            // this will eventually run out of numbers... need to reset everything at some point...  maybe it's not necessary
        //        }
        //        builder.OpenComponent<BFULayerPortal>(sequenceStart);
        //        builder.AddAttribute(sequenceStart + 1, "ChildContent", portalPair.fragment);
        //        builder.AddAttribute(sequenceStart + 2, "Id", portalPair.id);
        //        builder.AddAttribute(sequenceStart + 3, "Style", portalPair.style);
        //        builder.AddComponentReferenceCapture(sequenceStart + 4, (component) => portals[portalPair.id] = (BFULayerPortal)component);
        //        builder.CloseComponent();
        //    }
        //}

        public void AddOrUpdateHostedContent(string layerId, RenderFragment?renderFragment)
        {
            var foundPortalFragment = portalFragments.FirstOrDefault(x => x.Id == layerId);

            if (foundPortalFragment != null)
            {
                foundPortalFragment.Fragment = renderFragment;
//                foundPortalFragment.Parent = parent;
                //System.Diagnostics.Debug.WriteLine($"Rerendering layer: {layerId}");
                portals[layerId].Rerender();
            }
            else
            {
                if (layerId == null)
                {
                    throw new Exception("The Layer Id should not be null.");
                }
                //System.Diagnostics.Debug.WriteLine($"Adding new layer: {layerId}, {portalFragments.Count} layer(s) in host currently.");
                portalFragments.Add(new PortalDetails {
                    Id = layerId, Fragment = renderFragment
                });                                                                                 //should render the first time and not after unless explicitly set.
                InvokeAsync(StateHasChanged);
            }
        }
示例#10
0
 public void SetContent(RenderFragment newContent)
 {
     content = newContent;
     StateHasChanged();
 }
示例#11
0
 public Value(RenderFragment content)
 {
     Debug.Assert(content != null, "Attempted to set null Superset.Web.Markup.Value value.");
     _content = content;
 }
示例#12
0
 public void AddOrUpdateHostedContent(string layerId, RenderFragment?renderFragment)
 {
     portalGeneratorReference?.AddOrUpdateHostedContent(layerId, renderFragment);
 }
 public FragmentBuilder WithChildContent(string markupContent)
 {
     _childContent = (builder) => builder.AddMarkupContent(1, markupContent);
     return(this);
 }
示例#14
0
 /// <inheritdoc/>
 protected override void OnInitialized()
 {
     _currentFallbackBuilder = Loading;
     base.OnInitialized(); // trigger initial render
 }
示例#15
0
 public Task AddOrUpdateHostedContentAsync(string layerId, RenderFragment?renderFragment)
 {
     return(portalGeneratorReference?.AddOrUpdateHostedContentAsync(layerId, renderFragment));
 }
 public FragmentBuilder WithChildContent(RenderFragment childContent)
 {
     _childContent = childContent;
     return(this);
 }
 public FragmentBuilder WithChildContent(params RenderFragment[] childContents)
 {
     _childContent = ToFragment(childContents);
     return(this);
 }
示例#18
0
 void ISectionContentSubscriber.ContentChanged(RenderFragment?content)
 {
     _content = content;
     RenderContent();
 }
示例#19
0
 public void ClearContent()
 {
     content = null;
     StateHasChanged();
 }