Exemple #1
0
 /// <summary>
 /// Выполнение алгоритма по шагам
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void StepClick(object sender, RoutedEventArgs e)
 {
     if (_robot.CurrentAction == null)
     {
         _robot.CurrentAction = _algorithm.ActionList.FirstOrDefault();
     }
     try
     {
         _robot.CurrentAction = _algorithmWork.ExecuteAction(_robot, _algorithm, _field);
     }
     catch
     {
         MessageBox.Show("Роботу встретился незнакомый цвет", "Ошибка");
     }
     ActionsList.Focus();
     ActionsList.SelectedIndex = _algorithm.ActionList.IndexOf(_robot.CurrentAction);
     if (_algorithmWork.CheckPosition(_algorithm, _robot))
     {
         UpdateBackPattern();
         DrawField();
     }
     else
     {
         MessageBox.Show("Роботу запрещено покидать свой маленьки мир(", "Попытка выхода за пределы поля");
     }
 }
Exemple #2
0
 /// <summary>
 /// Перериовка холста
 /// </summary>
 private void UpdateCanvas()
 {
     Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
     {
         ActionsList.Focus();
         ActionsList.SelectedIndex = _algorithm.ActionList.IndexOf(_robot.CurrentAction);
         UpdateBackPattern();
         DrawField();
     }));
 }