/// <summary>
        /// Resets the controls color (both HSL and RGB variables) based on the current slider position
        /// </summary>
        private void ResetHSLRGB()
        {
            switch (m_eDrawStyle)
            {
            case eDrawStyle.Hue:
                m_hsl.H = 1.0 - (double)m_iMarker_Start_Y / (Height - 9);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Saturation:
                m_hsl.S = 1.0 - (double)m_iMarker_Start_Y / (Height - 9);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Brightness:
                m_hsl.L = 1.0 - (double)m_iMarker_Start_Y / (Height - 9);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Red:
                m_rgb = Color.FromArgb(255 - Round(255 * (double)m_iMarker_Start_Y / (Height - 9)), m_rgb.G, m_rgb.B);
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;

            case eDrawStyle.Green:
                m_rgb = Color.FromArgb(m_rgb.R, 255 - Round(255 * (double)m_iMarker_Start_Y / (Height - 9)), m_rgb.B);
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;

            case eDrawStyle.Blue:
                m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 255 - Round(255 * (double)m_iMarker_Start_Y / (Height - 9)));
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Resets the controls color (both HSL and RGB variables) based on the current marker position
        /// </summary>
        private void ResetHSLRGB()
        {
            int red, green, blue;

            switch (m_eDrawStyle)
            {
            case eDrawStyle.Hue:
                m_hsl.S = (double)m_iMarker_X / (Width - 4);
                m_hsl.L = 1.0 - (double)m_iMarker_Y / (Height - 4);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Saturation:
                m_hsl.H = (double)m_iMarker_X / (Width - 4);
                m_hsl.L = 1.0 - (double)m_iMarker_Y / (Height - 4);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Brightness:
                m_hsl.H = (double)m_iMarker_X / (Width - 4);
                m_hsl.S = 1.0 - (double)m_iMarker_Y / (Height - 4);
                m_rgb   = ColorManager.HSL_to_RGB(m_hsl);
                break;

            case eDrawStyle.Red:
                blue  = Round(255 * (double)m_iMarker_X / (Width - 4));
                green = Round(255 * (1.0 - (double)m_iMarker_Y / (Height - 4)));
                m_rgb = Color.FromArgb(m_rgb.R, green, blue);
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;

            case eDrawStyle.Green:
                blue  = Round(255 * (double)m_iMarker_X / (Width - 4));
                red   = Round(255 * (1.0 - (double)m_iMarker_Y / (Height - 4)));
                m_rgb = Color.FromArgb(red, m_rgb.G, blue);
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;

            case eDrawStyle.Blue:
                red   = Round(255 * (double)m_iMarker_X / (Width - 4));
                green = Round(255 * (1.0 - (double)m_iMarker_Y / (Height - 4)));
                m_rgb = Color.FromArgb(red, green, m_rgb.B);
                m_hsl = ColorManager.RGB_to_HSL(m_rgb);
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns the graphed color at the x,y position on the control
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private ColorManager.HSL GetColor(int x, int y)
        {
            var _hsl = new ColorManager.HSL();

            switch (m_eDrawStyle)
            {
            case eDrawStyle.Hue:
                _hsl.H = m_hsl.H;
                _hsl.S = (double)x / (Width - 4);
                _hsl.L = 1.0 - (double)y / (Height - 4);
                break;

            case eDrawStyle.Saturation:
                _hsl.S = m_hsl.S;
                _hsl.H = (double)x / (Width - 4);
                _hsl.L = 1.0 - (double)y / (Height - 4);
                break;

            case eDrawStyle.Brightness:
                _hsl.L = m_hsl.L;
                _hsl.H = (double)x / (Width - 4);
                _hsl.S = 1.0 - (double)y / (Height - 4);
                break;

            case eDrawStyle.Red:
                _hsl =
                    ColorManager.RGB_to_HSL(Color.FromArgb(m_rgb.R, Round(255 * (1.0 - (double)y / (Height - 4))),
                                                           Round(255 * (double)x / (Width - 4))));
                break;

            case eDrawStyle.Green:
                _hsl =
                    ColorManager.RGB_to_HSL(Color.FromArgb(Round(255 * (1.0 - (double)y / (Height - 4))), m_rgb.G,
                                                           Round(255 * (double)x / (Width - 4))));
                break;

            case eDrawStyle.Blue:
                _hsl =
                    ColorManager.RGB_to_HSL(Color.FromArgb(Round(255 * (double)x / (Width - 4)),
                                                           Round(255 * (1.0 - (double)y / (Height - 4))), m_rgb.B));
                break;
            }

            return(_hsl);
        }
Exemple #4
0
        private void UpdateUI(Color color)
        {
            isUpdating = true;
            m_rgb      = color;
            m_hsl      = ColorManager.RGB_to_HSL(m_rgb);
            m_cmyk     = ColorManager.RGB_to_CMYK(m_rgb);

            txtHue.Text        = Round(m_hsl.H * 360).ToString();
            txtSat.Text        = Round(m_hsl.S * 100).ToString();
            txtBrightness.Text = Round(m_hsl.L * 100).ToString();
            txtRed.Text        = m_rgb.R.ToString();
            txtGreen.Text      = m_rgb.G.ToString();
            txtBlue.Text       = m_rgb.B.ToString();

            colorBox.HSL    = m_hsl;
            colorSlider.HSL = m_hsl;

            colorPanelPending.Color = Color.FromArgb(255 - tbAlpha.Value, m_rgb);

            WriteHexData(m_rgb);
            isUpdating = false;
        }