Exemple #1
0
 /// <summary>
 /// Fires <see cref="TabStripItemClosing"/> event.
 /// </summary>
 /// <param name="e"></param>
 protected internal virtual void OnTabStripItemClosing(TabStripItemClosingEventArgs e)
 {
     if (TabStripItemClosing != null)
     {
         TabStripItemClosing(e);
     }
 }
Exemple #2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            HitTestResult result = HitTest(e.Location);

            if (result == HitTestResult.MenuGlyph)
            {
                HandledEventArgs args = new HandledEventArgs(false);
                OnMenuItemsLoading(args);

                if (!args.Handled)
                {
                    OnMenuItemsLoad(EventArgs.Empty);
                }

                ShowMenu();
            }
            else if (result == HitTestResult.CloseButton)
            {
                if (SelectedItem != null)
                {
                    TabStripItemClosingEventArgs args = new TabStripItemClosingEventArgs(SelectedItem);
                    OnTabStripItemClosing(args);
                    if (!args.Cancel && SelectedItem.CanClose)
                    {
                        RemoveTab(SelectedItem);
                        OnTabStripItemClosed(EventArgs.Empty);
                    }
                }
            }
            else if (result == HitTestResult.TabItem)
            {
                FATabStripItem item = GetTabItemByPoint(e.Location);
                if (item != null)
                {
                    SelectedItem = item;
                }
            }

            Invalidate();
        }