public Form1() { InitializeComponent(); this.FormClosing += Form1_FormClosing; best = GetObjectBestSampleAlgorithm(); if (best != null) { SetControlParams(best); } if (best == null) { SaveCheckBox.Checked = false; } }
private BestSampleAlgorithm GetObjectBestSampleAlgorithm() { BestSampleAlgorithm bestAlgorithm = new BestSampleAlgorithm(); try { ObjectSerializer <BestSampleAlgorithm> objSerializer = new ObjectSerializer <BestSampleAlgorithm>(); BestSampleAlgorithm yourObjectFromFile = objSerializer.GetSerializedObject(SerializePathObject); if (yourObjectFromFile != null) { bestAlgorithm = yourObjectFromFile; } else { bestAlgorithm = null; } } catch (Exception) { } return(bestAlgorithm); }
private void button1_Click(object sender, EventArgs e) { Random random = new Random(DateTime.Now.Millisecond); string function = FunctionTextBox.Text; double testStep = double.Parse(TestStepInputTextBox.Text.Replace(".", ",")); ExtendedPoint point = new ExtendedPoint(); point.X = random.Next(-10, 10); point.Y = random.Next(-10, 10); best = new BestSampleAlgorithm(function, testStep); best.QuantityVectrors = int.Parse(VectorsInputTextBox.Text); var result = best.StartSolution(point); OutPutXLabel.Text = best.EndPoint.X.ToString(); OutPutYLabel.Text = best.EndPoint.Y.ToString(); XinputLabel.Text = point.X.ToString(); YinputLabel.Text = point.Y.ToString(); ResultOutputLable.Text = result.ToString(); }
private void SetControlParams(BestSampleAlgorithm best) { FunctionTextBox.Text = best.Functioon; TestStepInputTextBox.Text = best.TestStep.ToString(); VectorsInputTextBox.Text = best.QuantityVectrors.ToString(); }
private void InitializeBSA() { best = new BestSampleAlgorithm(BSA_FunctionText.Text, 0.1); best.Progress += Best_Progress; BSA_ProgressBar.Maximum = 10; }