Advertisement
tolikpunkoff

idc_Changed

Dec 10th, 2023
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | Source Code | 0 0
  1.         private void idc_Changed(object sender, EventArgs e)
  2.         {
  3.             InputDigitControl idc = (InputDigitControl)sender;
  4.             string fldID = idc.Name.Substring(3, 1);
  5.  
  6.             double V = TemperatureConvert.ToDouble(idc.Text);
  7.            
  8.             switch (fldID)
  9.             {
  10.                 case "C":
  11.                     {
  12.                         if (!enC) return;
  13.                         if (V < -273.15)
  14.                         {
  15.                             lblError.Text = "Такой температуры не бывает!";
  16.                             return;
  17.                         }
  18.  
  19.                         idcK.Text = TemperatureConvert.C2K(V).ToString();
  20.                         idcF.Text = TemperatureConvert.C2F(V).ToString();
  21.                         lblError.Text = "";
  22.                     }; break;
  23.                 case "K":
  24.                     {
  25.                         if (!enK) return;
  26.                         idcC.Text = TemperatureConvert.K2C(V).ToString();
  27.                         idcF.Text = TemperatureConvert.K2F(V).ToString();
  28.                     }; break;
  29.                 case "F":
  30.                     {
  31.                         if (!enF) return;
  32.                         if (V < -459.67)
  33.                         {
  34.                             lblError.Text = "Такой температуры не бывает!";
  35.                             return;
  36.                         }
  37.  
  38.                         idcC.Text = TemperatureConvert.F2C(V).ToString();
  39.                         idcK.Text = TemperatureConvert.F2K(V).ToString();
  40.                         lblError.Text = "";
  41.                     }; break;
  42.             }
  43.         }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement