private void SpringNStep() { try { if (singleStepModel == null) { singleStepModel = new SpringModel(Nodes, Edges, double.Parse(txt_desired.Text), double.Parse(txt_desiredEdgeLength.Text), AllocationMode); singleStepModel.InitializeSpringModel(); singleStepModel.NodePositionChanged += new NodePositionChangedEventHandler(singleStepModel_NodePositionChanged); } for (int i = 0; i < int.Parse(txt_N.Text); i++) { singleStepModel.ChildSingleStep(); } SpringModelReportStatus smrs = new SpringModelReportStatus(singleStepModel); smrs.ShowDialog(); } catch (Exception) { MessageBox.Show("Input Error"); singleStepModel = null; return; } this.Nodes = singleStepModel.Nodes; this.Edges = singleStepModel.Edges; panel2.Invalidate(); }
private void SpringRun() { SpringModel SM = new SpringModel(Nodes, Edges, double.Parse(txt_desired.Text), double.Parse(txt_desiredEdgeLength.Text), AllocationMode); if (singleStepModel != null) { singleStepModel.NodePositionChanged -= new NodePositionChangedEventHandler(singleStepModel_NodePositionChanged); singleStepModel = null; } SM.NodePositionChanged += new NodePositionChangedEventHandler(singleStepModel_NodePositionChanged); SM.Run(); SM.NodePositionChanged -= new NodePositionChangedEventHandler(singleStepModel_NodePositionChanged); //List<double> nodesEnergy = SM.GetNodesEnergy(); //string s = ""; //int i = 0; //foreach (double en in nodesEnergy) //{ // s += "Node " + i + " : " + en + "\n"; // i++; //} //s += "i = " + SM.i.ToString(); //MessageBox.Show(s); //panel2.Invalidate(); }
private void button1_Click(object sender, EventArgs e) { if (radioButton_Random.Checked == true) { AllocationMode = Mode.RANDOM; } else if (radioButton_UserDefined.Checked == true) { AllocationMode = Mode.USERDEFINED; } else { AllocationMode = Mode.CIRCULAR; } try { if (singleStepModel == null) { singleStepModel = new SpringModel(Nodes, Edges, double.Parse(txt_desired.Text), double.Parse(txt_desiredEdgeLength.Text), AllocationMode); singleStepModel.InitializeSpringModel(); singleStepModel.NodePositionChanged += new NodePositionChangedEventHandler(singleStepModel_NodePositionChanged); } singleStepModel.ChildSingleStep(); } catch (Exception) { MessageBox.Show("Input Error"); singleStepModel = null; return; } lock (Nodes) { this.Nodes = singleStepModel.Nodes; this.Edges = singleStepModel.Edges; } panel2.Invalidate(); MessageBox.Show(singleStepModel.MaximumEnergyNode.index + " : " + singleStepModel.MaximumEnergyNode.energy); }
public SpringModelReportStatus(SpringModel spModel) { _spModel = spModel; InitializeComponent(); }
private void txt_desired_TextChanged(object sender, EventArgs e) { singleStepModel = null; }