Example #1
0
 private void DragStart(XTab tab)
 {
     _isDragging   = true;
     _isDraggedTab = tab;
     return;
 }
        private void RenderXTabs(RenderFragment pageFragment, bool resetXTabs = false)
        {
            var xTabTitle          = RouteData.PageType.Name;
            var xTabCssClass       = string.Empty;
            var xTabInactiveRender = false;

            var pageAttr = RouteData.PageType.GetCustomAttribute <XTabPageAttribute>();

            if (pageAttr is not null)
            {
                xTabTitle          = pageAttr.Title;
                xTabCssClass       = pageAttr.CssClass;
                xTabInactiveRender = pageAttr.InactiveRender;
            }

            if (_xTabs is null)
            {
                var xTabFragment = new RenderFragment(rBuilder =>
                {
                    rBuilder.OpenComponent(0, typeof(XTab));
                    rBuilder.AddAttribute(1, nameof(XTab.ChildContent), pageFragment);
                    rBuilder.AddAttribute(2, nameof(XTab.Title), xTabTitle);
                    rBuilder.AddAttribute(3, nameof(XTab.CssClass), xTabCssClass);
                    rBuilder.AddAttribute(4, nameof(XTab.InactiveRender), xTabInactiveRender);
                    rBuilder.CloseComponent();
                });

                _xTabsRenderFragment = new RenderFragment(rBuilder =>
                {
                    rBuilder.OpenComponent <XTabs>(0);

                    rBuilder.AddAttribute(1, nameof(XTabs.RenderMode), RenderMode);
                    rBuilder.AddAttribute(2, nameof(XTabs.CloseTabs), CloseTabs);
                    rBuilder.AddAttribute(3, nameof(XTabs.NewTabSetActive), NewTabSetActive);
                    rBuilder.AddAttribute(4, nameof(XTabs.ChildContent), xTabFragment);
                    rBuilder.AddAttribute(5, nameof(XTabs.PreviousStepsContent), PreviousStepsContent);
                    rBuilder.AddAttribute(6, nameof(XTabs.NextStepsContent), NextStepsContent);
                    rBuilder.AddAttribute(7, nameof(XTabs.CssClass), CssClass);
                    rBuilder.AddAttribute(8, nameof(XTabs.OnTabAdded), OnTabAdded);
                    rBuilder.AddAttribute(9, nameof(XTabs.OnActiveTabChanged), OnActiveTabChanged);
                    rBuilder.AddAttribute(10, nameof(XTabs.OnTabRemoved), OnTabRemoved);
                    rBuilder.AddAttribute(11, nameof(XTabs.OnPreviousSteps), OnPreviousSteps);
                    rBuilder.AddAttribute(12, nameof(XTabs.OnNextSteps), OnNextSteps);
                    rBuilder.AddAttribute(13, nameof(XTabs.IsLoading), IsLoading);
                    rBuilder.AddAttribute(14, nameof(XTabs.IsDraggable), IsDraggable);
                    rBuilder.AddAttribute(15, nameof(XTabs.CloseAllTabs), CloseAllTabs);
                    rBuilder.AddAttribute(16, nameof(XTabs.ShowCloseAllTabsButton), ShowCloseAllTabsButton);
                    rBuilder.AddAttribute(17, nameof(XTabs.CloseAllTabsButtonThreshold), CloseAllTabsButtonThreshold);
                    rBuilder.AddAttribute(18, nameof(XTabs.NoTabsNavigatesToHomepage), NoTabsNavigatesToHomepage);
                    rBuilder.AddAttribute(19, nameof(XTabs.JustifiedHeader), JustifiedHeader);

                    rBuilder.AddComponentReferenceCapture(100, compRef => _xTabs = (XTabs)compRef);
                    rBuilder.CloseComponent();
                });
            }
            else
            {
                var xtab = new XTab(_xTabs, xTabTitle, pageFragment, xTabCssClass, xTabInactiveRender);
                if (resetXTabs)
                {
                    _xTabs.AddOrReplacePage(xtab);
                }
                else
                {
                    _xTabs.AddPage(xtab);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Checks if tab is active.
 /// </summary>
 /// <param name="tab"></param>
 /// <returns></returns>
 public bool IsActive(XTab tab) => tab == Active;