Example #1
0
        /// <summary>
        /// Handles the start simulation button's click event.
        /// </summary>
        /// <param name="sender">The triggerer object.</param>
        /// <param name="e">The event arguments.</param>
        private void StartNewSimulation_Click(object sender, EventArgs e)
        {
            using (var simulationSettingsForm = new SimulationSettingsForm())
            {
                if (simulationSettingsForm.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                IAmbiguityResolver resolver = null;

                if (ManualResolver.Equals(AmbiguityResolverComboBox.SelectedItem))
                {
                    resolver = new ManualResolver();
                }
                else if (RandomResolver.Equals(AmbiguityResolverComboBox.SelectedItem))
                {
                    resolver = new RandomResolver();
                }

                var stepMethod = GetStepMethod();

                Graph.OnSimulationFinished += OnSimulationFinished;
                Graph.StartSimulation(stepMethod, simulationSettingsForm.GetInputArray(), resolver);

                if (stepMethod == SimulationStepMethod.Timed)
                {
                    TimedStepTimer.Interval = SimulationSpeedTrackBar.Value * 1000;
                    TimedStepTimer.Start();
                }
            }

            SetupUI();
        }
Example #2
0
        /// <summary>
        /// Handles the timed step timer's tick event.
        /// </summary>
        /// <param name="sender">The triggerer object.</param>
        /// <param name="e">The event arguments.</param>
        private void TimedStepTimer_Tick(object sender, EventArgs e)
        {
            var result = Graph.StepSimulation();

            if (result == SimulationStepResult.Success)
            {
                return;
            }

            TimedStepTimer.Stop();
        }