Exemple #1
0
        /// <summary>
        /// Handles tab change event.
        /// </summary>
        void IZenTabsChangedListener.ZenTabsChanged()
        {
            // Remove old tab controls in header, re-add them
            List <ZenControl> toRemove = new List <ZenControl>();

            foreach (ZenControl zc in ZenChildren)
            {
                ZenTabControl ztc = zc as ZenTabControl;
                if (ztc == null || ztc.IsMain)
                {
                    continue;
                }
                toRemove.Add(zc);
            }
            foreach (ZenControl zc in toRemove)
            {
                RemoveChild(zc);
                zc.Dispose();
            }
            contentTabControls.Clear();
            // Recreate all header tabs; add content control to form's children
            int posx = mainTabCtrl.AbsLocation.X + mainTabCtrl.Width;

            for (int i = 0; i != tabs.Count; ++i)
            {
                ZenTabControl tc = new ZenTabControl(this, false);
                tc.Text        = tabs[i].Header;
                tc.LogicalSize = new Size(80, 30);
                tc.Size        = new Size(tc.PreferredWidth, tc.Height);
                tc.AbsLocation = new Point(posx, headerHeight - tc.Height);
                posx          += tc.Width;
                tc.MouseClick += onTabCtrlClick;
                contentTabControls.Add(tc);
            }
            // If this is the first content tab being added, this will be the active (visible) one
            if (tabs.Count == 1)
            {
                RemoveChild(mainTab.Ctrl);
                contentTabControls[0].Selected = true;
            }
            // Must arrange controls - so newly added, and perhaps displayed, content tab
            // gets sized and placed
            arrangeControls();
            // Redraw
            doRepaint();
            form.Invalidate();
        }
Exemple #2
0
        /// <summary>
        /// Handles click on a tab header (to switch tabs).
        /// </summary>
        /// <param name="sender"></param>
        private void onTabCtrlClick(ZenControlBase sender)
        {
            ZenTabControl ztc = sender as ZenTabControl;

            // Click on active tab - nothing to do
            if (ztc.IsMain && activeTabIdx == -1)
            {
                return;
            }
            int idx = contentTabControls.IndexOf(ztc);

            if (idx == activeTabIdx)
            {
                return;
            }
            // Switching to main
            if (idx == -1)
            {
                contentTabControls[activeTabIdx].Selected = false;
                mainTabCtrl.Selected = true;
                RemoveChild(tabs[activeTabIdx].Ctrl);
                AddChild(mainTab.Ctrl);
                activeTabIdx = -1;
            }
            // Switching away to a content tab
            else
            {
                mainTabCtrl.Selected             = false;
                contentTabControls[idx].Selected = true;
                RemoveChild(mainTab.Ctrl);
                AddChild(tabs[idx].Ctrl);
                activeTabIdx = idx;
            }
            // Newly active contol still has old size if window was resized
            arrangeControls();
            // Refresh
            doRepaint();
            form.Invalidate();
        }
Exemple #3
0
        private void createZenControls()
        {
            int w = 0;

            btnClose             = new ZenSystemButton(this, SystemButtonType.Close);
            btnClose.AbsLocation = new Point(w - btnClose.Width - sysBtnPadding, 0);
            btnClose.MouseClick += onCloseClick;

            btnMinimize             = new ZenSystemButton(this, SystemButtonType.Minimize);
            btnMinimize.AbsLocation = new Point(btnClose.AbsLeft - btnMinimize.Size.Width, 0);
            btnMinimize.MouseClick += onMinimizeClick;

            btnClose.Tooltip    = new SysBtnTooltips(btnClose, tprov);
            btnMinimize.Tooltip = new SysBtnTooltips(btnMinimize, tprov);

            mainTabCtrl             = new ZenTabControl(this, true);
            mainTabCtrl.Text        = "Main";
            mainTabCtrl.LogicalSize = new Size(80, 30);
            mainTabCtrl.Size        = new Size(mainTabCtrl.PreferredWidth, mainTabCtrl.Height);
            mainTabCtrl.AbsLocation = new Point(1, headerHeight - mainTabCtrl.Height);
            mainTabCtrl.MouseClick += onTabCtrlClick;

            controlsCreated = true;
        }