Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            ButtonState buttonState = this.buttonPressed
                                ? ButtonState.Pressed
                                : this.buttonHovered
                                        ? ButtonState.Hot
                                        : ButtonState.Normal;

            if (this.ReadOnly)
            {
                buttonState = ButtonState.Disabled;
            }

            this.ControlRenderer.DrawButton(
                e.Graphics, this.rectButton,
                buttonState, "Add Component");
        }
Esempio n. 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Color brightChecker = Color.FromArgb(224, 224, 224);
            Color darkChecker   = Color.FromArgb(192, 192, 192);

            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), this.rectPanel);
            if (this.value != null)
            {
                Color val      = Color.FromArgb(this.value.ToIntArgb());
                Color valSolid = Color.FromArgb(255, val);
                e.Graphics.FillRectangle(
                    new SolidBrush(val),
                    this.rectPanel.X,
                    this.rectPanel.Y,
                    this.rectPanel.Width / 2,
                    this.rectPanel.Height);
                e.Graphics.FillRectangle(
                    new SolidBrush(valSolid),
                    this.rectPanel.X + this.rectPanel.Width / 2,
                    this.rectPanel.Y,
                    this.rectPanel.Width / 2,
                    this.rectPanel.Height);

                ColorRgba    rgba      = this.value.ConvertTo <ColorRgba>();
                Color        textColor = rgba.GetLuminance() > 0.5f ? Color.Black : Color.White;
                StringFormat format    = StringFormat.GenericDefault;
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                format.Trimming      = StringTrimming.EllipsisCharacter;
                e.Graphics.DrawString(
                    string.Format("{0}, {1}, {2}, {3}", rgba.R, rgba.G, rgba.B, rgba.A),
                    this.ControlRenderer.FontRegular,
                    new SolidBrush(Color.FromArgb(128, textColor)),
                    this.rectPanel,
                    format);
            }
            e.Graphics.DrawRectangle(SystemPens.ControlLightLight,
                                     this.rectPanel.X + 1,
                                     this.rectPanel.Y + 1,
                                     this.rectPanel.Width - 2,
                                     this.rectPanel.Height - 2);
            e.Graphics.DrawRectangle(SystemPens.ControlDark, this.rectPanel);

            ButtonState buttonCDiagState = ButtonState.Disabled;

            if (!this.ReadOnly && this.Enabled)
            {
                if (this.buttonCDiagPressed)
                {
                    buttonCDiagState = ButtonState.Pressed;
                }
                else if (this.buttonCDiagHovered)
                {
                    buttonCDiagState = ButtonState.Hot;
                }
                else
                {
                    buttonCDiagState = ButtonState.Normal;
                }
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectCDiagButton,
                buttonCDiagState,
                null,
                Properties.GeneralResCache.ColorWheel);

            ButtonState buttonCPickState = ButtonState.Disabled;

            if (!this.ReadOnly && this.Enabled)
            {
                if (this.buttonCPickPressed)
                {
                    buttonCPickState = ButtonState.Pressed;
                }
                else if (this.buttonCPickHovered)
                {
                    buttonCPickState = ButtonState.Hot;
                }
                else
                {
                    buttonCPickState = ButtonState.Normal;
                }
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectCPickButton,
                buttonCPickState,
                null,
                Properties.GeneralResCache.ColorPick);
        }