private void IsCheck(object sender, RoutedEventArgs e) { var radioCheck = sender as System.Windows.Controls.RadioButton; switch (radioCheck.Name) { case "_1st": testElevator = testElevator1; flag = 1; Remake(); break; case "_2nd": testElevator = testElevator2; flag = 2; Remake(); break; case "_3rd": testElevator = testElevator3; flag = 3; Remake(); break; case "_4th": testElevator = testElevator4; flag = 4; Remake(); break; } getOnElevator.IsEnabled = true; }
public string Working(List <int> list, TestElevator elevator, List <int> storeList) { if (int.Parse(elevator.waitFloor) == list[0]) { elevator.mode = elevator.WAIT_MODE; } if (elevator.mode == elevator.WAIT_MODE) { if (int.Parse(elevator.waitFloor) == list[0]) { list.Remove(list[0]); } if (list.Count != 0 && int.Parse(elevator.waitFloor) < list[0]) { elevator.mode = UP_MODE; foreach (var item in storeList) { list.Add(item); } storeList.Clear(); } else if (list.Count != 0 && int.Parse(elevator.waitFloor) > list[0]) { elevator.mode = DOWN_MODE; foreach (var item in storeList) { list.Add(item); } storeList.Clear(); } } if (elevator.mode == UP_MODE) { list.Sort(); for (int i = 0; i < list.Count; i++) { if (int.Parse(elevator.waitFloor) <= list[0]) { break; } int temp = list[0]; list.Remove(list[0]); list.Add(temp); } } else if (elevator.mode == DOWN_MODE) { list.Sort(); list.Reverse(); for (int i = 0; i < list.Count; i++) { if (int.Parse(elevator.waitFloor) >= list[0]) { break; } int temp = list[0]; list.Remove(list[0]); list.Add(temp); } } if (list.Count == 0) { return(elevator.waitFloor); } else { return(list[0].ToString()); } }