Ejemplo n.º 1
0
        /// <summary>
        ///     Add a new Header
        /// </summary>
        public void AddTabItem(int index)
        {
            if (IsFixedSize)
                throw new InvalidOperationException("ItemsSource is Fixed Size");

            //int i = this.SelectedIndex;
            int i = 0;
            for (int j = 0; j < index; j++)
            {
                if (isAdded.Get(j))
                    i++;
            }

            // give an opertunity to cancel the adding of the tabitem
            CancelEventArgs c = new CancelEventArgs();
            if (TabItemAdding != null)
                TabItemAdding(this, c);

            if (c.Cancel)
                return;

            TabItem tabItem;

            // Using ItemsSource property
            if (ItemsSource != null)
            {
                IList list = (IList)ItemsSource;
                NewTabItemEventArgs n = new NewTabItemEventArgs();
                if (NewTabItem == null)
                    throw new InvalidOperationException("You must implement the NewTabItem event to supply the item to be added to the tab control.");

                NewTabItem(this, n);
                if (n.Content == null)
                    return;

                if (i == 0 || i == list.Count)
                    list.Add(n.Content);
                else
                    list.Insert(i, n.Content);

                tabItem = (TabItem)this.ItemContainerGenerator.ContainerFromItem(n.Content);
            }
            else
            {
                // Using Items Property
                string tab_header = null;
                switch ((Section)index)
                {
                    case Section.WIP:
                        tab_header = "Work in Progress";
                        break;
                    case Section.INV:
                        tab_header = "Inventory";
                        break;
                    case Section.INOUT:
                        tab_header = "In-/OutBound";
                        break;
                    case Section.INBOUND:
                        tab_header = "Inbound";
                        break;
                    case Section.OUTBOUND:
                        tab_header = "Outbound";
                        break;
                    case Section.RETURN:
                        tab_header = "Return";
                        break;
                    case Section.REPORT:
                        tab_header = "Reporting";
                        break;
                    case Section.BILL:
                        tab_header = "Billing";
                        break;
                    case Section.ADMIN:
                        tab_header = "Admin";
                        break;
                    case Section.DOCK:
                        tab_header = "Dock";
                        break;
                    case Section.TASKS:
                        tab_header = "Tasks";
                        break;

                }
                tabItem = new TabItem { Header = tab_header};

                if (i >= this.Items.Count)
                    this.Items.Add(tabItem);
                else
                    //    this.Items.Insert(++i, tabItem);
                    this.Items.Insert(i, tabItem);
            }

            if (TabItemAdded != null)
                TabItemAdded(this, new TabItemEventArgs(tabItem));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Add a new Header
        /// </summary>
        public void AddTabItem()
        {
            if (IsFixedSize)
            {
                throw new InvalidOperationException("ItemsSource is Fixed Size");
            }

            int i = this.SelectedIndex;

            // give an opertunity to cancel the adding of the tabitem
            CancelEventArgs c = new CancelEventArgs();

            if (TabItemAdding != null)
            {
                TabItemAdding(this, c);
            }

            if (c.Cancel)
            {
                return;
            }

            TabItem tabItem;

            // Using ItemsSource property
            if (ItemsSource != null)
            {
                IList list            = (IList)ItemsSource;
                NewTabItemEventArgs n = new NewTabItemEventArgs();
                if (NewTabItem == null)
                {
                    throw new InvalidOperationException("You must implement the NewTabItem event to supply the item to be added to the tab control.");
                }

                NewTabItem(this, n);
                if (n.Content == null)
                {
                    return;
                }

                if (i == -1 || i == list.Count - 1 || AddNewTabToEnd)
                {
                    list.Add(n.Content);
                }
                else
                {
                    list.Insert(++i, n.Content);
                }

                tabItem = (TabItem)this.ItemContainerGenerator.ContainerFromItem(n.Content);
            }
            else
            {
                // Using Items Property
                tabItem = new TabItem {
                    Header = "New Tab"
                };
                if (i == -1 || i == this.Items.Count - 1 || AddNewTabToEnd)
                {
                    this.Items.Add(tabItem);
                }
                else
                {
                    this.Items.Insert(++i, tabItem);
                }
            }

            if (TabItemAdded != null)
            {
                TabItemAdded(this, new TabItemEventArgs(tabItem));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Add a new Header
        /// </summary>
        public void AddTabItem()
        {
            if (IsFixedSize)
                throw new InvalidOperationException("ItemsSource is Fixed Size");

            int i = this.SelectedIndex;

            // give an opertunity to cancel the adding of the tabitem
            CancelEventArgs c = new CancelEventArgs();
            if (TabItemAdding != null)
                TabItemAdding(this, c);

            if (c.Cancel)
                return;

            TabItem tabItem;

            // Using ItemsSource property
            if (ItemsSource != null)
            {
                IList list = (IList)ItemsSource;
                NewTabItemEventArgs n = new NewTabItemEventArgs();
                if (NewTabItem == null)
                    throw new InvalidOperationException("You must implement the NewTabItem event to supply the item to be added to the tab control.");

                NewTabItem(this, n);
                if (n.Content == null)
                    return;

                if (i == -1 || i == list.Count - 1 || AddNewTabToEnd)
                    list.Add(n.Content);
                else
                    list.Insert(++i, n.Content);

                tabItem = (TabItem)this.ItemContainerGenerator.ContainerFromItem(n.Content);
            }
            else
            {
                // Using Items Property
                tabItem = new TabItem { Header = "New Tab" };

                if (i == -1 || i == this.Items.Count - 1 || AddNewTabToEnd)
                    this.Items.Add(tabItem);
                else
                    this.Items.Insert(++i, tabItem);
            }

            if (TabItemAdded != null)
                TabItemAdded(this, new TabItemEventArgs(tabItem));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Add a new Header
        /// </summary>
        public void AddTabItem(int index)
        {
            if (IsFixedSize)
            {
                throw new InvalidOperationException("ItemsSource is Fixed Size");
            }

            //int i = this.SelectedIndex;
            int i = 0;

            for (int j = 0; j < index; j++)
            {
                if (isAdded.Get(j))
                {
                    i++;
                }
            }

            // give an opertunity to cancel the adding of the tabitem
            CancelEventArgs c = new CancelEventArgs();

            if (TabItemAdding != null)
            {
                TabItemAdding(this, c);
            }

            if (c.Cancel)
            {
                return;
            }

            TabItem tabItem;

            // Using ItemsSource property
            if (ItemsSource != null)
            {
                IList list            = (IList)ItemsSource;
                NewTabItemEventArgs n = new NewTabItemEventArgs();
                if (NewTabItem == null)
                {
                    throw new InvalidOperationException("You must implement the NewTabItem event to supply the item to be added to the tab control.");
                }

                NewTabItem(this, n);
                if (n.Content == null)
                {
                    return;
                }

                if (i == 0 || i == list.Count)
                {
                    list.Add(n.Content);
                }
                else
                {
                    list.Insert(i, n.Content);
                }

                tabItem = (TabItem)this.ItemContainerGenerator.ContainerFromItem(n.Content);
            }
            else
            {
                // Using Items Property
                string tab_header = null;
                switch ((Section)index)
                {
                case Section.WIP:
                    tab_header = "Work in Progress";
                    break;

                case Section.INV:
                    tab_header = "Inventory";
                    break;

                case Section.INOUT:
                    tab_header = "In-/OutBound";
                    break;

                case Section.INBOUND:
                    tab_header = "Inbound";
                    break;

                case Section.OUTBOUND:
                    tab_header = "Outbound";
                    break;

                case Section.RETURN:
                    tab_header = "Return";
                    break;

                case Section.REPORT:
                    tab_header = "Reporting";
                    break;

                case Section.BILL:
                    tab_header = "Billing";
                    break;

                case Section.ADMIN:
                    tab_header = "Admin";
                    break;

                case Section.DOCK:
                    tab_header = "Dock";
                    break;

                case Section.TASKS:
                    tab_header = "Tasks";
                    break;
                }
                tabItem = new TabItem {
                    Header = tab_header
                };

                if (i >= this.Items.Count)
                {
                    this.Items.Add(tabItem);
                }
                else
                {
                    //    this.Items.Insert(++i, tabItem);
                    this.Items.Insert(i, tabItem);
                }
            }

            if (TabItemAdded != null)
            {
                TabItemAdded(this, new TabItemEventArgs(tabItem));
            }
        }