Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Band_4()
- {
- if (radioButton1.Checked)
- {
- if (textBox1.Text == "0")
- {
- MessageBox.Show("Otpornost mora biti veca od nule!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (comboBox1.Text == "")
- {
- MessageBox.Show("Izaberi vrednost tolerancije!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- while (string.IsNullOrEmpty(res))
- {
- res = textBox1.Text;
- }
- var lastChar = res.Last();
- var isUnitCorrect = factorDictionary.ContainsKey(lastChar);
- var value = res.Substring(0, res.Length - 1);
- var isValueCorrect = !value.Any(x => !char.IsDigit(x));
- if (isUnitCorrect && isValueCorrect)
- {
- double mul = factorDictionary[lastChar];
- double val = double.Parse(value) * mul;
- int third = 0;
- if (val < 0.1)
- {
- MessageBox.Show("Otpornost ne moze da bude manja od 0.1 oma!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (val < 1)
- {
- val *= 100;
- third = 10;
- }
- else if (val < 10)
- {
- val *= 10;
- third = 11;
- }
- /*if (p <= val)
- {
- if (p < min)
- {
- min = E12[i];
- r = Math.Abs(val - p);
- }
- }*/
- res = val.ToString();
- if (res.Count() > 24)
- {
- MessageBox.Show("Pogresna vrednost!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- else
- {
- label14.BackColor = Color.FromName(colours[res[0] - '0']);
- label15.BackColor = Color.FromName(colours[res[1] - '0']);
- label16.BackColor = Color.FromName(colours[third != 0 ? third : res.Count() - 2]);
- label4.Text = textBox1.Text;
- textBox2.Text = colours[res[0] - '0'];
- textBox3.Text = colours[res[1] - '0'];
- textBox4.Text = colours[third != 0 ? third : res.Count() - 2];
- }
- }
- if (radioButton1.Checked)
- {
- if (comboBox1.Text == "E24 (5%)")
- {
- label17.BackColor = Color.Gold;
- textBox5.Text = "Gold";
- }
- if (comboBox1.Text == "E12 (10%)")
- {
- label17.BackColor = Color.Silver;
- textBox5.Text = "Silver";
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment