예제 #1
0
파일: LayoutManager.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 深度查找所有自动隐藏项,同步移除
 /// </summary>
 /// <param name="p_items"></param>
 /// <returns></returns>
 IEnumerable <Tab> GetHideItems(IPaneList p_items)
 {
     foreach (var item in p_items.Items)
     {
         if (item is Tabs tabs)
         {
             int index = 0;
             while (index < tabs.Items.Count)
             {
                 Tab si = tabs.Items[index] as Tab;
                 if (si != null && !si.IsPinned)
                 {
                     tabs.Items.RemoveAt(index);
                     yield return(si);
                 }
                 else
                 {
                     index++;
                 }
             }
         }
         else if (item is IPaneList child)
         {
             foreach (Tab si in GetHideItems(child))
             {
                 yield return(si);
             }
         }
     }
 }
예제 #2
0
파일: LayoutManager.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 深度清除所有子项
 /// </summary>
 /// <param name="p_items"></param>
 public static void ClearItems(IPaneList p_items)
 {
     // 不可使用Items.Clear
     while (p_items.Items.Count > 0)
     {
         // 先移除当前项,再清除子项,不可颠倒!
         var item = p_items.Items[0];
         p_items.Items.RemoveAt(0);
         if (item is IPaneList child)
         {
             ClearItems(child);
         }
         else if (item is TabControl tabs)
         {
             tabs.Items.Clear();
         }
     }
 }
예제 #3
0
파일: LayoutManager.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 将内部所有的Tab转移到两侧隐藏
 /// </summary>
 /// <param name="p_items"></param>
 /// <param name="p_state"></param>
 void MoveToAutoHide(IPaneList p_items, PanePosition p_state)
 {
     foreach (var item in p_items.Items)
     {
         if (item is Tabs tabs)
         {
             int index = 0;
             while (index < tabs.Items.Count)
             {
                 Tab si = tabs.Items[index] as Tab;
                 if (si != null)
                 {
                     tabs.Items.RemoveAt(index);
                     if (p_state == PanePosition.Left)
                     {
                         if (_owner.LeftAutoHide == null)
                         {
                             _owner.CreateLeftAutoHideTab();
                         }
                         _owner.LeftAutoHide.Unpin(si);
                     }
                     else if (p_state == PanePosition.Right)
                     {
                         if (_owner.RightAutoHide == null)
                         {
                             _owner.CreateRightAutoHideTab();
                         }
                         _owner.RightAutoHide.Unpin(si);
                     }
                 }
                 else
                 {
                     index++;
                 }
             }
         }
         else if (item is IPaneList child)
         {
             MoveToAutoHide(child, p_state);
         }
     }
 }
예제 #4
0
파일: LayoutManager.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 深度查找所有Tab项,构造以Tab.Title为键以Tab为值的字典,Title不为空
 /// </summary>
 /// <param name="p_items"></param>
 void ExtractItems(IPaneList p_items)
 {
     foreach (var item in p_items.Items)
     {
         if (item is Tabs tabs)
         {
             foreach (var obj in tabs.Items)
             {
                 if (obj is Tab tab && !string.IsNullOrEmpty(tab.Title))
                 {
                     tab.OwnWin       = _owner;
                     _tabs[tab.Title] = tab;
                 }
             }
         }
         else if (item is IPaneList child)
         {
             ExtractItems(child);
         }
     }
 }
예제 #5
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;
         }
     }
 }