Exemple #1
0
        UiLayoutTabControl CreateNewTabControl(TabControl template)
        {
            var newTabControl = new UiLayoutTabControl();

            newTabControl.Dock       = DockStyle.Fill;
            newTabControl.AllowDrop  = true;
            newTabControl.Appearance = template.Appearance;
            newTabControl.Multiline  = true;
            newTabControl.DragDrop  += new System.Windows.Forms.DragEventHandler(this.tabControl_DragDrop);
            newTabControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.tabControl_DragEnter);
            newTabControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tabControl_MouseDown);
            newTabControl.MouseMove += new System.Windows.Forms.MouseEventHandler(this.tabControl_MouseMove);
            newTabControl.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.tabControl_MouseUp);
            return(newTabControl);
        }
Exemple #2
0
        private void menuMvc_Opening(object sender, CancelEventArgs e)
        {
            if (!_M.ContextMenuEnabled)
            {
                e.Cancel = true; return;
            }
            _MvcMenuParent = null;
            _MvcMenuButton = null;
            _MvcMenuTabs   = null;
            var parent = (sender as ContextMenuStrip).SourceControl;

            while (parent != null && !(parent is SplitterPanel || parent is Panel))
            {
                parent = parent.Parent;
            }
            if (parent == null)
            {
                e.Cancel = true; return;
            }
            _MvcMenuParent = parent;
            _MvcMenuButton = parent.Controls[0] as Button;
            _MvcMenuTabs   = parent.Controls[1] as UiLayoutTabControl;
            hideTabsToolStripMenuItem.Checked      = !_MvcMenuTabs.TabsVisible;
            hideMvcButtonToolStripMenuItem.Enabled = parent != _M.Root;
            layoutSaveToolStripMenuItem.Enabled    = !_M.IsMaximized;
            var sc = parent.Parent as SplitContainer;

            fixedSizeTabToolStripMenuItem.Enabled = sc != null &&
                                                    (sc.FixedPanel == FixedPanel.None ||
                                                     sc.FixedPanel == FixedPanel.Panel1 && sc.Panel1 == parent ||
                                                     sc.FixedPanel == FixedPanel.Panel2 && sc.Panel2 == parent);
            fixedSizeTabToolStripMenuItem.Checked = fixedSizeTabToolStripMenuItem.Enabled && sc.FixedPanel != FixedPanel.None;
            fullScreenToolStripMenuItem.Checked   = _M.MainForm.FormBorderStyle == System.Windows.Forms.FormBorderStyle.None;

            var items = _ButtonMenu.Items;
            var c     = _UiLayoutFixedMenuItemsCount;

            while (items.Count > c)
            {
                items.RemoveAt(c);
            }
            var tabs = _MvcMenuTabs;

            if (tabs != null)
            {
                items.AddRange(tabs.TabPages.AsEnumerable().Where(tp => !(tp is UiLayoutManager.LayoutTabPage)).Select(tp => {
                    var i = new ToolStripMenuItem {
                        Text = tp.Name.Substring(3), Checked = true, Tag = tp
                    };
                    i.Click += tabMenuItem_Click;
                    return(i as ToolStripItem);
                }).OrderBy(tsi => tsi.Text).ToArray());
            }
            var inUse = new HashSet <TabPage>(
                _M.Root.AllChildControls().Where(acc => acc is UiLayoutTabControl)
                .SelectMany(acc => (acc as UiLayoutTabControl).TabPages.AsEnumerable()));

            items.AddRange(
                _M.AllTabs.Where(tp => !inUse.Contains(tp)).Select(tp => {
                var menuText = (tp.Name?.Length ?? 0) > 3 ? tp.Name.Substring(3) : tp.Text;
                var i        = new ToolStripMenuItem {
                    Text = menuText, Checked = false, Tag = tp
                };
                i.Click += tabMenuItem_Click;
                return(i as ToolStripItem);
            }).OrderBy(tsi => tsi.Text).ToArray());
        }