Example #1
0
 protected internal virtual void OnTabControlItemClosing(TabControlItemClosingEventArgs e)
 {
     if (this.TabControlItemClosing != null)
     {
         this.TabControlItemClosing(e);
     }
 }
Example #2
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 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);
             }
         }
     }
 }
        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();
        }
 private void TcTerminals_TabControlItemClosing(TabControlItemClosingEventArgs e)
 {
     IConnection currentConnection = this.mainForm.CurrentConnection;
     if (currentConnection != null && currentConnection.Connected)
     {
         if (AskToClose()) // ask only when tab is going to be closed by user
         {
             // Expecting all connections are disposable, because derive from Connection
             currentConnection.Dispose();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Example #6
0
 private void tabControl1_TabControlItemClosing(TabControlItemClosingEventArgs e)
 {
     if (this.tabControl1.Items.Count <= 1)
     {
         this.Close();
     }
 }
Example #7
0
 private void tcTerminals_TabControlItemClosing(TabControlItemClosingEventArgs e)
 {
     if(CurrentConnection != null && CurrentConnection.Connected)
     {
         bool close = false;
         if(Settings.WarnOnConnectionClose)
         {
             close = (MessageBox.Show(this, "Are you sure that you want to disconnect from the active terminal?",
            "Terminals", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
         }
         else
         {
             close = true;
         }
         if(close)
         {
             if(CurrentTerminal != null) CurrentTerminal.Disconnect();
             if(CurrentConnection != null) CurrentConnection.Disconnect();
             this.Text = Program.AboutText;
             e.Cancel = false;
         }
         else
         {
             e.Cancel = true;
         }
     }
     else
     {
         e.Cancel = false;
     }
 }
 protected internal virtual void OnTabControlItemClosing(TabControlItemClosingEventArgs e)
 {
     if (TabControlItemClosing != null)
         TabControlItemClosing(e);
 }
 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);
         }
     }
 }
        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();
        }