public void AddTab(TabStripItem item)
 {
     if (!Items.Contains(item))
     {
         Items.Add(item);
     }
 }
 protected override void WndProc(ref Message msg)
 {
     if (msg.Msg == 0x201)
     {
         var selectionService = (ISelectionService)GetService(typeof(ISelectionService));
         if (selectionService != null)
         {
             Point location = Control.PointToClient(Cursor.Position);
             var   tabStrip = Control as TabStrip;
             if (tabStrip != null)
             {
                 TabStripItem tabStripItem = tabStrip.FindTabStripItem(location);
                 if (tabStripItem != null)
                 {
                     tabStrip.SelectedItem = tabStripItem;
                     var selection = new ArrayList {
                         tabStripItem
                     };
                     selectionService.SetSelectedComponents(selection);
                 }
             }
         }
     }
     base.WndProc(ref msg);
 }
 public void CloseTab(TabStripItem item)
 {
     if (!Items.Contains(item))
     {
         throw new Exception("Item not in collection");
     }
     CloseInternal(item);
 }
        private void OnItemSelected(TabStripItem item)
        {
            EventHandler <TabStripEventArgs> temp = TabStripItemSelected;

            if (temp != null)
            {
                temp(this, new TabStripEventArgs(item));
            }
            item.OnSelected();
        }
        private void OnItemMouseDown(TabStripItem item, MouseEventArgs e)
        {
            EventHandler <TabStripMouseEventArgs> temp = TabStripItemMouseDown;

            if (temp == null)
            {
                return;
            }
            temp(this, new TabStripMouseEventArgs(item, e));
        }
        private bool IsItemSelectingCanceled(TabStripItem item)
        {
            EventHandler <TabStripCancelEventArgs> temp = TabStripItemSelecting;

            if (temp == null)
            {
                return(false);
            }
            var args = new TabStripCancelEventArgs(item);

            temp(this, args);
            return(args.Cancel || item.IsSelectingCanceled());
        }
 protected override void OnMouseLeave(EventArgs e)
 {
     MouseOverItem                = null;
     MouseDownOverItem            = null;
     MouseOverItemCloseButton     = false;
     MouseOverMenuButton          = false;
     MouseDownOverItemCloseButton = false;
     if (_toolTip != null)
     {
         _toolTip.Hide(this);
         _toolTip = null;
     }
     Invalidate();
     base.OnMouseLeave(e);
 }
        private bool MouseOverHandler(Point location, MouseButtons buttons)
        {
            TabStripItem mouseOverItem = FindTabStripItem(location);
            bool         invalidate    = false;

            if (!ReferenceEquals(MouseOverItem, mouseOverItem))
            {
                MouseOverItem = mouseOverItem;
                invalidate    = true;
            }
            if (MouseOverItem != null)
            {
                bool mouseOverItemCloseButton = MouseOverItem.CloseButtonTabStripBounds.Contains(location);
                if (MouseOverItemCloseButton != mouseOverItemCloseButton)
                {
                    MouseOverItemCloseButton = mouseOverItemCloseButton;
                    invalidate = true;
                }
                if (_toolTip != null)
                {
                    if (!ReferenceEquals(_toolTip.Tag, MouseOverItem))
                    {
                        _toolTip.Hide(this);
                        _toolTip = null;
                    }
                }
                if (_toolTip == null)
                {
                    _toolTip     = new ToolTip();
                    _toolTip.Tag = MouseOverItem;
                    _toolTip.Show(MouseOverItem.ToolTip, this, location.X, Convert.ToInt32(_tabStripHeight) + 1);
                }
            }
            else if (_toolTip != null)
            {
                _toolTip.Hide(this);
                _toolTip = null;
            }
            if (!MouseDownOverItemCloseButton && MouseOverItem != null && MouseOverItem != SelectedItem &&
                MouseDownOverItem == SelectedItem && IsLeftMouseButtonDown(buttons))
            {
                int selectedItemIndex  = Items.IndexOf(SelectedItem);
                int mouseOverItemIndex = Items.IndexOf(MouseOverItem);
                Items.Move(selectedItemIndex, mouseOverItemIndex);
                invalidate = true;
            }
            return(invalidate);
        }
 private bool CloseInternal(TabStripItem item)
 {
     if (!IsItemClosingCanceled(item))
     {
         bool selected = ReferenceEquals(SelectedItem, item);
         int  index    = Items.IndexOf(item);
         if (index >= 0)
         {
             Items.Remove(item);
         }
         OnItemClosed(item);
         if (selected && Items.Count > 0)
         {
             SelectedItem = Items.Count > index ? Items[index] : Items[Items.Count - 1];
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 10
0
 private void SelectItemInternal(TabStripItem item)
 {
     if (item == null)
     {
         return;
     }
     item.SetFocus();
     if (SelectedItem == item)
     {
         return;
     }
     if (IsItemSelectingCanceled(item))
     {
         return;
     }
     SelectedItem = item;
     OnItemSelected(SelectedItem);
     Invalidate();
 }
Ejemplo n.º 11
0
        private void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_collectionReArrangedInternaly)
            {
                return;
            }
            if (e.NewItems != null)
            {
                TabStripItem lastItem = null;
                foreach (TabStripItem item in e.NewItems)
                {
                    lastItem = item;
                    if (Controls.Contains(item))
                    {
                        continue;
                    }
                    item.Visible = false;
                    Controls.Add(item);
                    item.Dock    = DockStyle.Fill;
                    item.Visible = false;
                }
                if (lastItem != null)
                {
                    SelectedItem = lastItem;
                }
            }
            if (e.OldItems != null)
            {
                foreach (TabStripItem item in e.OldItems)
                {
                    if (Controls.Contains(item))
                    {
                        Controls.Remove(item);
                    }
                }
            }

            UpdateLayout();
            Invalidate();
        }
Ejemplo n.º 12
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     _focusControl.Focus();
     MouseDownOverItemCloseButton = false;
     if (MouseOverMenuButton && IsLeftMouseButtonDown(e.Button))
     {
         MouseDownOverMenuButton = true;
         Invalidate();
         ShowItemsMenu(e.Location);
         return;
     }
     if (MouseOverItem == null)
     {
         return;
     }
     if (e.Button == MouseButtons.Middle)
     {
         CloseInternal(MouseOverItem);
         MouseOverItem                = null;
         MouseDownOverItem            = null;
         MouseDownOverItemCloseButton = false;
         return;
     }
     OnItemMouseDown(MouseOverItem, e);
     MouseDownOverItem = MouseOverItem;
     if (!IsLeftMouseButtonDown(e.Button))
     {
         return;
     }
     if (MouseOverItemCloseButton)
     {
         MouseDownOverItemCloseButton = true;
         Invalidate();
     }
     else
     {
         SelectItemInternal(MouseOverItem);
     }
 }
Ejemplo n.º 13
0
        private void DrawTabStripItemCloseButton(Graphics g, TabStripItem item)
        {
            bool mouseOverCloseButton = false;
            bool selected             = ReferenceEquals(item, SelectedItem);
            bool mouseDownOverItem    = ReferenceEquals(item, MouseDownOverItem);

            if (ReferenceEquals(item, MouseOverItem))
            {
                mouseOverCloseButton = MouseOverItemCloseButton;
            }
            else if (!selected && !mouseDownOverItem && !MouseDownOverItemCloseButton)
            {
                return;
            }
            RectangleF rect = item.CloseButtonTabStripBounds;
            var        pen  = new Pen(ForeColor, 2);

            if ((mouseDownOverItem && MouseDownOverItemCloseButton) ||
                (mouseOverCloseButton && MouseDownOverItem == null))
            {
                g.FillRectangle(MouseDownOverItemCloseButton ? _backColorBrush : _glyphFillBrush, rect);
                g.DrawRectangle(_glyphBorderPen, rect.X, rect.Y, rect.Width, rect.Height);
            }
            else if (selected)
            {
                pen = _selectedCloseButtonPen;
            }
            else
            {
                pen = _inActiveCloseButtonPen;
            }
            float left   = rect.X + 4;
            float top    = rect.Y + 4;
            float rigth  = rect.X + rect.Width - 4;
            float bottom = rect.Y + rect.Height - 4;

            g.DrawLine(pen, left, top, rigth, bottom);
            g.DrawLine(pen, rigth, top, left, bottom);
        }
Ejemplo n.º 14
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (MouseOverItem != null)
     {
         OnItemMouseUp(MouseOverItem, e);
         if (IsLeftMouseButtonDown(e.Button))
         {
             if (ReferenceEquals(MouseDownOverItem, MouseOverItem) && MouseDownOverItemCloseButton &&
                 MouseOverItemCloseButton &&
                 IsLeftMouseButtonDown(e.Button))
             {
                 CloseInternal(MouseOverItem);
                 MouseOverItem = null;
             }
             else
             {
                 if (MouseOverHandler(e.Location, e.Button))
                 {
                     Invalidate();
                 }
             }
         }
         else if (IsRightMouseButtonDown(e.Button))
         {
             SelectItemInternal(MouseOverItem);
             if (ContextMenuStrip != null)
             {
                 ContextMenuStrip.Show(this, e.Location);
             }
         }
     }
     if (MouseDownOverItemCloseButton || MouseDownOverItem != null)
     {
         Invalidate();
     }
     MouseDownOverItemCloseButton = false;
     MouseDownOverItem            = null;
 }
 public TabStripMouseEventArgs(TabStripItem item, MouseEventArgs e)
     : this(item, e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
 }
 public override IProjectFile Open()
 {
     if (_projectPropertiesEditor == null)
     {
         _projectPropertiesEditor = new ProjectPropertiesEditor(this);
         if (_tabItem != null)
         {
             _tabItem.Close();
         }
         _tabItem = TabStripItemFactory.CreateTabStripItem(_projectPropertiesEditor, this);
         _tabItem.Closed += TabItemClosed;
     }
     return this;
 }
 public TabStripEventArgs(TabStripItem item)
 {
     Item = item;
 }
 public void Close()
 {
     try
     {
         _closing = true;
         if (_tabItem != null)
         {
             _tabItem.Close();
             _tabItem = null;
         }
         if (_solutionPropertiesEditor != null)
         {
             _solutionPropertiesEditor.Dispose();
             _solutionPropertiesEditor = null;
         }
     }
     finally
     {
         _closing = false;
     }
 }
Ejemplo n.º 19
0
 private void DrawTabStripItemCloseButton(Graphics g, TabStripItem item)
 {
     bool mouseOverCloseButton = false;
     bool selected = ReferenceEquals(item, SelectedItem);
     bool mouseDownOverItem = ReferenceEquals(item, MouseDownOverItem);
     if (ReferenceEquals(item, MouseOverItem))
     {
         mouseOverCloseButton = MouseOverItemCloseButton;
     }
     else if (!selected && !mouseDownOverItem && !MouseDownOverItemCloseButton)
     {
         return;
     }
     RectangleF rect = item.CloseButtonTabStripBounds;
     var pen = new Pen(ForeColor, 2);
     if ((mouseDownOverItem && MouseDownOverItemCloseButton) ||
         (mouseOverCloseButton && MouseDownOverItem == null))
     {
         g.FillRectangle(MouseDownOverItemCloseButton ? _backColorBrush : _glyphFillBrush, rect);
         g.DrawRectangle(_glyphBorderPen, rect.X, rect.Y, rect.Width, rect.Height);
     }
     else if (selected)
     {
         pen = _selectedCloseButtonPen;
     }
     else
     {
         pen = _inActiveCloseButtonPen;
     }
     float left = rect.X + 4;
     float top = rect.Y + 4;
     float rigth = rect.X + rect.Width - 4;
     float bottom = rect.Y + rect.Height - 4;
     g.DrawLine(pen, left, top, rigth, bottom);
     g.DrawLine(pen, rigth, top, left, bottom);
 }
Ejemplo n.º 20
0
 private bool IsItemSelectingCanceled(TabStripItem item)
 {
     EventHandler<TabStripCancelEventArgs> temp = TabStripItemSelecting;
     if (temp == null) return false;
     var args = new TabStripCancelEventArgs(item);
     temp(this, args);
     return args.Cancel || item.IsSelectingCanceled();
 }
 public IProjectFile Open()
 {
     if (_solutionPropertiesEditor == null)
     {
         _solutionPropertiesEditor = new SolutionPropertiesEditor(this);
         if (_tabItem != null)
         {
             _tabItem.Close();
         }
         _tabItem = TabStripItemFactory.CreateTabStripItem(_solutionPropertiesEditor, this);
         _tabItem.Closed += TabItemClosed;
     }
     return this;
 }
Ejemplo n.º 22
0
 private bool CloseInternal(TabStripItem item)
 {
     if (!IsItemClosingCanceled(item))
     {
         bool selected = ReferenceEquals(SelectedItem, item);
         int index = Items.IndexOf(item);
         if (index >= 0) Items.Remove(item);
         OnItemClosed(item);
         if (selected && Items.Count > 0)
         {
             SelectedItem = Items.Count > index ? Items[index] : Items[Items.Count - 1];
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 23
0
 private void OnItemMouseUp(TabStripItem item, MouseEventArgs e)
 {
     EventHandler<TabStripMouseEventArgs> temp = TabStripItemMouseUp;
     if (temp == null) return;
     temp(this, new TabStripMouseEventArgs(item, e));
 }
Ejemplo n.º 24
0
 public override IProjectFile Open()
 {
     if (_textEditor == null)
     {
         _textEditor = new TextEditorContainer(FileSystemPath);
         if (_tabItem != null)
         {
             _tabItem.Close();
         }
         _tabItem = TabStripItemFactory.CreateTabStripItem(_textEditor, this);
         _tabItem.Closed += TabItemClosed;
     }
     return this;
 }
Ejemplo n.º 25
0
 private void OnItemSelected(TabStripItem item)
 {
     EventHandler<TabStripEventArgs> temp = TabStripItemSelected;
     if (temp != null)
     {
         temp(this, new TabStripEventArgs(item));
     }
     item.OnSelected();
 }
 public TabStripMouseEventArgs(TabStripItem item, MouseButtons button, int clicks, int x, int y, int delta)
     : base(button, clicks, x, y, delta)
 {
     Item = item;
 }
Ejemplo n.º 27
0
 private void SelectItemInternal(TabStripItem item)
 {
     if (item == null) return;
     item.SetFocus();
     if (SelectedItem == item) return;
     if (IsItemSelectingCanceled(item)) return;
     SelectedItem = item;
     OnItemSelected(SelectedItem);
     Invalidate();
 }
 public TabStripEventArgs(TabStripItem item)
 {
     Item = item;
 }
Ejemplo n.º 29
0
 public void AddTab(TabStripItem item)
 {
     if (!Items.Contains(item))
     {
         Items.Add(item);
     }
 }
 public TabStripMouseEventArgs(TabStripItem item, MouseEventArgs e)
     : this(item, e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
 }
Ejemplo n.º 31
0
 public void CloseTab(TabStripItem item)
 {
     if (!Items.Contains(item)) throw new Exception("Item not in collection");
     CloseInternal(item);
 }
Ejemplo n.º 32
0
 public TabStripCancelEventArgs(TabStripItem item)
 {
     Item = item;
 }
 public TabStripCancelEventArgs(TabStripItem item)
 {
     Item = item;
 }
Ejemplo n.º 34
0
 public override void Close()
 {
     try
     {
         _closing = true;
         if (_tabItem != null)
         {
             _tabItem.Close();
             _tabItem = null;
         }
         if (_textEditor != null)
         {
             _textEditor.Dispose();
             _textEditor = null;
         }
     }
     finally
     {
         _closing = false;
     }
 }
 public TabStripMouseEventArgs(TabStripItem item, MouseButtons button, int clicks, int x, int y, int delta)
     : base(button, clicks, x, y, delta)
 {
     Item = item;
 }