Beispiel #1
0
        private void NumericUpDown_TextChanged(object sender, EventArgs e)
        {
            if (noUpdate)
            {
                return;
            }

            noUpdate = true;

            valueWasChanged = true;

            if (sender == colorWheel || sender == colorGradientControl ||
                sender == numericUpDownRed || sender == numericUpDownGreen || sender == numericUpDownBlue || sender == numericUpDownAlpha ||
                sender == trackBarRed || sender == trackBarGreen || sender == trackBarBlue || sender == trackBarAlpha)
            {
                ColorValue color = CurrentValue.Color;

                if (sender == colorWheel || sender == colorGradientControl)
                {
                    HSVColor hsvColor = colorWheel.HsvColor;
                    hsvColor.Value = (double)colorGradientControl.Value / 255.0;

                    var c = hsvColor.ToColorValue();
                    color.Red   = c.Red;
                    color.Green = c.Green;
                    color.Blue  = c.Blue;
                }

                if (sender == trackBarRed)
                {
                    color.Red = (float)((double)trackBarRed.Value / 1000);
                }
                if (sender == trackBarGreen)
                {
                    color.Green = (float)((double)trackBarGreen.Value / 1000);
                }
                if (sender == trackBarBlue)
                {
                    color.Blue = (float)((double)trackBarBlue.Value / 1000);
                }
                if (sender == trackBarAlpha)
                {
                    color.Alpha = (float)((double)trackBarAlpha.Value / 1000);
                }

                UpdateRGBAControls(color, sender);
            }

            if (powered && (sender == numericUpDownPower || sender == trackBarPower))
            {
                double power = CurrentValue.Power;

                if (sender == trackBarPower)
                {
                    power = powerRange.GetValueFromTrackBar(false, trackBarPower.Value);
                }

                UpdatePowerControls(power, sender);
            }

            if (itemProperty != null && itemProperty.CanEditValue())
            {
                if (powered)
                {
                    itemProperty.SetValue(CurrentValue, false);
                }
                else
                {
                    itemProperty.SetValue(CurrentValue.ToColorValue(), false);
                }
            }

            UpdateButtonCheckImages();

            noUpdate = false;
        }