Exemplo n.º 1
0
        private void CreateColorSlider(string name, int y)
        {
            HorizontalSlider slider = new HorizontalSlider(this);

            slider.Min = 0f;
            slider.Max = 255f;
            slider.SetPosition(0f, y);
            slider.SetSize(150, 20);
            slider.ValueChanged += OnSliderValueChanged;
            slider.Name          = $"{name}Slider";

            IntNumericUpDown upDown = new IntNumericUpDown(this);

            upDown.Min = 0;
            upDown.Max = 255;
            upDown.SetPosition(160, y + 2);
            upDown.SetSize(32, 16);
            upDown.ValueChanged += OnUpDownValueChanged;
            upDown.Name          = $"{name}UpDown";

            ColorDisplay colorDisplay = new ColorDisplay(this);

            colorDisplay.SetPosition(200, y + 3);
            colorDisplay.SetSize(16, 16);
            colorDisplay.Color = Color.White;
            colorDisplay.Name  = $"{name}Display";
        }
Exemplo n.º 2
0
        private void CreateControls()
        {
            CreateColorSlider("Red", 0);
            CreateColorSlider("Green", 25);
            CreateColorSlider("Blue", 50);

            ColorDisplay totalDisplay = new ColorDisplay(this);

            totalDisplay.SetPosition(220, 1);
            totalDisplay.SetSize(70, 70);
            totalDisplay.Color = Color.White;
            totalDisplay.Name  = $"TotalDisplay";
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(ControlBase parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock          = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock          = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            SetColor(DefaultColor);
        }