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; }
/// <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(); }