Esempio n. 1
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            var bgColour     = Color.Empty;
            var borderColour = Color.Empty;
            var itemRect     = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);

            if (e.Item.Pressed)
            {
                bgColour     = this.buttonPressedBackColour;
                borderColour = this.buttonPressedBorderColour;
            }
            else if (e.Item.Selected)
            {
                bgColour     = this.buttonSelectedBackColour;
                borderColour = this.buttonSelectedBorderColour;
            }
            else if (IsItemChecked(e.Item))
            {
                bgColour     = ColourUtils.Blend(e.ToolStrip.BackColor, this.buttonSelectedBackColour, .125f);
                borderColour = this.buttonSelectedBorderColour;
            }

            if (bgColour.IsEmpty == false)
            {
                using (var brush = new SolidBrush(bgColour))
                {
                    using (var pen = new Pen(borderColour))
                    {
                        e.Graphics.FillRectangle(brush, itemRect);
                        e.Graphics.DrawRectangle(pen, itemRect);
                    }
                }
            }
        }
Esempio n. 2
0
        protected override void OnBackColorChanged(EventArgs e)
        {
            base.OnBackColorChanged(e);

            for (var i = 0; i < this.captionBtns.Length; i++)
            {
                if (i == BTN_CLOSE)
                {
                    this.captionBtns[i].BackColor = ColourUtils.Blend(this.BackColor, Color.Red, .125f);
                }
                else
                {
                    this.captionBtns[i].BackColor = ColourUtils.Blend(this.BackColor, Color.White, .75f);
                }
            }
            UpdateForeColour();

            if (DesignMode == false && this.ParentForm != null && this.ParentForm.Handle != null)
            {
                IntPtr hwnd = this.ParentForm.Handle;
                using (var g = Graphics.FromHwnd(hwnd))
                {
                    DrawParentFrame(g, hwnd);
                }
            }
        }
Esempio n. 3
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            var rect = this.ClientRectangle;

            e.Graphics.FillRectangle(SystemBrushes.Window, rect);
            if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
            {
                rect.X    += rect.Width / 2;
                rect.Width = 1;
            }
            else if (this.Dock == DockStyle.Top || this.Dock == DockStyle.Bottom)
            {
                rect.Y     += rect.Height / 2;
                rect.Height = 1;
            }
            else
            {
                return;
            }
            var barColour = ColourUtils.Blend(SystemColors.Window, SystemColors.ButtonFace, .5f);

            using (var br = new SolidBrush(barColour))
            {
                e.Graphics.FillRectangle(br, rect);
            }
        }
Esempio n. 4
0
        Color CalculateShadowColour(Color colour)
        {
            Color backColour = this.BackColor;

            if (backColour.IsEmpty)
            {
                backColour = this.Parent.BackColor;
            }
            colour = colour.GetBrightness() > .5f ? Color.Black : Color.White;
            return(ColourUtils.Blend(colour, backColour, .5f));
        }
Esempio n. 5
0
        void UpdateForeColour(bool active)
        {
            var brightness     = this.BackColor.GetBrightness();
            var foreColourBase = ColourUtils.IsDark(this.BackColor) ? Color.White : Color.Black;

            if (active)
            {
                this.foreColour = foreColourBase;
            }
            else
            {
                this.foreColour = ColourUtils.Blend(this.BackColor, foreColourBase, .25f);
            }
            this.titleLabel.ForeColor   = this.foreColour;
            this.captionStrip.ForeColor = this.foreColour;
            OnForeColorChanged(EventArgs.Empty);
        }
Esempio n. 6
0
            protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
            {
                Color colour;

                if (e.Item.Pressed)
                {
                    colour = ColourUtils.Blend(e.Item.BackColor, Color.Black, .6f);
                }
                else if (e.Item.Selected)
                {
                    colour = e.Item.BackColor;
                }
                else
                {
                    return;
                }
                using (var br = new SolidBrush(colour))
                {
                    e.Graphics.FillRectangle(br, new Rectangle(Point.Empty, e.Item.Size));
                }
            }