Ejemplo n.º 1
0
 public void Assign(BrowserTabStripItem item)
 {
     Visible  = item.Visible;
     Text     = item.Text;
     CanClose = item.CanClose;
     base.Tag = item.Tag;
 }
 public virtual void Remove(BrowserTabStripItem item)
 {
     if (base.List.Contains(item))
     {
         base.List.Remove(item);
     }
 }
Ejemplo n.º 3
0
        private SizeF MeasureTabWidth(Graphics g, BrowserTabStripItem currentItem, Font currentFont)
        {
            SizeF result = g.MeasureString(currentItem.Title, currentFont, new SizeF(200f, 28f), sf);

            result.Width += 25f;
            return(result);
        }
 public virtual void Insert(int index, BrowserTabStripItem item)
 {
     if (!Contains(item))
     {
         base.List.Insert(index, item);
     }
 }
Ejemplo n.º 5
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            HitTestResult hitTestResult = HitTest(e.Location);

            if (hitTestResult == HitTestResult.TabItem)
            {
                BrowserTabStripItem tabItemByPoint = GetTabItemByPoint(e.Location);
                if (tabItemByPoint != null)
                {
                    SelectedItem = tabItemByPoint;
                    Invalidate();
                }
            }
            else
            {
                if (e.Button != MouseButtons.Left || hitTestResult != 0)
                {
                    return;
                }
                if (SelectedItem != null)
                {
                    TabStripItemClosingEventArgs tabStripItemClosingEventArgs = new TabStripItemClosingEventArgs(SelectedItem);
                    OnTabStripItemClosing(tabStripItemClosingEventArgs);
                    if (!tabStripItemClosingEventArgs.Cancel && SelectedItem.CanClose)
                    {
                        RemoveTab(SelectedItem);
                        OnTabStripItemClosed(EventArgs.Empty);
                    }
                }
                Invalidate();
            }
        }
        protected override void OnInsertComplete(int index, object item)
        {
            BrowserTabStripItem fATabStripItem = item as BrowserTabStripItem;

            fATabStripItem.Changed += OnItem_Changed;
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, item));
        }
Ejemplo n.º 7
0
 protected internal virtual void OnTabStripItemClosed(EventArgs e)
 {
     selectedItem = null;
     if (this.TabStripItemClosed != null)
     {
         this.TabStripItemClosed(this, e);
     }
 }
        protected override void OnRemove(int index, object item)
        {
            base.OnRemove(index, item);
            BrowserTabStripItem fATabStripItem = item as BrowserTabStripItem;

            fATabStripItem.Changed -= OnItem_Changed;
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, item));
        }
        public virtual int Add(BrowserTabStripItem item)
        {
            int num = IndexOf(item);

            if (num == -1)
            {
                num = base.List.Add(item);
            }
            return(num);
        }
Ejemplo n.º 10
0
 public void AddTab(BrowserTabStripItem tabItem, bool autoSelect)
 {
     tabItem.Dock = DockStyle.Fill;
     Items.Add(tabItem);
     if ((autoSelect && tabItem.Visible) || (tabItem.Visible && Items.DrawnCount < 1))
     {
         SelectedItem = tabItem;
         SelectItem(tabItem);
     }
 }
Ejemplo n.º 11
0
 private void SetDefaultSelected()
 {
     if (selectedItem == null && Items.Count > 0)
     {
         SelectedItem = Items[0];
     }
     for (int i = 0; i < Items.Count; i++)
     {
         BrowserTabStripItem fATabStripItem = Items[i];
         fATabStripItem.Dock = DockStyle.Fill;
     }
 }
        public virtual BrowserTabStripItem MoveTo(int newIndex, BrowserTabStripItem item)
        {
            int num = base.List.IndexOf(item);

            if (num >= 0)
            {
                RemoveAt(num);
                Insert(0, item);
                return(item);
            }
            return(null);
        }
Ejemplo n.º 13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            SetDefaultSelected();
            Rectangle clientRectangle = base.ClientRectangle;

            clientRectangle.Width--;
            clientRectangle.Height--;
            DEF_START_POS = 10;
            e.Graphics.DrawRectangle(SystemPens.ControlDark, clientRectangle);
            e.Graphics.FillRectangle(Brushes.White, clientRectangle);
            e.Graphics.FillRectangle(SystemBrushes.GradientInactiveCaption, new Rectangle(clientRectangle.X, clientRectangle.Y, clientRectangle.Width, 28));
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            for (int i = 0; i < Items.Count; i++)
            {
                BrowserTabStripItem fATabStripItem = Items[i];
                if (fATabStripItem.Visible || base.DesignMode)
                {
                    OnCalcTabPage(e.Graphics, fATabStripItem);
                    fATabStripItem.IsDrawn = false;
                    OnDrawTabButton(e.Graphics, fATabStripItem);
                }
            }
            if (selectedItem != null)
            {
                OnDrawTabButton(e.Graphics, selectedItem);
            }
            if (Items.DrawnCount == 0 || Items.VisibleCount == 0)
            {
                e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, 28), new Point(base.ClientRectangle.Width, 28));
            }
            else if (SelectedItem != null && SelectedItem.IsDrawn)
            {
                int   num   = (int)(SelectedItem.StripRect.Height / 4f);
                Point point = new Point((int)SelectedItem.StripRect.Left - num, 28);
                e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, 28), point);
                point.X += (int)SelectedItem.StripRect.Width + num * 2;
                e.Graphics.DrawLine(SystemPens.ControlDark, point, new Point(base.ClientRectangle.Width, 28));
            }
            if (SelectedItem != null && SelectedItem.CanClose)
            {
                closeButton.IsVisible = true;
                closeButton.CalcBounds(selectedItem);
                closeButton.Draw(e.Graphics);
            }
            else
            {
                closeButton.IsVisible = false;
            }
        }
 public virtual void Assign(BrowserTabStripItemCollection collection)
 {
     BeginUpdate();
     try {
         Clear();
         for (int i = 0; i < collection.Count; i++)
         {
             BrowserTabStripItem item           = collection[i];
             BrowserTabStripItem fATabStripItem = new BrowserTabStripItem();
             fATabStripItem.Assign(item);
             Add(fATabStripItem);
         }
     }
     finally {
         EndUpdate();
     }
 }
Ejemplo n.º 15
0
 protected virtual void OnMenuItemsLoad(EventArgs e)
 {
     menu.RightToLeft = RightToLeft;
     menu.Items.Clear();
     for (int i = 0; i < Items.Count; i++)
     {
         BrowserTabStripItem fATabStripItem = Items[i];
         if (fATabStripItem.Visible)
         {
             ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem(fATabStripItem.Title);
             toolStripMenuItem.Tag   = fATabStripItem;
             toolStripMenuItem.Image = fATabStripItem.Image;
             menu.Items.Add(toolStripMenuItem);
         }
     }
     OnMenuItemsLoaded(EventArgs.Empty);
 }
Ejemplo n.º 16
0
        private void OnDrawTabButton(Graphics g, BrowserTabStripItem currentItem)
        {
            Items.IndexOf(currentItem);
            Font         font         = Font;
            RectangleF   stripRect    = currentItem.StripRect;
            GraphicsPath graphicsPath = new GraphicsPath();
            float        left         = stripRect.Left;
            float        right        = stripRect.Right;
            float        num          = 3f;
            float        num2         = stripRect.Bottom - 1f;
            float        num3         = stripRect.Width;
            float        num4         = stripRect.Height;
            float        num5         = num4 / 4f;

            graphicsPath.AddLine(left - num5, num2, left + num5, num);
            graphicsPath.AddLine(right - num5, num, right + num5, num2);
            graphicsPath.CloseFigure();
            SolidBrush brush = new SolidBrush((currentItem == SelectedItem) ? Color.White : SystemColors.GradientInactiveCaption);

            g.FillPath(brush, graphicsPath);
            g.DrawPath(SystemPens.ControlDark, graphicsPath);
            if (currentItem == SelectedItem)
            {
                g.DrawLine(new Pen(brush), left - 9f, num4 + 2f, left + num3 - 1f, num4 + 2f);
            }
            PointF     location        = new PointF(left + 15f, 5f);
            RectangleF layoutRectangle = stripRect;

            layoutRectangle.Location = location;
            layoutRectangle.Width    = num3 - (layoutRectangle.Left - left) - 4f;
            if (currentItem == selectedItem)
            {
                layoutRectangle.Width -= 15f;
            }
            layoutRectangle.Height = 23f;
            if (currentItem == SelectedItem)
            {
                g.DrawString(currentItem.Title, font, new SolidBrush(ForeColor), layoutRectangle, sf);
            }
            else
            {
                g.DrawString(currentItem.Title, font, new SolidBrush(ForeColor), layoutRectangle, sf);
            }
            currentItem.IsDrawn = true;
        }
Ejemplo n.º 17
0
        public BrowserTabStripItem GetTabItemByPoint(Point pt)
        {
            BrowserTabStripItem result = null;
            bool flag = false;

            for (int i = 0; i < Items.Count; i++)
            {
                BrowserTabStripItem fATabStripItem = Items[i];
                if (fATabStripItem.StripRect.Contains(pt) && fATabStripItem.Visible && fATabStripItem.IsDrawn)
                {
                    result = fATabStripItem;
                    flag   = true;
                }
                if (flag)
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 18
0
        public void RemoveTab(BrowserTabStripItem tabItem)
        {
            int num = Items.IndexOf(tabItem);

            if (num >= 0)
            {
                UnSelectItem(tabItem);
                Items.Remove(tabItem);
            }
            if (Items.Count > 0)
            {
                if (Items[num - 1] != null)
                {
                    SelectedItem = Items[num - 1];
                }
                else
                {
                    SelectedItem = Items.FirstVisible;
                }
            }
        }
Ejemplo n.º 19
0
        private void OnCollectionChanged(object sender, CollectionChangeEventArgs e)
        {
            BrowserTabStripItem fATabStripItem = (BrowserTabStripItem)e.Element;

            if (e.Action == CollectionChangeAction.Add)
            {
                Controls.Add(fATabStripItem);
                OnTabStripItemChanged(new TabStripItemChangedEventArgs(fATabStripItem, BrowserTabStripItemChangeTypes.Added));
            }
            else if (e.Action == CollectionChangeAction.Remove)
            {
                Controls.Remove(fATabStripItem);
                OnTabStripItemChanged(new TabStripItemChangedEventArgs(fATabStripItem, BrowserTabStripItemChangeTypes.Removed));
            }
            else
            {
                OnTabStripItemChanged(new TabStripItemChangedEventArgs(fATabStripItem, BrowserTabStripItemChangeTypes.Changed));
            }
            UpdateLayout();
            Invalidate();
        }
Ejemplo n.º 20
0
        private void OnCalcTabPage(Graphics g, BrowserTabStripItem currentItem)
        {
            _ = Font;
            int num = 0;

            if (currentItem.Title == "+")
            {
                num = AddButtonWidth;
            }
            else
            {
                num = (base.Width - (AddButtonWidth + 20)) / (items.Count - 1);
                if (num > MaxTabSize)
                {
                    num = MaxTabSize;
                }
            }
            RectangleF rectangleF2 = (currentItem.StripRect = new RectangleF(DEF_START_POS, 3f, num, 28f));

            DEF_START_POS += num;
        }
Ejemplo n.º 21
0
 private void OnMenuItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     BrowserTabStripItem fATabStripItem2 = (SelectedItem = (BrowserTabStripItem)e.ClickedItem.Tag);
 }
 public TabStripItemChangedEventArgs(BrowserTabStripItem item, BrowserTabStripItemChangeTypes type)
 {
     changeType = type;
     itm        = item;
 }
 public virtual bool Contains(BrowserTabStripItem item)
 {
     return(base.List.Contains(item));
 }
 public virtual int IndexOf(BrowserTabStripItem item)
 {
     return(base.List.IndexOf(item));
 }
Ejemplo n.º 25
0
 public void AddTab(BrowserTabStripItem tabItem)
 {
     AddTab(tabItem, autoSelect: false);
 }
Ejemplo n.º 26
0
 internal void SelectItem(BrowserTabStripItem tabItem)
 {
     tabItem.Dock     = DockStyle.Fill;
     tabItem.Visible  = true;
     tabItem.Selected = true;
 }
Ejemplo n.º 27
0
 internal void UnSelectItem(BrowserTabStripItem tabItem)
 {
     tabItem.Selected = false;
 }
 public void CalcBounds(BrowserTabStripItem tab)
 {
     Rect       = new Rectangle((int)tab.StripRect.Right - 20, (int)tab.StripRect.Top + 5, 15, 15);
     RedrawRect = new Rectangle(Rect.X - 2, Rect.Y - 2, Rect.Width + 4, Rect.Height + 4);
 }
 public TabStripItemClosingEventArgs(BrowserTabStripItem item)
 {
     _item = item;
 }