//Set function button private void button1_Click(object sender, EventArgs e) { if (fieldsizetb.Text != "" && scaletb.Text != "") { for (int p = 0; p < 9; p++) { if (tb[p].Text != "") { innerParameters[p] = Convert.ToDecimal(tb[p].Text); } else { innerParameters[p] = 0; } } fieldSize = Convert.ToInt32(fieldsizetb.Text); scale = Convert.ToInt32(scaletb.Text); allCellf = new AllCellsFunc(func.FunctionForAllParsed(FunctionForCellsCB.Text)); ok.Enabled = true; } else { fieldSizeEmpty.Text = fieldsizetb.Text != "" ? "" : "*Field size is required"; ScaleEmpty.Text = scaletb.Text != "" ? "" : "*Scale is required"; } //mainFunction = tentCB.Checked ? "Tent" : "Logistic"; }
//Set function button private void button1_Click(object sender, EventArgs e) { if (fieldsizeHeighttb.Text != "" && fieldsizeHeighttb.Text != "Height" && fieldsizeWidthtb.Text != "Width" && fieldsizeWidthtb.Text != "" && scaletb.Text != "") { try { var uiValidation = 0.0m; for (int p = 0; p < 9; p++) { if (tb[p].Text != "") { innerParameters[p] = Convert.ToDecimal(tb[p].Text); } else { innerParameters[p] = p == 8 ? 1 : 0; } uiValidation += innerParameters[p]; } if (uiValidation == 1) { tb[8].Text = "1"; } HeightImg = Convert.ToInt32(fieldsizeHeighttb.Text); WidthImg = Convert.ToInt32(fieldsizeWidthtb.Text); scale = Convert.ToInt32(scaletb.Text); allCellf = new AllCellsFunc(funcParsing.FunctionForAllParsed(CalcFunctionCB.SelectedValue.ToString()));// // Logistic return 4 * x * (1 - x); // Tent return 1 - Math.Abs(2 * x - 1); // x return x; // Life decimal d = 17.0m; if (x >= 5 / d && x < 8 / d) { return 1; } else { return 0; } // linear return 2 * x - 16 //linear return 2 * x - 16 //test function return x / 2; // test2 return Convert.ToDecimal(Math.Pow(x, 2)); // Population return 4 * (1 - 0.5m * y) * x * (1 - x); // Population alfa = 0.3 return 4 * (1 - 0.3m * y) * x * (1 - x); // Population alfa = 0.2 return 4 * (1 - 0.2m * y) * x * (1 - x); // Population alfa = 0.1 return 4 * (1 - 0.1m * y) * x * (1 - x); // population alfa = 0 return 4 * (1 - 0.0m * y) * x * (1 - x); // population alfa = 0.05 return 4 * (1 - 0.05m * y) * x * (1 - x); ok.Enabled = true; weightsLbl.ForeColor = Color.Green; weightsLbl.Text = "Data set is completed. Press OK to continue"; } catch (Exception ex) { if (ex.Message == "Input string was not in a correct format.") { weightsLbl.Text = "*Values for cell weights, field size and scale should be decimals!"; } else { weightsLbl.Text = "*There is some problem with chosen function"; } } } else { Validation(); } }