コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
        internal void DrawIcons(Graphics g)
        {
            if ((leftRightImages == null) || (leftRightImages.Images.Count != 4))
            {
                return;
            }

            //----------------------------
            // calc positions
            Rectangle TabControlArea = this.ClientRectangle;

            Rectangle r0 = new Rectangle();

            WIN32.GetClientRect(scUpDown.Handle, ref r0);

            //paint backcolor
            Brush br = new SolidBrush(_buttonsBackColour);

            r0.Width = r0.Width - 1;
            g.FillRectangle(br, r0);
            br.Dispose();

            //paint border
            Pen       border  = new Pen(_buttonsBorderColour);
            Rectangle rborder = r0;

            rborder.Height = rborder.Height - 1;
            rborder.Width  = rborder.Width - 0;
            g.DrawRectangle(border, rborder);
            border.Dispose();



            int nMiddle = (r0.Width / 2);
            int nTop    = (r0.Height - 16) / 2;
            int nLeft   = (nMiddle - 16) / 2;

            Rectangle r1 = new Rectangle(nLeft, nTop, 16, 16);
            Rectangle r2 = new Rectangle(nMiddle + nLeft, nTop, 16, 16);
            //----------------------------

            //----------------------------
            // draw buttons
            Image img = leftRightImages.Images[1];

            if (img != null)
            {
                if (this.TabCount > 0)
                {
                    Rectangle r3 = this.GetTabRect(0);
                    if (r3.Left < TabControlArea.Left)
                    {
                        g.DrawImage(img, r1);
                    }
                    else
                    {
                        img = leftRightImages.Images[3];
                        if (img != null)
                        {
                            g.DrawImage(img, r1);
                        }
                    }
                }
            }

            img = leftRightImages.Images[0];
            if (img != null)
            {
                if (this.TabCount > 0)
                {
                    Rectangle r3 = this.GetTabRect(this.TabCount - 1);
                    if (r3.Right > (TabControlArea.Width - r0.Width))
                    {
                        g.DrawImage(img, r2);
                    }
                    else
                    {
                        img = leftRightImages.Images[2];
                        if (img != null)
                        {
                            g.DrawImage(img, r2);
                        }
                    }
                }
            }
            Invalidate();
            //----------------------------
        }
コード例 #3
0
        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();
            }
            //----------------------------
        }
コード例 #4
0
        // 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);
            }
        }