private CompileFunction ( string code, int dims ) : MethodResults | ||
code | string | |
dims | int | |
리턴 | MethodResults |
private void OkButton_Click(object sender, EventArgs e) { ResultFunction = SetFunction ? Main.CompileFunction(FunctionBox.Text, Dims) : Main.CompileConstraint(FunctionBox.Text, Dims); if (ResultFunction == null) { return; } Close(); }
private void SetButton_Click(object sender, EventArgs e) { SetButton.Text = "Working"; SetButton.Enabled = false; if (Main.Play) { Main.PlayButton_Click(null, null); Thread.Sleep(500); } int dimensions = (int)DimensionBox.Value; try { if (dimensions < 1) { MessageBox.Show("There must be at least one dimension"); return; } float[] testInput = new float[dimensions]; foreach (string item in FunctionList.Items) { string function = item.Substring(10); MethodResults func = Main.CompileFunction(function, dimensions); float result = (float)func.Invoke(testInput, 0f); } foreach (string constraint in ConstraintsList.Items) { MethodResults consts = Main.CompileConstraint(constraint, dimensions); bool good = (bool)consts.Invoke(testInput, 0f); } } catch (Exception ex) { MessageBox.Show(ex.Message); //MessageBox.Show("Function or Constraint has more variabls than allowed by the specified # of dimensions"); SetButton.Text = "Set"; SetButton.Enabled = true; return; } if (dimensions != Main.Config.Dimensions || Main.BestGlobalValue.Length != FunctionList.Items.Count) { Main.Config.Dimensions = dimensions; Main.ResetDimensions(FunctionList.Items.Count); } Main.Config.FunctionEqs.Clear(); foreach (string function in FunctionList.Items) { Main.Config.FunctionEqs.Add(function); } Main.Config.ConstraintEqs.Clear(); foreach (string constraint in ConstraintsList.Items) { Main.Config.ConstraintEqs.Add(constraint); } Main.CompileProblem(); float.TryParse(TimeBox.Text, out Main.Config.TimeInc); Main.Config.TimeUsed = TimeCheckBox.Checked; Main.RefreshAxisCombos(); Main.RefreshEvent.Set(); Main.Window.ResetView(); SetButton.Text = "Set"; SetButton.Enabled = true; }