Exemple #1
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Rectangle closeButton = GetCloseButtonRect(GetTabRect(SelectedIndex));
         if (closeButton.Contains(e.Location))
         {
             TabPages.Remove(SelectedTab);
         }
     }
 }
 private void CloseAllTabs_BarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     foreach (XtraTabPage tabPage in xtraTabControl1.TabPages)
     {
         if (TabPages.ContainsKey(tabPage.Name))
         {
             TabPages.Remove(tabPage.Name);
         }
     }
     xtraTabControl1.TabPages.Clear();
 }
Exemple #3
0
 public void Remove(PaneModel model)
 {
     if (model is TabPageModel document)
     {
         TabPages.Remove(document);
     }
     if (model is ToolPaneModel tool)
     {
         tool.IsVisible = false;
     }
 }
Exemple #4
0
        /*
         * OnTabPageAdded
         */

        /// <summary>
        /// Will bubble the <see cref="E:Genetibase.Controls.NuGenTabbedMdi.TabPageAdded"/> event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTabPageAdded(NuGenCollectionEventArgs <NuGenTabPage> e)
        {
            base.OnTabPageAdded(e);

            if (TabPages.Count > 1 && TabPages.Contains(BlankPage))
            {
                TabPages.Remove(BlankPage);
            }

            OnStateChanged(new MdiStateEventArgs(IsEmpty));
        }
Exemple #5
0
 private void CloseTab(int i)
 {
     if (PreRemoveTabPage != null)
     {
         bool closeIt = PreRemoveTabPage(i);
         if (!closeIt)
         {
             return;
         }
     }
     TabPages.Remove(TabPages[i]);
 }
Exemple #6
0
        private void RemoveTabPage(ITabPage tabPage)
        {
            if (tabPage.CanClose)
            {
                TabPages.Remove(tabPage);

                if (tabPage is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }
        }
Exemple #7
0
        public void CloseFile(FileEditorTab fileTab)
        {
            // TODO: Make AskToSaveFile so that it also has a CANCEL button
            //
            fileTab.AskToSaveFile();
            TabPages.Remove(fileTab);

            if (TabCount == 0)
            {
                this.AddNewFile();
            }
        }
Exemple #8
0
 public void ShowTabPage(bool show, System.Windows.Forms.TabPage page)
 {
     if (show)
     {
         InsertTabPage(_TabPageOrder, page);
         return;
     }
     if (TabPages.Contains(page))
     {
         TabPages.Remove(page);
     }
 }
Exemple #9
0
        private void CloseTabPage(ReportTabPage tabPage)
        {
            int  tabPageIndex          = 0;
            bool needRefreshReportTree = false;

            for (int i = 0; i < TabPages.Count; i++)
            {
                if (TabPages[i] == tabPage)
                {
                    tabPageIndex = i;
                    break;
                }
            }
            if (tabPage.IsEditing)
            {
                DialogResult dr = MessageBox.Show("是否将更改保存到 " + tabPage.Text.Substring(0, tabPage.Text.Length - 1) + "?", "保存", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (dr == DialogResult.Cancel)
                {
                    return;
                }
                if (dr == DialogResult.Yes)
                {
                    int i = tabPage.Save();
                    //如果未保存成功,则返回。
                    if (i < 0)
                    {
                        return;
                    }
                    //若保存成功,则需刷新报表树。
                    needRefreshReportTree = true;
                }
            }
            //防止闪烁,将removeReportTabPageByCode置为true。参见OnSelecting方法。
            removeReportTabPageByCode = true;
            TabPages.Remove(tabPage);
            removeReportTabPageByCode = false;
            //通知窗体有报表被关闭。主要用于当界面已经没有报表时,将焦点置于树,以达到清空工具栏的目的。
            if (ReportTablePageClosed != null)
            {
                ReportTablePageClosed(this, tabPage, needRefreshReportTree);
            }
            //如果被关闭页在中间,则将它右侧的页置于前端。
            if (TabPages.Count > tabPageIndex)
            {
                SelectedIndex = tabPageIndex;
            }
            //否则,将最后一页置于前端。
            else
            {
                SelectedIndex = TabPages.Count - 1;
            }
        }
Exemple #10
0
        public bool RemovePage(Control bodyControl)
        {
            Page page = TabPages.Find(p => p.Body == bodyControl);

            if (page != null)
            {
                return(TabPages.Remove(page));
            }
            else
            {
                return(false);
            }
        }
        private void closeOtherTabsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (TabPage tabPage in TabPages)
            {
                if (tabPage != SelectedTab && tabPage != addTabPage)
                {
                    TabPages.Remove(tabPage);
                }
            }
            // Documents.Remove(this.SelectedTab.Text);

            //this.TabPages.();
        }
Exemple #12
0
        /// <summary>
        /// Removes a tab page, but keeps a reference to it to allow showing it again later.
        /// </summary>
        public void HidePage(TabPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (TabPages.Contains(page))
            {
                TabPages.Remove(page);
                m_hiddenPages.Add(page);
            }
        }
        private void Close_Click(object sender, EventArgs e)
        {
            if (TabPages.Count <= 1)
            {
                return;
            }
            EditorTab tab = (EditorTab)contextMenuStrip.Tag;

            if (tab.CanClose())
            {
                TabPages.Remove(tab);
            }
        }
        public EditorTab LoadBlank(string file, CodeEditor editor)
        {
            EditorTab newTab = new EditorTab(file, editor);

            TabPages.Add(newTab);
            foreach (TabPage page in TabPages)
            {
                if (page != newTab)
                {
                    TabPages.Remove(page);
                }
            }
            return(newTab);
        }
Exemple #15
0
        void TabBar_ItemClose(object sender, TabItemEventArgs e)
        {
            Page page = TabPages.Find(p => p.Header == e.Item);

            if (page != null)
            {
                TabPages.Remove(page);
            }

            if (TabItemClose != null)
            {
                TabItemClose(this, e);
            }
        }
Exemple #16
0
        public void CloseTab(TabPage tp)
        {
            ClosingEventArgs args = new ClosingEventArgs(TabPages.IndexOf(tp));

            OnTabClosing(args);
            //Remove the tab and fir the event tot he client
            if (!args.Cancel)
            {
                // close and remove the tab, dispose it too
                TabPages.Remove(tp);
                OnTabClosed(new ClosedEventArgs(tp));
                tp.Dispose();
            }
        }
Exemple #17
0
 /// <summary>
 /// Закрытие вкладки
 /// </summary>
 /// <param name="i">Порядковый номер вкладки</param>
 private void CloseTab(int i)
 {
     if (PreRemoveTabPage != null)
     {
         bool closeIt = PreRemoveTabPage(i);
         if (!closeIt)
         {
             return;
         }
     }
     if (!TabPages[i].Text.Equals("Список оборудования"))
     {
         TabPages.Remove(TabPages[i]);
     }
 }
Exemple #18
0
        private void OnTabVisibleChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender != null && sender is MvcTabPage);
            MvcTabPage tabPage = (MvcTabPage)sender;

            if (!tabPage.Visible)
            {
                TabPages.Remove(tabPage);
            }
            else //from non visible to  visible: need to insert
            {
                int index = FindIndexToInsert(tabPage);

                TabPages.Insert(index, tabPage);
            }
        }
Exemple #19
0
        public bool CloseTab(TabPage tab)
        {
            if (!ConfirmCloseTab(tab))
            {
                return(false);
            }

            TabPages.Remove(tab);
            tab.Dispose();
            if (TabWindowsChanged != null)
            {
                TabWindowsChanged(TabPages);
            }

            return(true);
        }
Exemple #20
0
        // Closes a tab
        private void CloseTab(TabPage tab)
        {
            if (tab == null)
            {
                return;
            }

            // Remove tab
            TabPages.Remove(tab);

            // Notify
            if (TabClosed != null)
            {
                TabClosed(this, tab);
            }
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            RectangleF tabTextArea = GetTabRect(SelectedIndex);

            tabTextArea = new RectangleF(tabTextArea.X + tabTextArea.Width - CLOSE_AREA, tabTextArea.Y, 13, 13);
            Point pt = new Point(e.X, e.Y);

            if (tabTextArea.Contains(pt))
            {
                var wr = SelectedTab.Tag as CodeItem;
                if (wr == null)
                {
                    TabPages.Remove(SelectedTab);
                    return;
                }

                if (wr.State == CodeItemState.Draft)
                {
                    //if (Options.Instance.AutoSaveWhenLeaving)
                    //{
                    //    wr.Save();
                    //}
                    //else
                    {
                        var message = "You did not save your changes. Are you sure you want to close this tab?";
                        if (
                            MessageBox.Show(this, message, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
                            DialogResult.No)
                        {
                            return;
                        }
                        //else
                        //{
                        //    wr.CancelChange();
                        //}
                        //}
                    }

                    TabPages.Remove(SelectedTab);
                }
                else
                {
                    TabPages.Remove(SelectedTab);
                }
            }
        }
Exemple #22
0
        private void Tabs_MouseClick(object sender, MouseEventArgs e)
        {
            Point     p   = e.Location;
            Rectangle r   = GetTabRect(SelectedIndex);
            Image     img = new Bitmap(Properties.Resources.closebutton);

            r.X      = r.X + r.Width - img.Width - 5;
            r.Width  = img.Width;
            r.Height = img.Height;
            if (SelectedIndex >= 1)
            {
                if (r.Contains(p))
                {
                    TabPage TabP = (TabPage)TabPages[SelectedIndex];
                    TabPages.Remove(TabP);
                }
            }
        }
Exemple #23
0
        private void CloseTab(int i)
        {
            if (PreRemoveTabPage != null)
            {
                bool closeIt = PreRemoveTabPage(i);
                if (!closeIt)
                {
                    return;
                }
            }
            //raise remove tab event
            if (OnRemoveTabEventHandler != null)
            {
                OnRemoveTabEventHandler(null, i);
            }

            TabPages.Remove(TabPages[i]);
        }
Exemple #24
0
        private void CloseTab(int i)
        {
            TabPage page = TabPages[i];

            TabPages.Remove(page);
            if (TabPages.Count > i)
            {
                SelectTab(i);
            }
            else
            {
                i--;
                if (i >= 0 && TabPages.Count > i)
                {
                    SelectTab(i);
                }
            }
            OnTabeClosed(new TabClosedEventArgs(page));
        }
Exemple #25
0
        private void WebTab_MouseClick(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < TabCount; i++)
            {
                Rectangle bounds = GetTabRect(i);
                int       x1     = bounds.X + bounds.Width - MARGIN - 8;
                int       x2     = x1 + 8;
                int       y1     = bounds.Y + (bounds.Height - 8) / 2;
                int       y2     = y1 + 8;

                if (e.X >= x1 && e.X <= x2 && e.Y >= y1 && e.Y <= y2)
                {
                    int id = SelectedIndex;
                    TabPages.Remove(TabPages[i]);
                    SelectedIndex = Math.Min(TabPages.Count - 1, id);
                    return;
                }
            }
        }
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            TabPage clickedTab = TabAt(e.Location);

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (MerthsoftExtensions.IsRunningOnMono())
                {
                    return;
                }
                m_DraggedTab = clickedTab;
                break;

            case MouseButtons.Middle:
                TabCloseEventHandler temp = TabClose;
                if (temp != null)
                {
                    TabCloseEventArgs args = new TabCloseEventArgs(clickedTab);
                    temp(this, args);
                    if (!args.Cancel)
                    {
                        TabPages.Remove(clickedTab);
                    }
                }
                break;

            case MouseButtons.None:
                break;

            case MouseButtons.Right:
                break;

            case MouseButtons.XButton1:
                break;

            case MouseButtons.XButton2:
                break;

            default:
                break;
            }
        }
Exemple #27
0
        private void CloseTab(int i)
        {
            //if (PreRemoveTabPage != null)
            //{
            //    bool closeIt = PreRemoveTabPage(i);
            //    if (!closeIt)
            //        return;
            //}

            if (closedelage != null)
            {
                bool closeIt = closedelage(i);
                if (!closeIt)
                {
                    return;
                }
            }
            TabPages.Remove(TabPages[i]);
        }
Exemple #28
0
 private void CloseTab(int i)
 {
     if (TabPages.Count != 1)
     {
         if (PreRemoveTabPage != null)
         {
             bool closeIt = PreRemoveTabPage(i);
             if (!closeIt)
             {
                 return;
             }
         }
         TabPages.Remove(TabPages[i]);
     }
     else
     {
         Application.Exit();
     }
 }
        public void TabPageRemove(TabPage tp)
        {
            int i = SelectedTab == tp ? SelectedIndex == TabCount - 1 ? SelectedIndex - 1 : SelectedIndex : -1;

            if (TabPageRemoving != null)
            {
                TabControlCancelEventArgs tccea = new TabControlCancelEventArgs(tp, TabPages.IndexOf(tp), false, TabControlAction.Deselecting);
                TabPageRemoving(this, tccea);
                if (tccea.Cancel)
                {
                    return;
                }
            }
            TabPages.Remove(tp);
            if (i >= 0)
            {
                SelectedIndex = i;
            }
        }
Exemple #30
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            var tabTextArea = (RectangleF)GetTabRect(SelectedIndex);
            var icon        = new Rectangle((int)tabTextArea.X, (int)tabTextArea.Y, (int)tabTextArea.Width, (int)tabTextArea.Height);

            tabTextArea =
                new RectangleF(tabTextArea.X + tabTextArea.Width - 16, 4, 16, 16);
            var pt = new Point(e.X, e.Y);

            if (tabTextArea.Contains(pt))
            {
                // IDispose not appropriate.
                if (SelectedTab.Tag is IClearUp icu)
                {
                    icu.ClearUp();
                }
                TabPages.Remove(SelectedTab);
                _itr?.Invoke();
            }
        }