コード例 #1
0
        /// <summary>
        /// Creates a new TreeTabItem
        /// </summary>
        /// <param name="_id">string</param>
        /// <param name="_headerText">string</param>
        /// <param name="_showCloseButton">bool</param>
        /// <param name="_tooltip">string</param>
        /// <returns>TreeTabItem</returns>
        private TreeTabItem CreateTabItem(string _id, string _headerText, bool _showCloseButton, string _tooltip)
        {
            TreeTabItem tab = this.CreateTabItem(_id, _headerText, _showCloseButton, TreeItem.TREEITEM_TYPE.MAIN);

            tab.ToolTip = _tooltip;
            return(tab);
        }
コード例 #2
0
 /// <summary>
 /// Sets the current selected TreeTabItem.
 /// </summary>
 /// <param name="sender">object</param>
 /// <param name="e">RoutedEventArgs</param>
 protected void OnGotFocus(object sender, RoutedEventArgs e)
 {
     if (e.OriginalSource.GetType() == typeof(TreeTabItem) || e.OriginalSource.GetType() == typeof(TreeTabItemGroup))
     {
         this.selectedTabItem = (TreeTabItem)e.OriginalSource;
     }
 }
コード例 #3
0
        /// <summary>
        /// Sets the content of a specific TreeTabItem.
        /// The control content must implement the IDisposable interface.
        /// </summary>
        /// <param name="_tabId">string</param>
        /// <param name="_content">IDisposable</param>
        public void SetTabContent(string _tabId, IDisposable _content)
        {
            TreeTabItem tabItem = this.GetTabItemById(_tabId);

            if (tabItem != null)
            {
                this.SetTabContent(tabItem, _content);
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds a new TreeTabItem at the collection of the main tab container.
        /// Adds a new TreeItem at the TreeView control.
        /// </summary>
        /// <param name="_id">string</param>
        /// <param name="_headerText">string</param>
        /// <param name="_showCloseButton">TreeItem.TREEITEM_TYPE</param>
        /// <param name="_type">bool</param>
        /// <returns>TreeTabItem</returns>
        public TreeTabItem AddTabItem(string _id, string _headerText, bool _showCloseButton, TreeItem.TREEITEM_TYPE _type)
        {
            TreeTabItem tab = null;

            if (this.CheckId(_id))
            {
                tab = this.CreateTabItem(_id, _headerText, _showCloseButton, _type);
                TreeItem tItem = new TreeItem(_type, _headerText, _id);
                tItem.LinkedTabItem = tab;
                this.tabContainer.Items.Add(tab);
                this.treeView.Items.Add(tItem);
            }
            return(tab);
        }
コード例 #5
0
        /// <summary>
        /// Creates a new TreeTabItem
        /// </summary>
        /// <param name="_id">string</param>
        /// <param name="_headerText">string</param>
        /// <param name="_showCloseButton">bool</param>
        /// <param name="_type">TreeItem.TREEITEM_TYPE</param>
        /// <returns>TreeTabItem</returns>
        private TreeTabItem CreateTabItem(string _id, string _headerText, bool _showCloseButton, TreeItem.TREEITEM_TYPE _type)
        {
            TreeTabItem tab;

            if (_type == TreeItem.TREEITEM_TYPE.MAIN)
            {
                tab = new TreeTabItem(_id, _headerText, _showCloseButton);
            }
            else
            {
                tab = new TreeTabItemGroup(_id, _headerText, _showCloseButton);
            }
            return(tab);
        }
コード例 #6
0
        /// <summary>
        /// Adds a new TreeTabItem at the collection of a certain TreeTabItemGroup object.
        /// Adds a new TreeItem at the collection of certain TreeItem.
        /// </summary>
        /// <param name="_id">string</param>
        /// <param name="_headerText">string</param>
        /// <param name="_showCloseButton">bool</param>
        /// <param name="_type">TreeItem.TREEITEM_TYPE</param>
        /// <param name="_parent">TreeTabItemGroup</param>
        /// <returns>TreeTabItem</returns>
        public TreeTabItem AddTabItem(string _id, string _headerText, bool _showCloseButton, TreeItem.TREEITEM_TYPE _type, TreeTabItemGroup _parent)
        {
            TreeTabItem tab = null;

            if (_parent != null && this.CheckId(_id))
            {
                tab = this.CreateTabItem(_id, _headerText, _showCloseButton, _type);
                TreeItem tItem = new TreeItem(_type, _headerText, _id);
                tItem.LinkedTabItem = tab;
                _parent.Items.Add(tab);
                TreeItem tParent = this.GetTreeItemById(_parent.Id);
                tParent.Items.Add(tItem);
            }
            return(tab);
        }
コード例 #7
0
 /// <summary>
 /// Removes the linked tab item of the object.
 /// </summary>
 public void RemoveLinkedTabItem()
 {
     if (this.linkedTabItem.Parent != null)
     {
         this.linkedTabItem.Close();
         if (this.Parent.GetType() == typeof(TreeItem))
         {
             TreeItem tParent = (TreeItem)this.Parent;
             if (tParent.Items.Count == 1)
             {
                 tParent.RemoveExpandedMenus();
             }
         }
     }
     this.linkedTabItem = null;
 }
コード例 #8
0
        /// <summary>
        /// Closes the tab calling to the TreeTabControl's CloseTab method.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">RoutedEventArgs</param>
        private void xClose_Click(object sender, RoutedEventArgs e)
        {
            StackPanel  stack  = (StackPanel)((Button)e.OriginalSource).Parent;
            TabHeader   header = (TabHeader)stack.Parent;
            TreeTabItem item   = (TreeTabItem)header.Parent;

            FrameworkElement ctrl = item;

            do
            {
                ctrl = (FrameworkElement)ctrl.Parent;
            }while (ctrl.Parent == null || ctrl.GetType() != typeof(TreeTabControl));

            TreeTabControl tabControl = (TreeTabControl)ctrl;

            tabControl.CloseTab(item);
        }
コード例 #9
0
        /// <summary>
        /// Gets a already TreeTabItem by its Id at specific ItemCollection.
        /// </summary>
        /// <param name="_id">string</param>
        /// <param name="_startItems">ItemCollection</param>
        /// <returns>TreeTabItem</returns>
        public TreeTabItem GetTabItemById(string _id, ItemCollection _startItems)
        {
            int         i           = 0;
            TreeTabItem tItem       = null;
            TreeTabItem currentItem = null;

            while (i < _startItems.Count && tItem == null)
            {
                currentItem = (TreeTabItem)_startItems[i];
                if (currentItem.Id as string == _id)
                {
                    tItem = (TreeTabItem)currentItem;
                }
                else if (_startItems[i].GetType() == typeof(TreeTabItemGroup))
                {
                    if (((TreeTabItemGroup)_startItems[i]).HasItems)
                    {
                        tItem = this.GetTabItemById(_id, ((TreeTabItemGroup)_startItems[i]).Items);
                    }
                }
                i++;
            }
            return(tItem);
        }
コード例 #10
0
 /// <summary>
 /// Sets the current selected TreeTabItem.
 /// </summary>
 /// <param name="sender">object</param>
 /// <param name="e">RoutedEventArgs</param>
 protected void OnGotFocus(object sender, RoutedEventArgs e)
 {
     if (e.OriginalSource.GetType() == typeof(TreeTabItem) || e.OriginalSource.GetType() == typeof(TreeTabItemGroup))
         this.selectedTabItem = (TreeTabItem)e.OriginalSource;
 }
コード例 #11
0
 /// <summary>
 /// Sets the content of a specific TreeTabItem.
 /// The control content must implement the IDisposable interface.
 /// <param name="_tabItem">TreeTabItem</param>
 /// <param name="_content">IDisposable</param>
 public void SetTabContent(TreeTabItem _tabItem, IDisposable _content)
 {
     _tabItem.Content = _content;
 }
コード例 #12
0
 /// <summary>
 /// Closes a specific tab by passing a TreeTabItem object.
 /// </summary>
 /// <param name="_tabIem"></param>
 public void CloseTab(TreeTabItem _tabIem)
 {
     this.CloseTab(_tabIem.Id);
 }
コード例 #13
0
 /// <summary>
 /// Creates a new TreeTabItem
 /// </summary>
 /// <param name="_id">string</param>
 /// <param name="_headerText">string</param>
 /// <param name="_showCloseButton">bool</param>
 /// <param name="_type">TreeItem.TREEITEM_TYPE</param>
 /// <returns>TreeTabItem</returns>
 private TreeTabItem CreateTabItem(string _id, string _headerText, bool _showCloseButton, TreeItem.TREEITEM_TYPE _type)
 {
     TreeTabItem tab;
     if (_type == TreeItem.TREEITEM_TYPE.MAIN)
         tab = new TreeTabItem(_id, _headerText, _showCloseButton);
     else
         tab = new TreeTabItemGroup(_id, _headerText, _showCloseButton);
     return tab;
 }
コード例 #14
0
ファイル: TreeItem.cs プロジェクト: HydAu/PowershellUISamples
 /// <summary>
 /// Removes the linked tab item of the object.
 /// </summary>
 public void RemoveLinkedTabItem()
 {
     if (this.linkedTabItem.Parent != null)
     {
         this.linkedTabItem.Close();
         if (this.Parent.GetType() == typeof(TreeItem))
         {
             TreeItem tParent = (TreeItem)this.Parent;
             if (tParent.Items.Count == 1)
                 tParent.RemoveExpandedMenus();
         }
     }
     this.linkedTabItem = null;
 }
コード例 #15
0
ファイル: TreeItem.cs プロジェクト: HydAu/PowershellUISamples
 /// <summary>
 /// Adds the linked tab item to the object and creates the context menu items.
 /// </summary>
 /// <param name="_tabItem">TreeTabItem</param>
 public void AddLinkedTabItem(TreeTabItem _tabItem)
 {
     this.linkedTabItem = _tabItem;
     this.AddSelectTabMenu();
     this.AddCloseMenu();
 }
コード例 #16
0
 /// <summary>
 /// Sets the content of a specific TreeTabItem.
 /// The control content must implement the IDisposable interface.
 /// <param name="_tabItem">TreeTabItem</param>
 /// <param name="_content">IDisposable</param>
 public void SetTabContent(TreeTabItem _tabItem, IDisposable _content)
 {
     _tabItem.Content = _content;
 }
コード例 #17
0
 /// <summary>
 /// Adds the linked tab item to the object and creates the context menu items.
 /// </summary>
 /// <param name="_tabItem">TreeTabItem</param>
 public void AddLinkedTabItem(TreeTabItem _tabItem)
 {
     this.linkedTabItem = _tabItem;
     this.AddSelectTabMenu();
     this.AddCloseMenu();
 }
コード例 #18
0
 /// <summary>
 /// Closes a specific tab by passing a TreeTabItem object.
 /// </summary>
 /// <param name="_tabIem"></param>
 public void CloseTab(TreeTabItem _tabIem)
 {
     this.CloseTab(_tabIem.Id);
 }