public GraphForm(AlgorithmTests test) { InitializeComponent(); testRef = test; this.Text = "Prikaz rezultata testiranja"; }
public MainUI() { InitializeComponent(); numericUpDowns = new NumericUpDown[] { tbTest1, tbTest2, tbTest3, tbTest4, tbTest5 }; numericUpDownsMinMax = new NumericUpDown[] { tbMinValue, tbMaxValue }; this.Text = "Aplikacija za testiranje algoritama sortiranja"; _label_file_name.Text = "Ime datoteke"; AlgorithmTests test = new AlgorithmTests(); InitializeBackgroundWorkerHandlers(); }
//write JSON file with object data private void WriteJSON(AlgorithmTests test) { saveFileDialog.FileName = newJsonFileName; saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string json = JsonConvert.SerializeObject(test); if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { TextWriter writeDataToFile = new StreamWriter(saveFileDialog.OpenFile()); writeDataToFile.Write(json); writeDataToFile.Close(); } }
//load file and import data from file private void load_file_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string array_file = openFileDialog1.FileName; string json = File.ReadAllText(array_file); _label_file_name.Text = array_file; test = new AlgorithmTests(); test = JsonConvert.DeserializeObject <AlgorithmTests>(json); test.GetMainReference(this); FillUIElements(); test.DisplayDataFromFile(); } }
//"start test" button funcitonality public void btnStartAlgorithmTests_Click(object sender, EventArgs e) { if (dropdownTestType.SelectedItem == null) { MessageBox.Show( "Niste odabrali vrstu testa!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error ); Console.WriteLine(this); } else if (lbAlgs.Items.Count == 0 && dropdownTestType.SelectedIndex == 0) { MessageBox.Show( "Niste odabrali nijedan algoritam!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error ); } else if (!CheckTestCount() && dropdownTestType.SelectedIndex == 0) { MessageBox.Show( "Niste odabrali broj testova!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error ); } else if (!CheckTextBoxes() && dropdownTestType.SelectedIndex == 0) { MessageBox.Show("Niste unijeli veličinu polja!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (tbMinValue.Value > tbMaxValue.Value) { MessageBox.Show("Minimalna vrijednost u polju mora biti manja od maksimalne!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (tbMinValue.Value == tbMaxValue.Value) { MessageBox.Show("Minimalna i maksimalna vrijednost ne smiju biti iste!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (dropdownTestType.SelectedIndex == 0) { GetDataFromUI(); test = new AlgorithmTests(algorithms, testRepetitions, array_size, min, max); test.GetMainReference(this); newJsonFileName = "test_" + DateTime.Now.ToString("ddMMyy_HHmmss") + ".json"; } btnStartAlgorithmTests.Enabled = false; btnStopTesting.Enabled = true; InitializeGraphForm(); graphForm.EnableChartSeries(); SetTimer(); RunAlgorithmTests(); } }