示例#1
0
 public virtual void Remove(FaTabStripItem item)
 {
     if (List.Contains(item))
     {
         List.Remove(item);
     }
 }
示例#2
0
 public void Assign(FaTabStripItem item)
 {
     Visible  = item.Visible;
     Text     = item.Text;
     CanClose = item.CanClose;
     Tag      = item.Tag;
 }
示例#3
0
 public virtual void Insert(int index, FaTabStripItem item)
 {
     if (Contains(item))
     {
         return;
     }
     List.Insert(index, item);
 }
示例#4
0
        public virtual int Add(FaTabStripItem item)
        {
            var res = IndexOf(item);

            if (res == -1)
            {
                res = List.Add(item);
            }
            return(res);
        }
示例#5
0
 public void AddTab(FaTabStripItem tabItem, bool autoSelect)
 {
     tabItem.Dock = DockStyle.Fill;
     Items.Add(tabItem);
     if ((!autoSelect || !tabItem.Visible) && (!tabItem.Visible || Items.DrawnCount >= 1))
     {
         return;
     }
     SelectedItem = tabItem;
     SelectItem(tabItem);
 }
示例#6
0
        public virtual FaTabStripItem MoveTo(int newIndex, FaTabStripItem item)
        {
            var currentIndex = List.IndexOf(item);

            if (currentIndex >= 0)
            {
                RemoveAt(currentIndex);
                Insert(0, item);
                return(item);
            }
            return(null);
        }
示例#7
0
 public virtual void Assign(FaTabStripItemCollection collection)
 {
     BeginUpdate();
     try
     {
         Clear();
         for (var n = 0; n < collection.Count; n++)
         {
             var item    = collection[n];
             var newItem = new FaTabStripItem();
             newItem.Assign(item);
             Add(newItem);
         }
     }
     finally
     {
         EndUpdate();
     }
 }
示例#8
0
        private bool AllowDraw(FaTabStripItem item)
        {
            var result = true;

            if (RightToLeft == RightToLeft.No)
            {
                if (item.StripRect.Right >= _stripButtonRect.Width)
                {
                    result = false;
                }
            }
            else
            {
                if (item.StripRect.Left <= _stripButtonRect.Left)
                {
                    return(false);
                }
            }
            return(result);
        }
示例#9
0
        public FaTabStripItem GetTabItemByPoint(Point pt)
        {
            FaTabStripItem item  = null;
            var            found = false;

            for (var i = 0; i < Items.Count; i++)
            {
                var current = Items[i];
                if (current.StripRect.Contains(pt) && current.Visible && current.IsDrawn)
                {
                    item  = current;
                    found = true;
                }
                if (found)
                {
                    break;
                }
            }
            return(item);
        }
示例#10
0
        public void RemoveTab(FaTabStripItem tabItem)
        {
            var tabIndex = Items.IndexOf(tabItem);

            if (tabIndex >= 0)
            {
                UnSelectItem(tabItem);
                Items.Remove(tabItem);
            }
            if (Items.Count <= 0)
            {
                return;
            }
            if (RightToLeft == RightToLeft.No)
            {
                SelectedItem = Items[tabIndex - 1] ?? Items.FirstVisible;
            }
            else
            {
                SelectedItem = Items[tabIndex + 1] ?? Items.LastVisible;
            }
        }
示例#11
0
        private void OnCalcTabPage(Graphics g, FaTabStripItem currentItem)
        {
            var currentFont = Font;

            if (currentItem == SelectedItem)
            {
                currentFont = new Font(Font, FontStyle.Bold);
            }
            var textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, currentFont.Height), _sf);

            textSize.Width += 20;
            if (RightToLeft == RightToLeft.No)
            {
                var buttonRect = new RectangleF(_defStartPos - 9, 1, textSize.Width, _defHeaderHeight);
                currentItem.StripRect = buttonRect;
                _defStartPos         += (int)textSize.Width;
            }
            else
            {
                var buttonRect = new RectangleF(_defStartPos - textSize.Width + 1, 3, textSize.Width - 1, _defHeaderHeight);
                currentItem.StripRect = buttonRect;
                _defStartPos         -= (int)textSize.Width;
            }
        }
示例#12
0
 internal void SelectItem(FaTabStripItem tabItem)
 {
     tabItem.Dock     = DockStyle.Fill;
     tabItem.Visible  = true;
     tabItem.Selected = true;
 }
示例#13
0
 public virtual bool Contains(FaTabStripItem item)
 {
     return(List.Contains(item));
 }
示例#14
0
 public virtual int IndexOf(FaTabStripItem item)
 {
     return(List.IndexOf(item));
 }
示例#15
0
        private void OnDrawTabPage(Graphics g, FaTabStripItem currentItem)
        {
            LinearGradientBrush brush = null;
            var flag        = Items.IndexOf(currentItem) == 0;
            var currentFont = Font;

            if (currentItem == SelectedItem)
            {
                currentFont = new Font(Font, FontStyle.Bold);
            }
            var ef = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, currentFont.Height), _sf);

            ef.Width += 20f;
            var stripRect       = currentItem.StripRect;
            var layoutRectangle = stripRect;

            using (var path = new GraphicsPath())
            {
                const int num = 3;
                switch (RightToLeft)
                {
                case RightToLeft.No:
                    if (currentItem == SelectedItem || flag)
                    {
                        path.AddLine(stripRect.Left - 10f, stripRect.Bottom - 1f,
                                     (stripRect.Left + (stripRect.Height / 2f)) - 4f, num + 4);
                    }
                    else
                    {
                        path.AddLine(stripRect.Left, stripRect.Bottom - 1f, stripRect.Left,
                                     (stripRect.Bottom - (stripRect.Height / 2f)) - 2f);
                        path.AddLine(stripRect.Left, (stripRect.Bottom - (stripRect.Height / 2f)) - 3f,
                                     (stripRect.Left + (stripRect.Height / 2f)) - 4f, num + 3);
                    }
                    path.AddLine((stripRect.Left + (stripRect.Height / 2f)) + 2f, num, stripRect.Right - 3f, num);
                    path.AddLine(stripRect.Right, num + 2, stripRect.Right, stripRect.Bottom - 1f);
                    path.AddLine(stripRect.Right - 4f, stripRect.Bottom - 1f, stripRect.Left, stripRect.Bottom - 1f);
                    path.CloseFigure();
                    brush = currentItem != SelectedItem
                                    ? new LinearGradientBrush(stripRect, SystemColors.ControlLightLight,
                                                              SystemColors.Control, LinearGradientMode.Vertical)
                                    : new LinearGradientBrush(stripRect, SystemColors.ControlLightLight,
                                                              SystemColors.Window, LinearGradientMode.Vertical);
                    g.FillPath(brush, path);
                    g.DrawPath(SystemPens.ControlDark, path);
                    if (currentItem == SelectedItem)
                    {
                        g.DrawLine(new Pen(brush), stripRect.Left - 9f, stripRect.Height + 2f,
                                   (stripRect.Left + stripRect.Width) - 1f,
                                   stripRect.Height + 2f);
                    }
                    layoutRectangle.Location = new PointF((stripRect.Left + stripRect.Height) - 4f,
                                                          ((float)_defHeaderHeight / 2) - (stripRect.Height / 2) + 2.5f);
                    layoutRectangle.Width  = (stripRect.Width - (layoutRectangle.Left - stripRect.Left));   // - 4f;
                    layoutRectangle.Height = ef.Height + (currentFont.Size / 2f);
                    if (currentItem == SelectedItem)
                    {
                        g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), layoutRectangle,
                                     _sf);
                    }
                    else
                    {
                        g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), layoutRectangle,
                                     _sf);
                    }
                    break;

                case RightToLeft.Yes:
                    if (currentItem == SelectedItem || flag)
                    {
                        path.AddLine(stripRect.Right + 10f, stripRect.Bottom - 1f,
                                     (stripRect.Right - (stripRect.Height / 2f)) + 4f, num + 4);
                    }
                    else
                    {
                        path.AddLine(stripRect.Right, stripRect.Bottom - 1f, stripRect.Right,
                                     (stripRect.Bottom - (stripRect.Height / 2f)) - 2f);
                        path.AddLine(stripRect.Right, (stripRect.Bottom - (stripRect.Height / 2f)) - 3f,
                                     (stripRect.Right - (stripRect.Height / 2f)) + 4f, num + 3);
                    }
                    path.AddLine((stripRect.Right - (stripRect.Height / 2f)) - 2f, num, stripRect.Left + 3f,
                                 num);
                    path.AddLine(stripRect.Left, num + 2, stripRect.Left, stripRect.Bottom - 1f);
                    path.AddLine(stripRect.Left + 4f, stripRect.Bottom - 1f, stripRect.Right, stripRect.Bottom - 1f);
                    path.CloseFigure();
                    brush = currentItem != SelectedItem
                                    ? new LinearGradientBrush(stripRect, SystemColors.ControlLightLight,
                                                              SystemColors.Control, LinearGradientMode.Vertical)
                                    : new LinearGradientBrush(stripRect, SystemColors.ControlLightLight,
                                                              SystemColors.Window, LinearGradientMode.Vertical);
                    g.FillPath(brush, path);
                    g.DrawPath(SystemPens.ControlDark, path);
                    if (ReferenceEquals(currentItem, SelectedItem))
                    {
                        g.DrawLine(new Pen(brush), stripRect.Right + 9f, stripRect.Height + 2f,
                                   (stripRect.Right - stripRect.Width) + 1f,
                                   stripRect.Height + 2f);
                    }
                    layoutRectangle.Location = new PointF(stripRect.Left + 2f,
                                                          ((float)_defHeaderHeight / 2) - (stripRect.Height / 2) + 2.5f);
                    layoutRectangle.Width  = (stripRect.Width - (layoutRectangle.Left - stripRect.Left)) - 10f;
                    layoutRectangle.Height = ef.Height + (currentFont.Size / 2f);
                    if (currentItem != SelectedItem)
                    {
                        g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), layoutRectangle,
                                     _sf);
                    }
                    else
                    {
                        layoutRectangle.Y--;
                        g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), layoutRectangle,
                                     _sf);
                    }
                    break;
                }
            }
            if (brush != null)
            {
                brush.Dispose();
            }
            currentItem.IsDrawn = true;
        }
示例#16
0
 public void AddTab(FaTabStripItem tabItem)
 {
     AddTab(tabItem, false);
 }
示例#17
0
 internal void UnSelectItem(FaTabStripItem tabItem)
 {
     tabItem.Selected = false;
 }