Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Windows.Forms;
- namespace refueling
- {
- public partial class Form1 : Form
- {
- Model model = new Model();
- public Form1()
- {
- InitializeComponent();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- Thread myThread = new Thread(new ThreadStart(Func1));
- }
- public static void Func1()
- {
- Model m = new Model();
- m.DoOneIteration();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- checkBox1.Checked = false;
- checkBox2.Checked = false;
- checkBox3.Checked = false;
- textBox2.Clear();
- textBox3.Clear();
- textBox4.Clear();
- textBox6.Clear();
- FlashToTextBox(0, 0, 0, 0);
- if (!SetData())
- {
- return;
- }
- for (int i = 0; i < model.GetNumberOfIteration(); i++)
- {
- model.DoOneIteration();
- checkBox1.Checked = model.GetCheckBox1();
- checkBox2.Checked = model.GetCheckBox2();
- checkBox3.Checked = model.GetCheckBox3();
- FlashToTextBox(model.GetNumberOfCar(), model.GetCarsGone(), model.GetCarsIn(), i + 1);
- }
- }
- private void button2_Click(object sender, EventArgs e){ }
- private void radioButton1_CheckedChanged(object sender, EventArgs e){}
- private void timer1_Tick(object sender, EventArgs e){}
- private void FlashToTextBox(int numOfCar, int carsGone, int carsIn, int numOfIteration)
- {
- textBox4.Text = numOfCar.ToString();
- textBox4.Update();
- textBox2.Text = carsGone.ToString();
- textBox2.Update();
- textBox3.Text = carsIn.ToString();
- textBox3.Update();
- textBox6.Text = numOfIteration.ToString();
- textBox6.Update();
- Thread.Sleep(50);
- }
- private bool SetData()
- {
- double dTmp;
- int iTmp;
- model.SetNumOfCar(0);
- model.SetCarsGone(0);
- model.SetCarsIn(0);
- if (!double.TryParse(textBox5.Text, out dTmp))
- {
- return false;
- }
- if (dTmp > 1)
- {
- return false;
- }
- model.SetComingTime(dTmp);
- if (!double.TryParse(textBox7.Text, out dTmp))
- {
- return false;
- }
- if (dTmp > 1)
- {
- return false;
- }
- model.SetRefuelingTime(dTmp);
- if (!int.TryParse(textBox1.Text, out iTmp))
- {
- return false;
- }
- model.SetNumOfIteration(iTmp);
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement