Example #1
0
        private void UpdatetbValue(TextBox skipupdate)
        {
            #region hsv textboxes

            HSV chsv = HSV.FromRGB(InternalColor.ToRGB());
            if (skipupdate != tbHSV_H)
            {
                tbHSV_H.Text = (chsv.H * 360.0).ToString("0");
            }
            if (skipupdate != tbHSV_S)
            {
                tbHSV_S.Text = (chsv.S * 100.0).ToString("0");
            }
            if (skipupdate != tbHSV_V)
            {
                tbHSV_V.Text = (chsv.V * 100.0).ToString("0");
            }

            #endregion

            #region secondary textboxes

            if (_mode == Mode.HSV_RGB)
            {
                RGB crgb = InternalColor.ToRGB();
                if (skipupdate != tbSecond_1)
                {
                    tbSecond_1.Text = (crgb.R * 255.0).ToString("0");
                }
                if (skipupdate != tbSecond_2)
                {
                    tbSecond_2.Text = (crgb.G * 255.0).ToString("0");
                }
                if (skipupdate != tbSecond_3)
                {
                    tbSecond_3.Text = (crgb.B * 255.0).ToString("0");
                }
            }
            else             //(_mode==Mode.HSV_LAB)
            {
                LAB clab = LAB.FromXYZ(InternalColor);
                if (skipupdate != tbSecond_1)
                {
                    tbSecond_1.Text = clab.L.ToString("0");
                }
                if (skipupdate != tbSecond_2)
                {
                    tbSecond_2.Text = clab.a.ToString("0");
                }
                if (skipupdate != tbSecond_3)
                {
                    tbSecond_3.Text = clab.b.ToString("0");
                }
            }

            #endregion
        }
Example #2
0
 private void _module_ColorChanged(object sender, EventArgs e)
 {
     if (_module == null)
     {
         return;
     }
     InternalColor     = _module.XYZ;
     lblColorOut.Color = InternalColor.ToRGB();
     UpdatetbValue(null);
 }
Example #3
0
        public void UpdateUI()
        {
            ChangeModule();
            ChangeDescriptions();
            UpdaterdFader();
            UpdatectxOptions();
            UpdatetbValue(null);

            _module.XYZ       = InternalColor;
            lblColorOut.Color = lblColorOut.OldColor = InternalColor.ToRGB();
        }
Example #4
0
 private void blueButton_Click(object sender, EventArgs e)
 {
     InternalColor     = XYZ.FromRGB(new RGB(0, 0, 255));
     lblColorOut.Color = InternalColor.ToRGB();
     UpdatetbValue(null);
 }
Example #5
0
        private void tbValue_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (!(sender is TextBox))
            {
                return;
            }
            if (e.KeyCode == Keys.Return)
            {
                UpdatetbValue(null);
                e.Handled = true;
                return;
            }
            double value;

            if (!double.TryParse(((TextBox)sender).Text,
                                 System.Globalization.NumberStyles.Integer,
                                 null, out value))
            {
                return;
            }

            #region hsv  textboxes

            if (sender == tbHSV_H)
            {
                HSV chsv = HSV.FromRGB(InternalColor.ToRGB());
                chsv.H        = value / 360.0;
                InternalColor = XYZ.FromRGB(chsv.ToRGB());
            }
            else if (sender == tbHSV_S)
            {
                HSV chsv = HSV.FromRGB(InternalColor.ToRGB());
                chsv.S        = value / 100.0;
                InternalColor = XYZ.FromRGB(chsv.ToRGB());
            }
            else if (sender == tbHSV_V)
            {
                HSV chsv = HSV.FromRGB(InternalColor.ToRGB());
                chsv.V        = value / 100.0;
                InternalColor = XYZ.FromRGB(chsv.ToRGB());
            }
            #endregion
            #region secondary textboxes

            else if (_mode == Mode.HSV_RGB)
            {
                RGB crgb = InternalColor.ToRGB();
                if (sender == tbSecond_1)
                {
                    crgb.R = value / 255.0;
                }
                else if (sender == tbSecond_2)
                {
                    crgb.G = value / 255.0;
                }
                else                 //sender==tbSecond_3
                {
                    crgb.B = value / 255.0;
                }
                InternalColor = XYZ.FromRGB(crgb);
            }
            else if (_mode == Mode.HSV_LAB)
            {
                LAB clab = LAB.FromXYZ(InternalColor);
                if (sender == tbSecond_1)
                {
                    clab.L = value;
                }
                else if (sender == tbSecond_2)
                {
                    clab.a = value;
                }
                else                 //sender==tbSecond_3
                {
                    clab.b = value;
                }
                InternalColor = clab.ToXYZ();
            }

            #endregion

            //update ui
            _module.XYZ       = InternalColor;
            lblColorOut.Color = InternalColor.ToRGB();
            UpdatetbValue((TextBox)sender);
        }