Пример #1
0
        void ExtractTheColors(Color colorName)
        {
            try
            {
                // Store color in PictureBox
                panelPreviewer.BackColor = colorName;

                // Store to textboxes
                textBoxRed.Text   = colorName.R.ToString();
                textBoxGreen.Text = colorName.G.ToString();
                textBoxBlue.Text  = colorName.B.ToString();

                // Convert to HEX
                textBoxHex.Text = ColorValueConverter.RGBToHex(colorName);
                textBoxRGB.Text = ColorValueConverter.toRGBA(colorName);

                // HSL
                textBoxHSL.Text = ColorValueConverter.RGBToHSL(colorName);

                string   HSLAsArray = ColorValueConverter.RGBToHSL(colorName, false, true);
                string[] hslarray   = HSLAsArray.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                textBoxHue.Text        = hslarray[0];
                textBoxSaturation.Text = hslarray[1];
                textBoxLuminance.Text  = hslarray[2];

                // KnownColor
                textBoxColorName.Text = ColorValueConverter.ColorToKnownColor(colorName);

                // Save the Color to Settings
                Properties.Settings.Default.LastColor = colorName;

                // Populate Pallette
                panelPalletteLightestColor.BackColor = ColorValueConverter.ColorAdjust(colorName, (float)0.60);  //ControlPaint.Light(colorName, (Single)1.5);
                panelPalletteLighterColor.BackColor  = ColorValueConverter.ColorAdjust(colorName, (float)0.30);  //ControlPaint.Light(colorName, (Single)1.01);
                panelPalletteNormalColor.BackColor   = ColorValueConverter.ColorAdjust(colorName, (float)0);;    // 0F
                panelPalletteDarkerColor.BackColor   = ColorValueConverter.ColorAdjust(colorName, (float)-0.30); //ControlPaint.Dark(colorName, 0.01F);
                panelPalletteDarkestColor.BackColor  = ColorValueConverter.ColorAdjust(colorName, (float)-0.60); //ControlPaint.Dark(colorName, 0.05F);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Exception Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                // Copy to Clipboard
                CopyToClipboard();
                this.Text = Properties.Settings.Default.AppTitle + " - " + GetTheColorViaRadioButton(colorName).ToUpper();
            }
        }
Пример #2
0
        public String GetTheColorViaRadioButton(Color c)
        {
            String color = "";
            var    checkedRadioButton = Automaton.GetCheckedRadio(new List <RadioButton>(new RadioButton[] { radioButtonHex, radioButtonRGB, radioButtonHSL }));
            var    tag = checkedRadioButton.Tag.ToString();

            switch (tag)
            {
            case "textBoxHex":
                color = ColorValueConverter.RGBToHex(c);
                break;

            case "textBoxRGB":
                color = ColorValueConverter.toRGBA(c);
                break;

            case "textBoxHSL":
                color = ColorValueConverter.RGBToHSL(c);
                break;
            }
            return(color);
        }