예제 #1
0
        private void AddPane()
        {
            string currentUrl = NavigationManager.Uri;
            var    path       = new Uri(currentUrl).LocalPath;

            if (path != "/")
            {
                if (Panes.TryGetValue(currentUrl, out Pane curPane))
                {
                    curPane.ActiveTime = DateTime.Now;
                }
                else
                {
                    string title;
                    FindMenuTitle(Menus, path);
                    title   = MenuTitle;
                    curPane = new Pane
                    {
                        Url   = currentUrl,
                        Title = title,
                        Body  = Body
                    };
                    Panes[currentUrl] = curPane;
                    if (PageType != null)
                    {
                        curPane.BuildCustomBodyRenderer(PageType, RouteValues);
                    }
                }
            }

            foreach (Pane pane in Panes.Values.ToArray())
            {
                if (pane.Url != currentUrl && pane.IsClosed)
                {
                    Panes.Remove(pane.Url);
                }
            }

            Tabs = new ObservableCollection <TabOption>();
            foreach (Pane pane in Panes.Values.OrderBy(a => a.StartTime).ToArray())
            {
                Tabs.Add(new TabOption
                {
                    Name       = pane.Url,
                    Title      = pane.Title,
                    IsActive   = currentUrl == pane.Url,
                    IsClosable = true
                });
            }

            if (Panes.Count == 0)
            {
                Menu?.DeActiveItem();
            }

            Tab?.MarkAsRequireRender();
            Tab?.Refresh();
        }