예제 #1
0
        private void HandleMouseInTitle(MouseEventArgs e)
        {
            TabControlItem item = this.GetTabItemByPoint(e.Location);

            if (item != null)
            {
                var inTitle = item.LocationIsInTitle(e.Location);
                TabControlMouseOnTitleEventArgs args = new TabControlMouseOnTitleEventArgs(item, e.Location);
                if (inTitle)
                {
                    //mouseWasOnTitle = true;
                    this.OnTabControlMouseOnTitle(args);
                    if (!this.mouseEnteredTitle)
                    {
                        this.mouseEnteredTitle = true;
                        this.OnTabControlMouseEnteredTitle(args);
                    }
                }
                else if (this.mouseEnteredTitle) // if (mouseWasOnTitle)
                {
                    //mouseWasOnTitle = false;
                    this.mouseEnteredTitle = false;
                    this.OnTabControlMouseLeftTitle(args);
                }
            }
        }
예제 #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            try
            {
                this.HandleTablItemMouseUpActions(e);
                var handled = this.HandleMenuGlipMouseUp(e);
                handled |= this.HandleCloseButtonMouseUp(e);
                handled |= this.HandleTabDetach(e);

                if (!handled)
                {
                    base.OnMouseUp(e);
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
            finally
            {
                this.tabAtMouseDown        = null;
                this.mouseDownAtMenuGliph  = false;
                this.mouseDownAtCloseGliph = false;
                this.movePreview.Hide();
            }
        }
예제 #3
0
 public void Assign(TabControlItem item)
 {
     this.Visible  = item.Visible;
     this.Text     = item.Text;
     this.CanClose = item.CanClose;
     this.Tag      = item.Tag;
 }
예제 #4
0
        private void OnCalcTabPage(Graphics g, TabControlItem currentItem)
        {
            var currentFont = this.Font;

            if (currentItem == this.SelectedItem)
            {
                currentFont = new Font(this.Font, FontStyle.Bold);
            }

            var textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, 10), this.sf);

            textSize.Width += 20;

            if (this.RightToLeft == RightToLeft.No)
            {
                var buttonRect = new RectangleF(this.DEF_START_POS, 3, textSize.Width, 17);
                currentItem.StripRect = buttonRect;
                this.DEF_START_POS   += (int)textSize.Width;
            }
            else
            {
                var buttonRect = new RectangleF(this.DEF_START_POS - textSize.Width + 1, 3, textSize.Width - 1, 17);
                currentItem.StripRect = buttonRect;
                this.DEF_START_POS   -= (int)textSize.Width;
            }
        }
예제 #5
0
        protected virtual void OnMenuItemsLoad(EventArgs e)
        {
            menu.RightToLeft = this.RightToLeft;
            menu.Items.Clear();
            List <ToolStripMenuItem> list = new List <ToolStripMenuItem>();
            int nr = Items.Count;

            for (int i = 0; i < nr; i++)
            {
                TabControlItem item = this.Items[i];
                if (!item.Visible)
                {
                    continue;
                }

                ToolStripMenuItem tItem = new ToolStripMenuItem(item.Title);
                tItem.Tag = item;
                if (item.Selected)
                {
                    tItem.Select();
                }
                list.Add(tItem);
            }
            list.Sort(CompareSortText);
            menu.Items.AddRange(list.ToArray());
            OnMenuItemsLoaded(EventArgs.Empty);
        }
예제 #6
0
        private void OnRemoving(object sender, ComponentEventArgs e)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            //Removing a button
            if (e.Component is TabControlItem)
            {
                TabControlItem itm = e.Component as TabControlItem;
                if (Control.Items.Contains(itm))
                {
                    changeService.OnComponentChanging(Control, null);
                    Control.RemoveTab(itm);
                    changeService.OnComponentChanged(Control, null, null, null);
                    return;
                }
            }

            if (e.Component is TabControl)
            {
                for (int i = Control.Items.Count - 1; i >= 0; i--)
                {
                    TabControlItem itm = Control.Items[i];
                    changeService.OnComponentChanging(Control, null);
                    Control.RemoveTab(itm);
                    host.DestroyComponent(itm);
                    changeService.OnComponentChanged(Control, null, null, null);
                }
            }
        }
 public virtual void Remove(TabControlItem item)
 {
     if (List.Contains(item))
     {
         List.Remove(item);
     }
 }
예제 #8
0
        private void SwapTabItems(int mouseX, TabControlItem upItem)
        {
            var downIndex = this.Items.IndexOf(this.tabAtMouseDown);
            var newIndex  = this.Items.IndexOf(upItem);

            var upCentre = 48 + newIndex * 87;

            if (downIndex < newIndex)
            {
                newIndex--;
                upCentre += 10;
            }

            if (mouseX >= upCentre)
            {
                newIndex++;
            }

            if (newIndex > this.Items.Count - 1)
            {
                newIndex = this.Items.Count - 1;
            }
            if (newIndex <= 0)
            {
                newIndex = 0;
            }
            this.Items.Remove(this.tabAtMouseDown);
            this.Items.Insert(newIndex, this.tabAtMouseDown);
        }
        protected override void OnInsertComplete(int index, object item)
        {
            TabControlItem itm = item as TabControlItem;

            itm.Changed += new EventHandler(OnItem_Changed);
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, item));
        }
예제 #10
0
 private void UnSelectAll()
 {
     for (int i = 0; i < this.Items.Count; i++)
     {
         TabControlItem item = this.Items[i];
         UnSelectItem(item);
     }
 }
 public virtual void Insert(int index, TabControlItem item)
 {
     if (Contains(item))
     {
         return;
     }
     List.Insert(index, item);
 }
        protected override void OnRemove(int index, object item)
        {
            base.OnRemove(index, item);
            TabControlItem itm = item as TabControlItem;

            itm.Changed -= new EventHandler(OnItem_Changed);
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, item));
        }
예제 #13
0
        private void OnMenuItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            TabControlItem clickedItem = (TabControlItem)e.ClickedItem.Tag;

            if (clickedItem != null)
            {
                SelectedItem = clickedItem;
            }
        }
예제 #14
0
 private void UpdateSize(TabControlItem tabControlItem)
 {
     RectangleF tabRectangle = tabControlItem.StripRect;
     // two pixels to add right mergin
     // tab doesnt have to be first, so include all on left side
     int imageDistance = this.imageDetach.Width + 4;
     this.Width = (int)(tabRectangle.Width + tabRectangle.Left) + imageDistance;
     this.Height = (int)(tabRectangle.Height + tabRectangle.Top);
 }
예제 #15
0
 protected internal virtual void OnTabControlItemClosed(TabControlItem tabItem)
 {
     if (this.TabControlItemClosed != null)
     {
         var args = new TabControlItemClosedEventArgs {
             Item = tabItem
         };
         this.TabControlItemClosed(this, args);
     }
 }
        public virtual int Add(TabControlItem item)
        {
            int res = IndexOf(item);

            if (res == -1)
            {
                res = List.Add(item);
            }
            return(res);
        }
예제 #17
0
        private void UpdateSize(TabControlItem tabControlItem)
        {
            RectangleF tabRectangle = tabControlItem.StripRect;
            // two pixels to add right mergin
            // tab doesnt have to be first, so include all on left side
            int imageDistance = this.imageDetach.Width + 4;

            this.Width  = (int)(tabRectangle.Width + tabRectangle.Left) + imageDistance;
            this.Height = (int)(tabRectangle.Height + tabRectangle.Top);
        }
예제 #18
0
        protected override void OnDoubleClick(EventArgs e)
        {
            base.OnDoubleClick(e);
            TabControlItem item = GetTabItemByPoint(PointToClient(Cursor.Position));

            if (item != null)
            {
                CloseTab(item);
            }
        }
예제 #19
0
        private void OnRemoveTabControl(object sender, EventArgs e)
        {
            IDesignerHost       host        = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = host.CreateTransaction("Remove Button");

            changeService.OnComponentChanging(Control, null);
            TabControlItem itm = Control.Items[Control.Items.Count - 1];

            Control.UnSelectItem(itm);
            Control.Items.Remove(itm);
            changeService.OnComponentChanged(Control, null, null, null);
            transaction.Commit();
        }
예제 #20
0
        private void SetDefaultSelected()
        {
            if (selectedItem == null && Items.Count > 0)
            {
                SelectedItem = Items[0];
            }

            for (int i = 0; i < this.Items.Count; i++)
            {
                TabControlItem itm = Items[i];
                itm.Dock = DockStyle.Fill;
            }
        }
예제 #21
0
        internal void Show(TabControlItem tabControlItem)
        {
            this.selectedTabItem = tabControlItem;
            this.UpdateSize(tabControlItem);

            if (!this.Visible)
            {
                this.Show(); // this grabs the fucus, which we have to return
                Form parentForm = this.tabControl.FindForm();
                if (parentForm != null)
                    parentForm.Focus();
            }
        }
예제 #22
0
 public void CloseTab(TabControlItem tabItem)
 {
     if (tabItem != null)
     {
         this.SelectedItem = tabItem;
         var args = new TabControlItemClosingEventArgs(this.SelectedItem);
         this.OnTabControlItemClosing(args);
         if (this.SelectedItem != null && !args.Cancel && this.SelectedItem.CanClose)
         {
             this.RemoveTab(this.SelectedItem);
             this.OnTabControlItemClosed(tabItem);
         }
     }
 }
        public virtual TabControlItem MoveTo(int newIndex, TabControlItem item)
        {
            int currentIndex = List.IndexOf(item);

            if (currentIndex >= 0)
            {
                RemoveAt(currentIndex);
                Insert(0, item);

                return(item);
            }

            return(null);
        }
예제 #24
0
        public TabControlItem GetTabItemByPoint(Point pt)
        {
            TabControlItem item = null;

            for (var i = 0; i < this.Items.Count; i++)
            {
                var current = this.Items[i];
                if (current.StripRect.Contains(pt))
                {
                    item = current;
                }
            }

            return(item);
        }
예제 #25
0
        internal void Show(TabControlItem tabControlItem)
        {
            this.selectedTabItem = tabControlItem;
            this.UpdateSize(tabControlItem);

            if (!this.Visible)
            {
                this.Show(); // this grabs the fucus, which we have to return
                Form parentForm = this.tabControl.FindForm();
                if (parentForm != null)
                {
                    parentForm.Focus();
                }
            }
        }
예제 #26
0
        private void OnAddTabControl(object sender, EventArgs e)
        {
            IDesignerHost       host        = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = host.CreateTransaction("Add TabControl");
            TabControlItem      itm         = (TabControlItem)host.CreateComponent(typeof(TabControlItem));

            changeService.OnComponentChanging(Control, null);
            Control.AddTab(itm);
            int indx = Control.Items.IndexOf(itm) + 1;

            itm.Title = "TabControl Page " + indx.ToString();
            Control.SelectItem(itm);
            changeService.OnComponentChanged(Control, null, null, null);
            transaction.Commit();
        }
예제 #27
0
 private void HandleTablItemMouseUpActions(MouseEventArgs e)
 {
     if (this.tabAtMouseDown != null)
     {
         TabControlItem upItem = this.GetTabItemByPoint(e.Location);
         if (upItem != null && upItem == this.tabAtMouseDown)
         {
             this.SelectedItem = upItem;
         }
         else
         {
             this.SwapTabItems(e.X, upItem);
         }
     }
 }
예제 #28
0
 public void CloseTab(TabControlItem tabItem)
 {
     if (tabItem != null)
     {
         TabControlItemClosingEventArgs args = new TabControlItemClosingEventArgs(SelectedItem);
         OnTabControlItemClosing(args);
         if (SelectedItem != null)
         {
             if (!args.Cancel && SelectedItem.CanClose)
             {
                 RemoveTab(SelectedItem);
                 OnTabControlItemClosed(EventArgs.Empty);
             }
         }
     }
 }
예제 #29
0
        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == 0x201)
            {
                Point          pt  = Control.PointToClient(Cursor.Position);
                TabControlItem itm = Control.GetTabItemByPoint(pt);
                if (itm != null)
                {
                    Control.SelectedItem = itm;
                    ArrayList selection = new ArrayList();
                    selection.Add(itm);
                    ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
                    selectionService.SetSelectedComponents(selection);
                }
            }

            base.WndProc(ref msg);
        }
예제 #30
0
        protected override void OnClick(EventArgs e)
        {
            //If its the middle button, close the tab
            MouseEventArgs mouse = (e as MouseEventArgs);

            if (mouse != null)
            {
                if (mouse.Button == MouseButtons.Middle)
                {
                    TabControlItem item = GetTabItemByPoint(PointToClient(Cursor.Position));
                    if (item != null)
                    {
                        CloseTab(item);
                    }
                }
            }
            base.OnClick(e);
        }
예제 #31
0
        public void RemoveTab(TabControlItem tabItem)
        {
            var tabIndex    = this.Items.IndexOf(tabItem);
            var wasSelected = tabItem.Selected;

            if (tabIndex >= 0)
            {
                this.UnSelectItem(tabItem);
                this.Items.Remove(tabItem);
            }

            if (wasSelected)
            {
                if (this.Items.Count > 0)
                {
                    if (this.RightToLeft == RightToLeft.No)
                    {
                        if (this.Items[tabIndex - 1] != null)
                        {
                            this.SelectedItem = this.Items[tabIndex - 1];
                        }
                        else
                        {
                            this.SelectedItem = this.Items.FirstVisible;
                        }
                    }
                    else
                    {
                        if (this.Items[tabIndex + 1] != null)
                        {
                            this.SelectedItem = this.Items[tabIndex + 1];
                        }
                        else
                        {
                            this.SelectedItem = this.Items.LastVisible;
                        }
                    }
                }
                else
                {
                    this.SelectedItem = null;
                }
            }
        }
예제 #32
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            downItem = GetTabItemByPoint(e.Location);
            if (menuGlyph.Rect.Contains(e.Location))
            {
                HandledEventArgs args = new HandledEventArgs(false);
                OnMenuItemsLoading(args);
                if (!args.Handled)
                {
                    OnMenuItemsLoad(EventArgs.Empty);
                }

                OnMenuShow();
            }
            else if (closeButton.Rect.Contains(e.Location))
            {
                if (SelectedItem != null)
                {
                    TabControlItemClosingEventArgs args = new TabControlItemClosingEventArgs(SelectedItem);
                    OnTabControlItemClosing(args);
                    if (SelectedItem != null && !args.Cancel && SelectedItem.CanClose)
                    {
                        RemoveTab(SelectedItem);
                        OnTabControlItemClosed(EventArgs.Empty);
                    }
                }
            }
            else
            {
                TabControlItem item = GetTabItemByPoint(e.Location);
                if (item != null)
                {
                    SelectedItem = item;
                }
            }

            Invalidate();
        }
 public virtual void Insert(int index, TabControlItem item)
 {
     if (Contains(item)) return;
     List.Insert(index, item);
 }
 public virtual int IndexOf(TabControlItem item)
 {
     return List.IndexOf(item);
 }
 public virtual bool Contains(TabControlItem item)
 {
     return List.Contains(item);
 }
 public virtual void Assign(TabControlItemCollection collection)
 {
     BeginUpdate();
     try
     {
         Clear();
         for (int n = 0; n < collection.Count; n++)
         {
             TabControlItem item = collection[n];
             TabControlItem newItem = new TabControlItem();
             newItem.Assign(item);
             Add(newItem);
         }
     }
     finally
     {
         EndUpdate();
     }
 }
예제 #37
0
 public void ForceCloseTab(TabControlItem tabItem)
 {
     RemoveTab(tabItem);
     OnTabControlItemClosed(EventArgs.Empty);
 }
예제 #38
0
 public void Assign(TabControlItem item)
 {
     this.Visible = item.Visible;
     this.Text = item.Text;
     this.CanClose = item.CanClose;
     this.Tag = item.Tag;
 }
예제 #39
0
 private void tcTerminals_TabControlMouseOnTitle(TabControlMouseOnTitleEventArgs e)
 {
     if(Settings.ShowInformationToolTips)
     {
         //ToolTip
         if((currentToolTipItem != null) && (currentToolTipItem != e.Item))
         {
             currentToolTip.Hide(currentToolTipItem);
         }
         currentToolTip.ToolTipTitle = "Connection information";
         currentToolTip.ToolTipIcon = ToolTipIcon.Info;
         currentToolTip.UseFading = true;
         currentToolTip.UseAnimation = true;
         currentToolTip.IsBalloon = false;
         currentToolTip.Show(e.Item.ToolTipText, e.Item, (int)e.Item.StripRect.X, 2);
         currentToolTipItem = e.Item;
     }
 }
예제 #40
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            try
            {
                this.HandleTablItemMouseUpActions(e);
                bool handled = this.HandleMenuGlipMouseUp(e);
                handled |= this.HandleCloseButtonMouseUp(e);
                handled |= this.HandleTabDetach(e);

                if (!handled)
                    base.OnMouseUp(e);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
            finally
            {
                this.tabAtMouseDown = null;
                this.mouseDownAtMenuGliph = false;
                this.mouseDownAtCloseGliph = false;
                this.movePreview.Hide();
            }
        }
예제 #41
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.mouseDownPoint = e.Location;
                this.tabAtMouseDown = GetTabItemByPoint(this.mouseDownPoint);

                if (this.MouseIsOnMenuGliph(e)) // Show Tabs menu
                    mouseDownAtMenuGliph = true;

                if (this.MouseIsOnCloseButton(e)) // close by click on close button
                    mouseDownAtCloseGliph = true;
            }

            if(!mouseDownAtCloseGliph && !mouseDownAtMenuGliph && this.tabAtMouseDown == null)
                base.OnMouseDown(e); // custom handling

            Invalidate();
        }
예제 #42
0
 internal void UnSelectItem(TabControlItem tabItem)
 {
     tabItem.Selected = false;
 }
예제 #43
0
 internal void SelectItem(TabControlItem tabItem)
 {
     tabItem.Dock = DockStyle.Fill;
     tabItem.Visible = true;
     tabItem.Selected = true;
 }
예제 #44
0
        internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)
        {
            bool isFirstTab = Items.IndexOf(currentItem) == 0;
            Font currentFont = Font;

            if (currentItem == SelectedItem)
                currentFont = new Font(Font, FontStyle.Bold);

            SizeF textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, 10), sf);
            textSize.Width += 20;
            RectangleF buttonRect = currentItem.StripRect;

            GraphicsPath path = new GraphicsPath();
            LinearGradientBrush brush = null;
            int mtop = 3;

            #region Draw Not Right-To-Left Tab

            if (RightToLeft == RightToLeft.No)
            {
                if (currentItem == SelectedItem || isFirstTab)
                {
                    path.AddLine(buttonRect.Left - 10, buttonRect.Bottom - 1, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 4);
                }
                else
                {
                    path.AddLine(buttonRect.Left, buttonRect.Bottom - 1, buttonRect.Left, buttonRect.Bottom - (buttonRect.Height / 2) - 2);
                    path.AddLine(buttonRect.Left, buttonRect.Bottom - (buttonRect.Height / 2) - 3, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 3);
                }

                path.AddLine(buttonRect.Left + (buttonRect.Height / 2) + 2, mtop, buttonRect.Right - 3, mtop);
                path.AddLine(buttonRect.Right, mtop + 2, buttonRect.Right, buttonRect.Bottom - 1);
                path.AddLine(buttonRect.Right - 4, buttonRect.Bottom - 1, buttonRect.Left, buttonRect.Bottom - 1);
                path.CloseFigure();
                try {
                    if(currentItem == SelectedItem) {
                        brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical);
                    } else {
                        brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
                    }
                }catch(Exception) {

                }
                g.FillPath(brush, path);
                Pen pen = SystemPens.ControlDark;
                if (currentItem == SelectedItem)
                {
                    pen = new Pen(ToolStripRenderer.ColorTable.MenuStripGradientBegin);
                }
                g.DrawPath(pen, path);
                if (currentItem == SelectedItem)
                {
                    pen.Dispose();
                }

                if (currentItem == SelectedItem)
                {
                    g.DrawLine(new Pen(brush), buttonRect.Left - 9, buttonRect.Height + 2, buttonRect.Left + buttonRect.Width - 1, buttonRect.Height + 2);
                }

                PointF textLoc = new PointF(buttonRect.Left + buttonRect.Height - 4, buttonRect.Top + (buttonRect.Height / 2) - (textSize.Height / 2) - 3);
                RectangleF textRect = buttonRect;
                textRect.Location = textLoc;
                textRect.Width = (float)buttonRect.Width - (textRect.Left - buttonRect.Left) - 4;
                textRect.Height = textSize.Height + currentFont.Size / 2;

                if (currentItem == SelectedItem)
                {
                    //textRect.Y -= 2;
                    g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), textRect, sf);
                }
                else
                {
                    g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), textRect, sf);
                }
            }

            #endregion

            #region Draw Right-To-Left Tab

            if (RightToLeft == RightToLeft.Yes)
            {
                if (currentItem == SelectedItem || isFirstTab)
                {
                    path.AddLine(buttonRect.Right + 10, buttonRect.Bottom - 1, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 4);
                }
                else
                {
                    path.AddLine(buttonRect.Right, buttonRect.Bottom - 1, buttonRect.Right, buttonRect.Bottom - (buttonRect.Height / 2) - 2);
                    path.AddLine(buttonRect.Right, buttonRect.Bottom - (buttonRect.Height / 2) - 3, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 3);
                }

                path.AddLine(buttonRect.Right - (buttonRect.Height / 2) - 2, mtop, buttonRect.Left + 3, mtop);
                path.AddLine(buttonRect.Left, mtop + 2, buttonRect.Left, buttonRect.Bottom - 1);
                path.AddLine(buttonRect.Left + 4, buttonRect.Bottom - 1, buttonRect.Right, buttonRect.Bottom - 1);
                path.CloseFigure();

                if (currentItem == SelectedItem)
                {
                    brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical);
                }
                else
                {
                    brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
                }

                g.FillPath(brush, path);
                g.DrawPath(SystemPens.ControlDark, path);

                if (currentItem == SelectedItem)
                {
                    g.DrawLine(new Pen(brush), buttonRect.Right + 9, buttonRect.Height + 2, buttonRect.Right - buttonRect.Width + 1, buttonRect.Height + 2);
                }

                PointF textLoc = new PointF(buttonRect.Left + 2, buttonRect.Top + (buttonRect.Height / 2) - (textSize.Height / 2) - 2);
                RectangleF textRect = buttonRect;
                textRect.Location = textLoc;
                textRect.Width = (float)buttonRect.Width - (textRect.Left - buttonRect.Left) - 10;
                textRect.Height = textSize.Height + currentFont.Size / 2;

                if (currentItem == SelectedItem)
                {
                    textRect.Y -= 1;
                    g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), textRect, sf);
                }
                else
                {
                    g.DrawString(currentItem.Title, currentFont, new SolidBrush(ForeColor), textRect, sf);
                }

                //g.FillRectangle(Brushes.Red, textRect);
            }

            #endregion

            currentItem.IsDrawn = true;
        }
예제 #45
0
        public void RemoveTab(TabControlItem tabItem)
        {
            int tabIndex = Items.IndexOf(tabItem);
            bool wasSelected = tabItem.Selected;

            if (tabIndex >= 0)
            {
                UnSelectItem(tabItem);
                Items.Remove(tabItem);
            }

            if (wasSelected)
            {
                if (Items.Count > 0)
                {
                    if (RightToLeft == RightToLeft.No)
                    {
                        if (Items[tabIndex - 1] != null)
                        {
                            SelectedItem = Items[tabIndex - 1];
                        }
                        else
                        {
                            SelectedItem = Items.FirstVisible;
                        }
                    }
                    else
                    {
                        if (Items[tabIndex + 1] != null)
                        {
                            SelectedItem = Items[tabIndex + 1];
                        }
                        else
                        {
                            SelectedItem = Items.LastVisible;
                        }
                    }
                }
                else
                    SelectedItem = null;
            }
        }
        public virtual TabControlItem MoveTo(int newIndex, TabControlItem item)
        {
            int currentIndex = List.IndexOf(item);
            if (currentIndex >= 0)
            {
                RemoveAt(currentIndex);
                Insert(0, item);

                return item;
            }

            return null;
        }
 public virtual void Remove(TabControlItem item)
 {
     if (List.Contains(item))
         List.Remove(item);
 }
예제 #48
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            try {
                base.OnMouseUp(e);
                if(downItem != null) {
                    TabControlItem upItem = GetTabItemByPoint(e.Location);
                    if(upItem != downItem) {
                        //perform swap
                        int downIndex = this.items.IndexOf(downItem);
                        int newIndex = downIndex;

                        if(e.X >= downItem.Left) {
                            newIndex = downIndex + 1;
                        } else {
                            newIndex = downIndex - 1;
                        }

                        if(newIndex > this.Items.Count - 1) newIndex = this.Items.Count - 1;
                        if(newIndex <= 0) newIndex = 0;
                        this.items.Remove(downItem);
                        this.items.Insert(newIndex, downItem);

                    }
                }
                downItem = null;
            } catch(Exception exc) { }
        }
예제 #49
0
 internal void UnSelectItem(TabControlItem tabItem)
 {
     //tabItem.Visible = false;
     tabItem.Selected = false;
 }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     TabControl = component as TabControlItem;
 }
예제 #51
0
        private bool AllowDraw(TabControlItem item)
        {
            bool 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;
        }
예제 #52
0
 public void CloseTab(TabControlItem tabItem)
 {
     if (tabItem != null)
     {
         this.SelectedItem = tabItem;
         TabControlItemClosingEventArgs args = new TabControlItemClosingEventArgs(SelectedItem);
         OnTabControlItemClosing(args);
         if (SelectedItem != null && !args.Cancel && SelectedItem.CanClose)
         {
             RemoveTab(SelectedItem);
             OnTabControlItemClosed(EventArgs.Empty);
         }
     }
 }
예제 #53
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if(e.Button != MouseButtons.Left) {
                return;
            }
            downItem = GetTabItemByPoint(e.Location);
            if (menuGlyph.Rect.Contains(e.Location))
            {
                HandledEventArgs args = new HandledEventArgs(false);
                OnMenuItemsLoading(args);
                if (!args.Handled)
                    OnMenuItemsLoad(EventArgs.Empty);

                OnMenuShow();
            }
            else if (closeButton.Rect.Contains(e.Location))
            {
                if (SelectedItem != null)
                {
                    TabControlItemClosingEventArgs args = new TabControlItemClosingEventArgs(SelectedItem);
                    OnTabControlItemClosing(args);
                    if (SelectedItem!=null && !args.Cancel && SelectedItem.CanClose)
                    {
                        RemoveTab(SelectedItem);
                        OnTabControlItemClosed(EventArgs.Empty);
                    }
                }
            }
            else
            {
                TabControlItem item = GetTabItemByPoint(e.Location);
                if (item != null)
                    SelectedItem = item;
            }

            Invalidate();
        }
 public virtual int Add(TabControlItem item)
 {
     int res = IndexOf(item);
     if (res == -1) res = List.Add(item);
     return res;
 }
예제 #55
0
        private void OnCalcTabPage(Graphics g, TabControlItem currentItem)
        {
            Font currentFont = this.Font;
            if (currentItem == SelectedItem)
                currentFont = new Font(this.Font, FontStyle.Bold);

            SizeF textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, 10), sf);
            textSize.Width += 20;

            if (RightToLeft == RightToLeft.No)
            {
                RectangleF buttonRect = new RectangleF(DEF_START_POS, 3, textSize.Width, 17);
                currentItem.StripRect = buttonRect;
                DEF_START_POS += (int)textSize.Width;
            }
            else
            {
                RectangleF buttonRect = new RectangleF(DEF_START_POS - textSize.Width + 1, 3, textSize.Width - 1, 17);
                currentItem.StripRect = buttonRect;
                DEF_START_POS -= (int)textSize.Width;
            }
        }
 public virtual void AddRange(TabControlItem[] items)
 {
     BeginUpdate();
     try
     {
         foreach (TabControlItem item in items)
         {
             List.Add(item);
         }
     }
     finally
     {
         EndUpdate();
     }
 }
예제 #57
0
        private void TcTerminals_TabControlMouseOnTitle(TabControlMouseOnTitleEventArgs e)
        {
            if (settings.ShowInformationToolTips)
            {
                if (this.currentToolTip == null)
                {
                    this.currentToolTip = new ToolTip();
                    this.currentToolTip.Active = false;
                }
                else if ((this.currentToolTipItem != null) && (this.currentToolTipItem != e.Item))
                {
                    this.currentToolTip.Hide(this.currentToolTipItem);
                    this.currentToolTip.Active = false;
                }

                if (!this.currentToolTip.Active)
                {
                    this.currentToolTip = new ToolTip();
                    this.currentToolTip.ToolTipTitle = Program.Resources.GetString("ConnectionInformation");
                    this.currentToolTip.ToolTipIcon = ToolTipIcon.Info;
                    this.currentToolTip.UseFading = true;
                    this.currentToolTip.UseAnimation = true;
                    this.currentToolTip.IsBalloon = false;
                    this.currentToolTip.Show(e.Item.ToolTipText, e.Item, (int)e.Item.StripRect.X, 2);
                    this.currentToolTipItem = e.Item;
                    this.currentToolTip.Active = true;
                }
            }
        }
예제 #58
0
        private void SwapTabItems(int mouseX, TabControlItem upItem)
        {
            int downIndex = this.items.IndexOf(this.tabAtMouseDown);
            int newIndex = this.items.IndexOf(upItem);

            int upCentre = 48 + newIndex * 87;
            if (downIndex < newIndex)
            {
                newIndex--;
                upCentre += 10;
            }

            if (mouseX >= upCentre)
            {
                newIndex++;
            }

            if (newIndex > this.Items.Count - 1)
            {
                newIndex = this.Items.Count - 1;
            }
            if (newIndex <= 0)
            {
                newIndex = 0;
            }
            this.items.Remove(this.tabAtMouseDown);
            this.items.Insert(newIndex, this.tabAtMouseDown);
        }
 private void RemoveTabPage(TabControlItem tabControlToRemove)
 {
     this.tcTerminals.RemoveTab(tabControlToRemove);
     CloseTabControlItem();
 }
예제 #60
0
 public void AddTab(TabControlItem tabItem)
 {
     Items.Add(tabItem);
     tabItem.Dock = DockStyle.Fill;
 }