private void UpdateUpDown() { if (bUpDown) { if (WIN32.IsWindowVisible(scUpDown.Handle)) { Rectangle rect = new Rectangle(); WIN32.GetClientRect(scUpDown.Handle, ref rect); //move the rect is allow close in on (TOP) if ((this.Alignment == TabAlignment.Top) && (_allowCloseButton == true)) { WIN32.MoveWindow(scUpDown.Handle, this.Width - 60, rect.Y + 5, rect.Width, rect.Height, true); } else if ((this.Alignment == TabAlignment.Top) && (_allowCloseButton == false)) //if ((this.Alignment == TabAlignment.Top)) { WIN32.MoveWindow(scUpDown.Handle, this.Width - 41, rect.Y + 5, rect.Width, rect.Height, true); } //move the rect is allow close in on (Bottom) if ((this.Alignment == TabAlignment.Bottom) && (_allowCloseButton == true)) { WIN32.MoveWindow(scUpDown.Handle, this.Width - 60, this.Height - 24, rect.Width, rect.Height, true); } else if ((this.Alignment == TabAlignment.Bottom) && (_allowCloseButton == false)) //if ((this.Alignment == TabAlignment.Bottom)) { WIN32.MoveWindow(scUpDown.Handle, this.Width - 41, this.Height - 24, rect.Width, rect.Height, true); } WIN32.InvalidateRect(scUpDown.Handle, ref rect, true); //Try Disabling Theme try { WIN32.SetWindowTheme(scUpDown.Handle, "", ""); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
internal void DrawControl(Graphics g) { if (!Visible) { return; } Rectangle TabControlArea = this.ClientRectangle; Rectangle TabArea = this.DisplayRectangle; //---------------------------- // fill client area Brush br = new SolidBrush(_standardBackColour); //(SystemColors.Control); UPDATED g.FillRectangle(br, TabControlArea); br.Dispose(); //---------------------------- //---------------------------- // draw border int nDelta = SystemInformation.Border3DSize.Width; Pen border = new Pen(_borderColour, _borderWidth); TabArea.Inflate(nDelta, nDelta); g.DrawRectangle(border, TabArea); border.Dispose(); //---------------------------- //---------------------------- // clip region for drawing tabs Region rsaved = g.Clip; Rectangle rreg; int nWidth = TabArea.Width + nMargin; // exclude close button control for painting if (_allowCloseButton) { nWidth -= 20; } if (bUpDown) { // exclude updown control for painting if (WIN32.IsWindowVisible(scUpDown.Handle)) { Rectangle rupdown = new Rectangle(); WIN32.GetWindowRect(scUpDown.Handle, ref rupdown); Rectangle rupdown2 = this.RectangleToClient(rupdown); nWidth = rupdown2.X; } } //if top or bottom leave a blank space for Close button or navigator if ((this.Alignment == TabAlignment.Top) || (this.Alignment == TabAlignment.Bottom)) { rreg = new Rectangle(TabArea.Left, TabControlArea.Top, nWidth - nMargin, TabControlArea.Height); } else { rreg = ClientRectangle; } g.SetClip(rreg); // draw tabs for (int i = 0; i < this.TabCount; i++) { DrawTab(g, this.TabPages[i], i); } g.Clip = rsaved; //---------------------------- //---------------------------- // draw background to cover flat border areas if (this.SelectedTab != null) { TabPage tabPage = this.SelectedTab; Color color = tabPage.BackColor; border = new Pen(color); TabArea.Offset(1, 1); TabArea.Width -= 2; TabArea.Height -= 2; g.DrawRectangle(border, TabArea); TabArea.Width -= 1; TabArea.Height -= 1; g.DrawRectangle(border, TabArea); border.Dispose(); } //---------------------------- }
// Check in UpDown Is visible protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); DrawControl(e.Graphics); //firt load? if (bFirtsLoad == true) { FindUpDown(); UpdateUpDown(); bFirtsLoad = false; } //bool bIsVisibleUpDown = false; // Check in UpDown Is visible if (bUpDown) { if (WIN32.IsWindowVisible(scUpDown.Handle)) { //bIsVisibleUpDown = true; } } if (_allowCloseButton == true) { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FlatTabControl)); Bitmap closeImage = ((System.Drawing.Bitmap)(resources.GetObject("CloseIcon.bmp"))); closeImage.MakeTransparent(Color.White); if (Alignment == TabAlignment.Top) { //if (bIsVisibleUpDown) //{ // m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 56, ClientRectangle.Y + 8, 14, 14); //} //else //{ m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 18, ClientRectangle.Y + 8, 14, 14); //} } else if (Alignment == TabAlignment.Right) { m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 21, ClientRectangle.Y + ClientRectangle.Height - 18, 14, 14); } else if (Alignment == TabAlignment.Left) { m_closeRect = new Rectangle(ClientRectangle.X + 8, ClientRectangle.Y + ClientRectangle.Height - 18, 14, 14); } else if (Alignment == TabAlignment.Bottom) { //if (bIsVisibleUpDown) //{ // m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 56, ClientRectangle.Y + ClientRectangle.Height - 21, 14, 14); //} //else //{ m_closeRect = new Rectangle(ClientRectangle.X + ClientRectangle.Width - 18, ClientRectangle.Y + ClientRectangle.Height - 21, 14, 14); //} } //paint border and backcolor of the button Rectangle closeBorder = m_closeRect; closeBorder.Inflate(3, 3); closeBorder.Width -= 1; closeBorder.Height -= 1; e.Graphics.FillRectangle(new SolidBrush(_buttonsBackColour), closeBorder); e.Graphics.DrawRectangle(new Pen(_buttonsBorderColour), closeBorder); //paint the image e.Graphics.DrawImage(closeImage, m_closeRect); // e.Graphics.DrawRectangle(new Pen(Color.Red), m_closeRect); } }