Example #1
0
 /// <summary>
 /// 深度查找所有Tab项,构造以Tab.Title为键名以Tab为值的字典
 /// </summary>
 /// <param name="p_items"></param>
 void ExtractItems(IPaneList p_items)
 {
     foreach (var obj in p_items.Items)
     {
         if (obj is Tabs tabs)
         {
             foreach (var tab in tabs.Items.OfType <Tab>())
             {
                 string title = tab.Title;
                 if (string.IsNullOrEmpty(title))
                 {
                     // Tab未设置标题时使用窗口标题
                     tab.Title = Title;
                     title     = Kit.NewGuid;
                 }
                 tab.OwnWin   = this;
                 _tabs[title] = tab;
             }
             tabs.Items.Clear();
         }
         else if (obj is IPaneList ic)
         {
             ExtractItems(ic);
         }
         else
         {
             // 普通界面元素,一般为单视图窗口
             Tab tab = new Tab
             {
                 Content = obj,
                 Title   = Title,
                 OwnWin  = this
             };
             _tabs[Kit.NewGuid] = tab;
         }
     }
 }
Example #2
0
        void LoadWinMain(object p_content)
        {
            Tab  tab;
            Tabs tabs = (Tabs)GetValue(MainTabsProperty);

            if (tabs == null || tabs.Items.Count == 0)
            {
                // 初次加载 或 恢复默认布局后
                tabs = new Tabs {
                    ShowHeader = false
                };
                tab = new Tab();
                tabs.Items.Add(tab);
                SetValue(MainTabsProperty, tabs);

                // 已应用模板
                CenterItem.Items.Add(tabs);
            }
            else
            {
                tab = (Tab)tabs.Items[0];
            }

            // 切换内容
            if (tab.Content != p_content)
            {
                if (p_content is Win win)
                {
                    // 为重合边线
                    win.Margin = new Thickness(-1, -1, 0, 0);
                    // 关闭时用
                    win.SetValue(OwnTabProperty, tab);
                }
                tab.Content = p_content;
            }
        }
Example #3
0
        internal void OnPinChange(Tab item)
        {
            if (item.IsPinned)
            {
                AutoHideTab autoHide = item.Owner as AutoHideTab;
                if (autoHide != null)
                {
                    autoHide.Pin(item);
                    PanePosition dockState = GetDockState(autoHide.TabStripPlacement);
                    Tabs         sect      = FindPinSect(dockState);
                    if (sect != null)
                    {
                        // 直接停靠
                        sect.Items.Add(item);
                    }
                    else
                    {
                        Pane dockItem = new Pane();
                        dockItem.Pos = dockState;
                        sect         = new Tabs();
                        dockItem.Items.Add(sect);
                        sect.Items.Add(item);
                        Items.Add(dockItem);
                    }
                }
            }
            else
            {
                Tabs sect = item.Owner as Tabs;
                Pane dockItem;
                if (sect != null && (dockItem = sect.OwnWinItem) != null)
                {
                    switch (dockItem.Pos)
                    {
                    case PanePosition.Left:
                        if (LeftAutoHide == null)
                        {
                            CreateLeftAutoHideTab();
                        }
                        LeftAutoHide.Unpin(item);
                        break;

                    case PanePosition.Bottom:
                        if (BottomAutoHide == null)
                        {
                            CreateBottomAutoHideTab();
                        }
                        BottomAutoHide.Unpin(item);
                        break;

                    case PanePosition.Right:
                        if (RightAutoHide == null)
                        {
                            CreateRightAutoHideTab();
                        }
                        RightAutoHide.Unpin(item);
                        break;

                    case PanePosition.Top:
                        if (TopAutoHide == null)
                        {
                            CreateTopAutoHideTab();
                        }
                        TopAutoHide.Unpin(item);
                        break;
                    }
                }
            }
            OnLayoutChanged();
        }
Example #4
0
 static ToolWindow GetParentWindow(Tab p_sectItem)
 {
     return(GetParentWindow(p_sectItem?.OwnTabs?.OwnWinItem));
 }
Example #5
0
 /// <summary>
 /// 内容是否可停靠
 /// </summary>
 /// <param name="pane"></param>
 /// <returns></returns>
 internal static bool CheckIsDockable(Tab pane)
 {
     return((pane != null) && pane.CanDock);
 }