Ejemplo n.º 1
0
        public TabItem CloseCurrentTab()
        {
            int pos = items.IndexOf(selectedItem);

            if (pos == items.Count-1)
                pos--;

            items.Remove(selectedItem);
            if (pos >= 0)
                selectedItem = items[pos];
            else
                selectedItem = null;
            Refresh();
            return selectedItem;
        }
Ejemplo n.º 2
0
 void tabBar1_SelectedTabChanged(TabItem obj)
 {
     if (obj != null)
     {
         ideCanvas.Page = obj.assocItem as Classes.IGuiPage;
     }
     else
         ideCanvas.Page = null;
 }
Ejemplo n.º 3
0
 void i_Click(object sender, EventArgs e)
 {
     selectedItem = (sender as ToolStripMenuItem).Tag as TabItem;
     Refresh();
 }
Ejemplo n.º 4
0
 public void AddTab(TabItem m)
 {
     items.Add(m);
     selectedItem = m;
     this.Refresh();
 }
Ejemplo n.º 5
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            lastPoint = e.Location;

            if (e.Button == System.Windows.Forms.MouseButtons.None && items.Count>0)
            {
                bool intersectsPlus = e.Location.X >= this.Width - 26;
                bool refresh = false;

                if (intersectsPlus)
                {
                    hoverItem = null;
                    plusHover = true;
                    refresh = true;
                }
                else
                {
                    if (plusHover)
                    {
                        plusHover = false;
                        refresh = true;
                    }
                    bool isOnX = false;
                    TabItem i = GetHoverItem(e.Location, out isOnX);
                    if (hoverItem != i || (hoverItem == null && i != null))
                    {
                        hoverItem = i;
                        if (i != null && toolTip1.GetToolTip(this) != i.Type.ToString() + ": " + i.Title)
                            toolTip1.Show(i.Type.ToString() + ": " + i.Title, this, new Point(e.Location.X, e.Location.Y + 20));
                        refresh = true;
                    }

                    if ((isOnX && xHoverItem != i) || (!isOnX && xHoverItem != null))
                    {
                        if (isOnX)
                            xHoverItem = i;
                        else
                            xHoverItem = null;
                        refresh = true;
                    }

                }
                if (refresh)
                    Refresh();
            }
        }
Ejemplo n.º 6
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (e.Location.X >= this.Width - 26 && items.Count>0 && e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (!contextMenuStrip1.Visible && items.Count > 0)
                {
                    contextMenuStrip1.Items.Clear();
                    foreach (TabItem item in items)
                    {
                        ToolStripMenuItem i = new ToolStripMenuItem(item.Title);
                        i.Tag = item;
                        switch (item.Type)
                        {
                            case Classes.CodeType.Task:
                                i.Image = Properties.Resources.thread;
                                break;
                            case Classes.CodeType.Method:
                                i.Image = Properties.Resources.method;
                                break;
                            //case Classes.CodeType.Enum:
                            //    i.Image = Properties.Resources._enum;
                            //    break;
                            //case Classes.CodeType.Struct:
                            //    i.Image = Properties.Resources._struct;
                            //    break;
                        }
                        i.Click += new EventHandler(i_Click);
                        if (selectedItem == item)
                            i.Checked = true;
                        contextMenuStrip1.Items.Add(i);
                    }
                    contextMenuStrip1.Items.Add(new ToolStripSeparator());
                    contextMenuStrip1.Items.Add("Close All").Click += new EventHandler(tabBar_Click);

                    contextMenuStrip1.Show(this.PointToScreen(e.Location));
                }
            }
            else
            {
                bool x = false;
                TabItem i = GetHoverItem(e.Location, out x);

                if (i != null && x && e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    xHoverItem = null;
                    xClickItem = null;
                    if (selectedItem == i)
                    {
                        int pos = items.IndexOf(i);
                        if (pos < items.Count - 1)
                            selectedItem = items[pos + 1];
                        else if (pos > 0)
                            selectedItem = items[pos - 1];
                        else
                            selectedItem = null;
                    }
                    items.Remove(i);
                    Refresh();
                }
                else if (i != null)
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        selectedItem = i;
                    else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
                    {
                        if (i == selectedItem)
                            this.CloseCurrentTab();
                        else
                            items.Remove(i);
                    }
                    Refresh();
                }
            }
        }
Ejemplo n.º 7
0
 protected override void OnMouseLeave(EventArgs e)
 {
     hoverItem = xHoverItem = xClickItem = null;
     plusHover = false;
     lastPoint = Point.Empty;
     if (toolTip1.Active)
         toolTip1.Hide(this);
     Refresh();
     base.OnMouseLeave(e);
 }
Ejemplo n.º 8
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == System.Windows.Forms.MouseButtons.Left && items.Count>0)
            {
                if (e.Location.X < this.Width - 16)
                {
                    bool x = false;
                    TabItem i = GetHoverItem(e.Location, out x);

                    if (i != null && x)
                    {
                        xHoverItem = null;
                        xClickItem = i;
                        Refresh();
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public void SelectTab(Classes.IGuiPage e)
 {
     foreach (TabItem item in items)
     {
         if (item.assocItem == e)
         {
             selectedItem = item;
             this.Refresh();
             return;
         }
     }
 }
Ejemplo n.º 10
0
        public TabItem SelectPrevious()
        {
            if (items.Count > 1)
            {
                int i = items.IndexOf(selectedItem);

                if (i >= 1)
                    i--;
                else
                    i = items.Count - 1;

                selectedItem = items[i];
                Refresh();
            }
            return selectedItem;
        }
Ejemplo n.º 11
0
        public TabItem SelectNext()
        {
            if (items.Count > 1)
            {
                int i = items.IndexOf(selectedItem);

                if (i >= 0 && i < items.Count-1)
                    i++;
                else
                    i = 0;

                selectedItem = items[i];
                Refresh();
            }
            return selectedItem;
        }