BrrrBayBay.PwmGUIControl.GenericPwmControl.frequencyChangedHandler C# (CSharp) Метод

frequencyChangedHandler() приватный Метод

private frequencyChangedHandler ( Object sender, EventArgs e ) : void
sender Object
e System.EventArgs
Результат void
        private void frequencyChangedHandler(Object sender, EventArgs e)
        {
            float multiplier = 1;
            double freq = 0;
            double? fVal;
            // get the frequency multiplier
            switch (fUnitsBox.Text)
            {
                case "Hz":
                    multiplier = 1;
                    break;
                case "KHz":
                    multiplier = 1000;
                    break;
                default:
                    MessageBox.Show("Unknown frequency units: " + fUnitsBox.Text);
                    return;
            }

            // Check if the frequency is a valid number
            fVal = Utils.getDoubleFromString(frequencyBox.Text);
            if (fVal == null)
            {
                frequencyBox.BackColor = Color.Salmon;
                return;
            }
            else
            {
                frequencyBox.BackColor = Color.Empty;
            }

            // Check if the frequency is between 1Hz and 1 MHz
            freq = fVal.Value * multiplier;

            if ((freq < 1) || (freq > 1000000))
            {
                frequencyBox.BackColor = Color.Salmon;
                return;
            }
            else
            {
                frequencyBox.BackColor = Color.Empty;
                synchronousPwmFrequency = (int) freq;
                for (int i = 0; i < 8; i++)
                {
                    channelControls[i].setNewFrequency((int) freq, fUnitsBox.Text);
                }
            }
        }