예제 #1
0
        /// <summary>
        /// Handles the Tick event raised by the sliderTimer object. This is
        /// used to guarantee fluidity between two different points on the
        /// color slider when the arrows are being dragged. Without this, the
        /// currently selected color panel and the updated structure values
        /// (RGB/HEX) jump awkwardly between points.
        ///
        /// This will probably be changed to a threaded solution since FXCop
        /// is complaining about the tick frequency.
        /// </summary>
        /// <param name="sender">The object that raised this event.</param>
        /// <param name="e">An EventArgs containing the event data.</param>

        private void sliderTimer_Tick(object sender, System.EventArgs e)
        {
            int difference = Math.Abs(m_currentYValue - m_targetYValue);
            int nextValue  = ( int )Math.Round(( double )difference / 2);

            if (nextValue == 0)
            {
                m_currentYValue = m_targetYValue;
                sliderTimer.Stop();
            }
            else
            {
                if (m_currentYValue < m_targetYValue)
                {
                    m_currentYValue += nextValue;
                }
                else
                {
                    m_currentYValue += -nextValue;
                }
            }

            if (m_currentColorSpace is RgbColorSpace)
            {
                hsbColorSpace.Structure = ColorConverter.RgbToHsb(( RGB )rgbColorSpace.Structure);
            }
            else if (m_currentColorSpace is HsbColorSpace)
            {
                rgbColorSpace.Structure = ColorConverter.HsbToRgb(( HSB )hsbColorSpace.Structure);
            }

            UpdateColorPanels(false, false, true);
        }
예제 #2
0
        /// <summary>
        /// Updates the color spaces with the new hex value and makes sure that
        /// the necessary components are updated (color field, color slider,
        /// etc).
        /// </summary>

        private void UpdateColorSpacesWithNewHexValue()
        {
            RGB rgb = ColorConverter.HexToRgb(hexTextBox.Text);

            rgbColorSpace.Structure = rgb;
            hsbColorSpace.Structure = ColorConverter.RgbToHsb(rgb);

            UpdateColorSliderArrowRegions();

            // reset the location of the arrows in the value region.
            this.UpdateColorPanels(true, true, false);
        }
예제 #3
0
        /// <summary>
        /// Handles the ComponentValueChanged event that the ColorSpace raises
        /// when the value of one of its components is changed by way of a
        /// keyboard user input. The color spaces are synced up and the color
        /// panels updated.
        /// </summary>
        /// <param name="sender">The ColorSpace object that raised the event.</param>
        /// <param name="e">An EventArgs object containing the event data.</param>

        private void ColorSpaceComponentValueChanged(ColorSpace sender, EventArgs e)
        {
            if (sender is RgbColorSpace)
            {
                hsbColorSpace.Structure = ColorConverter.RgbToHsb(( RGB )rgbColorSpace.Structure);
            }
            else if (sender is HsbColorSpace)
            {
                rgbColorSpace.Structure = ColorConverter.HsbToRgb(( HSB )hsbColorSpace.Structure);                    //, ( 255 - ( this.m_currentColorSliderArrowYLocation - m_colorSliderInnerRegion.Top ) ) );
            }

            UpdateColorSliderArrowRegions();
            UpdateColorPanels(true, true, true);
        }
예제 #4
0
        /// <summary>
        /// Processes the selected color.
        /// </summary>
        /// <param name="color">A Color object containing the color that was
        /// recently selected.</param>

        private void ColorSelected(Color color, bool updateSliderPosition)
        {
            // make sure the color that was just clicked isn't the color that
            // is currently displayed (performance enhancement).

            if (!ColorConverter.ColorToRgb(color).Equals(rgbColorSpace.Structure))
            {
                RGB rgb = ColorConverter.ColorToRgb(color);

                rgbColorSpace.Structure = rgb;
                hsbColorSpace.Structure = ColorConverter.RgbToHsb(rgb);

                if (updateSliderPosition)
                {
                    UpdateColorSliderArrowRegions();
                }

                this.UpdateColorPanels(true, true, true);
            }
        }