Exemple #1
0
        private void addObjectsButton_Click(object sender, EventArgs e)
        {
            if (_objectTemplate == null)
            {
                return;
            }

            int number;

            if (!int.TryParse(numberOfObjectsToAdd.Text, out number))
            {
                MessageBox.Show("Number of Objects must be an integer!");
                return;
            }

            for (int i = 0; i < number; i++)
            {
                var newObject = _objectTemplate.Duplicate();

                double x = JobEngine.Rand.NextDouble() * _currentJob.Box.XLength;
                double y = JobEngine.Rand.NextDouble() * _currentJob.Box.YLength;

                newObject.X         = x;
                newObject.Y         = y;
                newObject.PreviousX = x;
                newObject.PreviousY = y;

                _currentJob.Box.MonteCarloObjects.Add(newObject);
            }

            UpdateMonteCarloPlot(_currentJob.Box);

            propertyGrid1.SelectedObject = null;
            propertyGrid1.SelectedObject = _currentJob;
        }