コード例 #1
0
 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();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public SpringModelReportStatus(SpringModel spModel)
 {
     _spModel = spModel;
     InitializeComponent();
 }
コード例 #5
0
 private void txt_desired_TextChanged(object sender, EventArgs e)
 {
     singleStepModel = null;
 }