Beispiel #1
0
        /// <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 / (this.Allocation.Height - 9);
                m_rgb   = GraphUtil.HSL_to_RGB(m_hsl);
                break;

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

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

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

            case eDrawStyle.Green:
                m_rgb = Color.FromArgb(m_rgb.R, 255 - Round(255 * (double)m_iMarker_Start_Y / (this.Allocation.Height - 9)), m_rgb.B);
                m_hsl = GraphUtil.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 / (this.Allocation.Height - 9)));
                m_hsl = GraphUtil.RGB_to_HSL(m_rgb);
                break;
            }
        }
Beispiel #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 / (this.Allocation.Width - 4);
                m_hsl.L = 1.0 - (double)m_iMarker_Y / (this.Allocation.Height - 4);
                m_rgb   = GraphUtil.HSL_to_RGB(m_hsl);
                break;

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

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

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

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

            case eDrawStyle.Blue:
                red   = Round(255 * (double)m_iMarker_X / (this.Allocation.Width - 4));
                green = Round(255 * (1.0 - (double)m_iMarker_Y / (this.Allocation.Height - 4)));
                m_rgb = Color.FromArgb(red, green, m_rgb.B);
                m_hsl = GraphUtil.RGB_to_HSL(m_rgb);
                break;
            }
        }
Beispiel #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 GraphUtil.HSL GetColor(int x, int y)
        {
            GraphUtil.HSL _hsl = new GraphUtil.HSL();

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

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

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

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

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

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

            return(_hsl);
        }