Ejemplo n.º 1
0
 public void OnAction(cnTabButton sender, TabButtonAction action)
 {
     if (Action != null)
     {
         Action(this, action);
     }
 }
Ejemplo n.º 2
0
        private void buttonAction(cnTabButton sender, TabButtonAction action)
        {
            if ((action == TabButtonAction.Left) || (action == TabButtonAction.Up))
            {
                offsetX -= tabWidth;
                if (offsetX < 0)
                {
                    offsetX = 0;
                }
            }
            else if ((action == TabButtonAction.Right) || (action == TabButtonAction.Down))
            {
                int l = tabWidth;
                if (tabView == TabControlView.OneNote)
                {
                    l += tabHeight / 2 + 3;
                }
                offsetX += l;
                int       full_l = l * TabPages.Count;
                Rectangle r      = this.GetBoundsHeader(0);
                Rectangle rb     = this.GetBoundsButtons();
                int       d;
                if ((Alignment == TabAlignment.Top) || (Alignment == TabAlignment.Bottom))
                {
                    d = r.Width - rb.Width;
                }
                else
                {
                    d = r.Height - rb.Height;
                }

                if (full_l < d)
                {
                    offsetX = 0;
                }
                else
                if (d + offsetX > full_l)
                {
                    offsetX = full_l - d;
                }
            }
            else if (action == TabButtonAction.Action)
            {
                ContextMenuStrip menu = new ContextMenuStrip();
                foreach (cnTabPage tb in TabPages)
                {
                    ToolStripMenuItem item = new System.Windows.Forms.ToolStripMenuItem();
                    item.Text = tb.Title;
                    int n = TabPages.IndexOf(tb);
                    item.Tag     = n;
                    item.Checked = (n == currentPage);
                    item.Click  += new System.EventHandler(ItemClickMenu);
                    menu.Items.Add(item);
                }
                menu.Show(sender, 0, sender.Size.Height);
            }
            Invalidate();
        }
Ejemplo n.º 3
0
        public void EndInit()
        {
            // Создадим кнопки
            buttons    = new cnTabButton[4];
            buttons[0] = new cnTabButton(this, TabButtonAction.Left);
            buttons[1] = new cnTabButton(this, TabButtonAction.Right);
            buttons[2] = new cnTabButton(this, TabButtonAction.Action);
            buttons[3] = new cnTabButton(this, TabButtonAction.Close);

            // Процесс создания кнопок завершен, можно их размещать на форме
            initProcess = false;
            // Разместим кнопки на форме...
            this.RelocationButtons();
            // и добавим их на нее
            for (int i = 0; i < 4; i++)
            {
                this.Controls.Add(buttons[i]);
                buttons[i].Action += new cnTabButton.ActionEventHandler(buttonAction);
            }
        }