示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            prm = new Params();
            move = new Movement();
            bsgraph = new BindingSource();
            datastore = new List<Movement>();
            //setup the parameters - call the extra windows form
            frmParameters p = new frmParameters();
            //user can use preset values
            p.Param_data.Buckets = 5;
            p.Param_data.Inflow = 10;
            p.Param_data.Outflow = 1;
            p.Finaltime = 10;
            p.Movement.Omega = 0.1f;
            DialogResult d = p.ShowDialog();
            //or set is own one
            if (d == DialogResult.OK)
            {
                prm.Buckets = p.Param_data.Buckets;
                prm.Inflow = p.Param_data.Inflow;
                prm.Outflow = p.Param_data.Outflow;
                finaltime = p.Finaltime;
                move.Omega = p.Movement.Omega;
            }
            else if (d == DialogResult.Cancel)
            {
                prm.Buckets = 5;
                prm.Theta = 0;
                prm.Inflow = 10;
                prm.Outflow = 1;
                finaltime = 10;
                move.Omega = 0.1f;
            }
            //setup the transform for painting
            SetupTransform();
            //initialize the picture
            r = 40;
            cX = 50;
            cY = 50;
            //initialize the list of buckets
            buckets = new List<Bucket>();
            for (int i = 0; i < prm.Buckets; i++)
            {
                b = new Bucket(0);
                buckets.Add(b);
            }
            //initialize the timer
            timer = new Timer();
            timer.Tick += frm_Tick;
            timer.Interval = 50;

            //the text boxes...
            txtUpDownBuckets.DataBindings.Add("Text", prm, "Buckets");
            txtMass.DataBindings.Add("Text", prm, "Mass");
            txtTheta.DataBindings.Add("Text", prm, "Theta");
            txtUpDownBuckets.Maximum = limitbucket;
            txtUpDownBuckets.Minimum = 0;
            textBox1.Visible = false;
            rbNormal.Checked = true;
        }
示例#2
0
 private void frm_Tick(object sender, EventArgs e)
 {
     if (iter >= data.GetLength(0))
     {
         timer.Stop();
         btStop_Click(sender,e);
         return;
     }
     prm.Theta = data[iter,0];
     //graph
     Movement p=new Movement();
     p.B=data[iter,2];
     p.Omega = data[iter,3];
     datastore.Add(p);
     //buckets
     prm.Mass = 0;
     for (int i = 0; i < prm.Buckets; i++)
     {
         buckets[i].W = data[iter, i + 4];
         if (buckets[i].W > buckets[i].B) buckets[i].W = buckets[i].B;
         prm.Mass += buckets[i].W;
     }
     //update the text boxes...databindings fails
     time += (float) 0.05;
     txtTime.Text = Convert.ToString(time);
     txtTheta.Text = Convert.ToString(prm.Theta);
     txtMass.Text = Convert.ToString(prm.Mass);
     iter++;///move to next step
     this.Refresh();//redraw the picture
 }
 public frmParameters()
 {
     InitializeComponent();
     param_data = new Params();
     movement = new Movement();
 }