示例#1
0
        public void InitializeContent(PropertyEnumerator propEnum, string currentValue, object valueKey)
        {
            _color = (Color)propEnum.Property.Value.GetValue();

            Width     = 200;
            Height    = 212;
            BackColor = SystemColors.Control;

            double h, s, b;

            ColorUtils.RgbToHsb(_color, out h, out s, out b);

            _hueBar.Bounds        = new Rectangle(35, 10, 155, 12);
            _hueBar.Margins       = new Win32Calls.RECT(25, 1, 1, 1);
            _hueBar.Label         = "Hue";
            _hueBar.Value         = (int)Math.Round(h / 360.0 * 255.0);
            _hueBar.ValueChanged += new EventHandler(OnTrackBarValueChanged);
            _hueBar.TabIndex      = 2;

            _sbMapPicker.Color         = _color;
            _sbMapPicker.Bounds        = new Rectangle(40, 30, 150, 150);
            _sbMapPicker.ValueChanged += new EventHandler(OnSbMapValueChanged);
            _sbMapPicker.TabIndex      = 3;

            _alphaBar.Bounds         = new Rectangle(10, 10, 20, 100);
            _alphaBar.Margins        = new Win32Calls.RECT(1, 1, 1, 1);
            _alphaBar.Orientation    = Orientation.Vertical;
            _alphaBar.ReversedOrigin = true;
            _alphaBar.Value          = _color.A;
            _alphaBar.ValueChanged  += new EventHandler(OnTrackBarValueChanged);
            _alphaBar.TabIndex       = 1;

            _rLabel.TextAlign   = ContentAlignment.MiddleLeft;
            _rLabel.Bounds      = new Rectangle(10, 185, 15, 19);
            _rLabel.Text        = "R";
            _rEdit.AutoSize     = false;
            _rEdit.Bounds       = new Rectangle(25, 185, 26, 19);
            _rEdit.Text         = _color.R.ToString();
            _rEdit.MaxLength    = 3;
            _rEdit.KeyPress    += new KeyPressEventHandler(OnEditKeyPress);
            _rEdit.TextChanged += new EventHandler(OnEditTextChanged);

            _gLabel.TextAlign   = ContentAlignment.MiddleLeft;
            _gLabel.Bounds      = new Rectangle(56, 185, 15, 19);
            _gLabel.Text        = "G";
            _gEdit.AutoSize     = false;
            _gEdit.Bounds       = new Rectangle(71, 185, 26, 19);
            _gEdit.Text         = _color.G.ToString();
            _gEdit.MaxLength    = 3;
            _gEdit.KeyPress    += new KeyPressEventHandler(OnEditKeyPress);
            _gEdit.TextChanged += new EventHandler(OnEditTextChanged);

            _bLabel.TextAlign   = ContentAlignment.MiddleLeft;
            _bLabel.Bounds      = new Rectangle(102, 185, 15, 19);
            _bLabel.Text        = "B";
            _bEdit.AutoSize     = false;
            _bEdit.Bounds       = new Rectangle(117, 185, 26, 19);
            _bEdit.Text         = _color.B.ToString();
            _bEdit.MaxLength    = 3;
            _bEdit.KeyPress    += new KeyPressEventHandler(OnEditKeyPress);
            _bEdit.TextChanged += new EventHandler(OnEditTextChanged);

            _aLabel.TextAlign   = ContentAlignment.MiddleLeft;
            _aLabel.Bounds      = new Rectangle(148, 185, 15, 19);
            _aLabel.Text        = "A";
            _aEdit.AutoSize     = false;
            _aEdit.Bounds       = new Rectangle(163, 185, 26, 19);
            _aEdit.Text         = _color.A.ToString();
            _aEdit.MaxLength    = 3;
            _aEdit.KeyPress    += new KeyPressEventHandler(OnEditKeyPress);
            _aEdit.TextChanged += new EventHandler(OnEditTextChanged);

            Controls.Add(_hueBar);
            Controls.Add(_sbMapPicker);
            Controls.Add(_alphaBar);
            Controls.Add(_rEdit);
            Controls.Add(_gEdit);
            Controls.Add(_bEdit);
            Controls.Add(_aEdit);
            Controls.Add(_rLabel);
            Controls.Add(_gLabel);
            Controls.Add(_bLabel);
            Controls.Add(_aLabel);
        }
示例#2
0
        public override void DrawSubCategoryLabelBackground(Graphics graphics, int labelRectX, Rectangle rect, PropertyEnumerator enumSelf)
        {
            Rectangle fillRect = Rectangle.Intersect(rect, Rectangle.Round(graphics.ClipBounds));

            if (fillRect.IsEmpty)
            {
                return;
            }

            Brush brush;

            if (DrawSelectedStateAsFocusRect)
            {
                if (_drawSubCategoryBackground)
                {
                    double H, S, L;
                    ColorUtils.RGBtoHSL(Grid.GridColor, out H, out S, out L);
                    Color newBkg = ColorUtils.HSLtoRGB(H, S, L + (1 - L) / 2.0);
                    brush = new SolidBrush(newBkg);
                }
                else
                {
                    brush = new SolidBrush(Grid.GridColor);
                }
            }
            else
            {
                if (enumSelf.Property.Selected) // if selected
                {
                    Color bkgColor;

                    if (Grid.GridContainsFocus)
                    {
                        bkgColor = Grid.SelectedBackColor;
                    }
                    else
                    {
                        // If the control has not the focus, the background is light
                        bkgColor = Grid.SelectedNotFocusedBackColor;
                    }

                    brush = new SolidBrush(bkgColor);
                }
                else
                {
                    if (_drawSubCategoryBackground)
                    {
                        double H, S, L;
                        ColorUtils.RGBtoHSL(Grid.GridColor, out H, out S, out L);
                        Color newBkg = ColorUtils.HSLtoRGB(H, S, 230.0 / 255.0);
                        brush = new SolidBrush(newBkg);
                    }
                    else
                    {
                        brush = new SolidBrush(Grid.GridColor);
                    }
                }
            }

            graphics.FillRectangle(brush, fillRect);

            brush.Dispose();
        }