/// <summary> /// Has the car arrived at its destination? /// </summary> /// <returns>true if arrived, false if still transitioning.</returns> private bool ArrivedDestination() { bool arrived = false; // Are we heading in a direction, but servicing the opposite list (i.e. heading up to service the downList - or vice versa) Direction currentListDirection = (CurrentList == upList) ? Direction.up : Direction.down; if (currentListDirection != CurrentDirection) { // We are servicing opposing list / direction case. We have only arrived if we are at the head of the list. if ((CurrentList.Count > 0) && (CurrentList[0] != CurrentFloor)) { return(arrived); } } if (CurrentList.Contains(CurrentFloor)) { Console.WriteLine("Car is on floor {0}, loading/unloading passengers, and {1}.", CurrentFloor, (CurrentDirection == Direction.idle) ? "is idle" : "is heading " + CurrentDirection.ToString()); Console.WriteLine("You have {0} seconds to choose your destination. Otherwise, you may loose your turn.", ElevatorTimer.TheTimer.Interval / 1000); CurrentList.Remove(CurrentFloor); arrived = true; } return(arrived); }
private void DeleteProduct() { using (var db = new ShoppingContext()) { var productToRemove = db.Products.SingleOrDefault(x => x.ProductId == SelectedProduct.OriginalProduct.ProductId); db.Products.Remove(productToRemove); db.SaveChanges(); } CurrentList.Remove(SelectedProduct); }
private void deleteNote() { int temp = SelectedIndex; if (temp >= 0 && temp < CurrentList.Size) { CurrentList.Remove(temp); SelectedIndex = temp > 0 ? temp - 1 : 0; Utilities.SavedData.Save(Tabs); } }
private void MoveElevator() { // The elevator is moving in a direction if ((CurrentDirection == Direction.up) || (CurrentDirection == Direction.down)) { int destination = -1; // Are there more items on the CurrentList - which are eligible for servicing? int found = CurrentList.FindIndex((n) => { if (CurrentDirection == Direction.up) { return(n > CurrentFloor); } else if (CurrentDirection == Direction.down) { return(n < CurrentFloor); } return(false); }); // If not, it is time to reverse direction if (found == -1) { List <int> otherList = (CurrentList == upList) ? downList : upList; if (otherList.Count == 0) { CurrentDirection = Direction.idle; return; } CurrentList = otherList; SetDirection(); destination = CurrentList[0]; // We have switched lists. Are we on a floor on the new list? if (CurrentFloor == destination) { CurrentList.Remove(destination); return; } } else { destination = CurrentList[found]; } Console.WriteLine("The elevator is moving past floor {0} transitioning to {1}", CurrentFloor, destination); CurrentFloor = (CurrentDirection == Direction.up) ? CurrentFloor + 1 : CurrentFloor - 1; //FutureDirection = OppositeDirection; return; } }
private void buttonRemove_Click(object sender, EventArgs e) { var item = CurrentlySelected; if (item == null) { return; } CurrentList.Remove(item); PopulateList(); OnFiltersChanged(sender, e); }
private void RemoveFromCurrent() { //Need to reassign as Remove will set SelectedCurrent to null var tmp = SelectedCurrent; if (tmp == null) { return; } bool removed = CurrentList.Remove(tmp); if (removed && tmp.ID > 0) { AllTags.Add(tmp); } }
public virtual void RemoveAt(int index) { CurrentList.Remove(index); }
public virtual void Remove(T newVal) { CurrentList.Remove(newVal); }