Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication3
- {
- public partial class Form1 : Form
- {
- float temperature = 0;
- float pressure = 0;
- bool polarity = false;
- float space = 0;
- double result, result1 = 0;
- double a, b, c, d = 0;
- int index = 0;
- //array z wartościami
- double[,] array = new double[,]
- {
- //polaryzacja ujemna
- {-7.0278, 36.679, 0.9537}, // dla 2 array 0
- {-3.1197, 34.267, 1.0852}, // dla 5
- {-2.5274, 33.751, 0.6446}, // 6,25
- {-1.5805, 32.356, 0.9248}, // 10
- {-1.2233, 31.466,1.4188}, // 12,5
- {-1.0359, 31.261,1.3121}, // 15
- {-0.6224, 30.424, 1.4651}, // 25
- {-0.3158, 29.175, 1.9239}, //50
- {-0.2677, 28.347, 3.6374 }, //75
- {-0.1616, 28.359, 1.3109}, //100
- {-0.109, 27.637, 4.892}, //150
- {-0.0782, 26.234 , 27.778}, //200
- // polaryzacja dodatnia
- {-7.6027, 37.814, 0.4703},
- {-2.4876,34.219,0.6911},
- {-2.1011,33.342,0.8251},
- {-1.2439,31.94,0.8181},
- {-0.9963,31.478,0.7935},
- {-0.8891,31.434,0.4858},
- {-0.5498,30.754,-0.4025},
- {-0.3005,29.831,-2.1153},
- {-0.2037,29.154,-1.8502},
- {-0.1576,28.819,-3.3674},
- {0.107,28.039,27.753},
- {0.0819, 27.753, -5.472},
- };
- double calculateResult(double a, double b, double c, double d)
- {
- result = (a * space * space) + (b * space) + c;
- return result;
- }
- double calculateDiameter(double space, double d)
- {
- result1 = space / d;
- return result1;
- }
- double calculateParameter(double pressure, double temperature)
- {
- double density = ((293*pressure*100)/(1013*100*(temperature+273)));
- double k = 0.9358*density + 0.0664;
- return k;
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.Checked)
- {
- bool isChecked = true;
- temperature = 20;
- pressure = 1013;
- textBox2.Text = pressure.ToString();
- textBox1.Text = temperature.ToString();
- }
- else
- {
- bool isChecked = false;
- temperature = 0;
- pressure = 0;
- textBox2.Text = pressure.ToString();
- textBox1.Text = temperature.ToString();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- polarity = true;
- label5.Text = "Dodatnia";
- }
- private void button2_Click(object sender, EventArgs e)
- {
- polarity = false;
- label5.Text = "Ujemna";
- }
- private void button6_Click(object sender, EventArgs e)
- {
- pressure++;
- textBox2.Text = pressure.ToString();
- }
- private void button5_Click(object sender, EventArgs e)
- {
- pressure--;
- textBox2.Text = pressure.ToString();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- temperature--;
- textBox1.Text = temperature.ToString();
- }
- private void button7_Click(object sender, EventArgs e)
- {
- if (polarity == false) {
- calculateResult(array[index, 0], array[index, 1], array[index, 2], d);
- } else
- {
- calculateResult(array[(index+12), 0], array[(index+12), 1], array[(index+12), 2], d);
- }
- double value = calculateDiameter(space, d);
- double k = calculateParameter(pressure, temperature);
- MessageBox.Show(result.ToString()+" kV\n", "Napięcie przeskoku: ");
- textBox4.Text = value.ToString();
- textBox5.Text = Math.Round(k,3).ToString();
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- index = comboBox1.SelectedIndex;
- d = Convert.ToDouble(comboBox1.Items[index]);
- }
- private void textBox4_TextChanged(object sender, EventArgs e)
- {
- }
- private void button4_Click(object sender, EventArgs e)
- {
- temperature++;
- textBox1.Text = temperature.ToString();
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- space = (float)Convert.ToDouble(textBox3.Text);
- bool valid = float.TryParse(textBox3.Text.ToString(), out space);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement