private void refuelVehicle(string i_LicenseNumber) { try { Messages.ClearAndDisplayMessage(Messages.SelectFuelType); Console.WriteLine(EnumOperations.ListEnumValues <eFuelType>(k_EnumListWithNumbers)); eFuelType fuelChoice = (eFuelType)getOptionFromUser(r_NumOfFuelTypes); Messages.ClearAndDisplayMessage(Messages.EnterFuelAmount); float fuelToAdd; while (!float.TryParse(Console.ReadLine(), out fuelToAdd)) { Console.WriteLine(Messages.InvalidNumberInserted); } r_GarageManager.RefuelVehicle(i_LicenseNumber, fuelChoice, fuelToAdd); Messages.ClearAndDisplayMessage(Messages.RefueledSuccessfully); } catch (Exception e) { Messages.ClearAndDisplayMessage(e.Message); } enterToContinue(); }
private void btResult_Click(object sender, EventArgs e) { if (secondElement != "") { switch (lastOperation) { case EnumOperations.None: break; case EnumOperations.Plus: firstElement = (Convert.ToDouble(firstElement) + Convert.ToDouble(secondElement)).ToString(); tbResult.Text = firstElement; break; case EnumOperations.Minus: firstElement = (Convert.ToDouble(firstElement) - Convert.ToDouble(secondElement)).ToString(); tbResult.Text = firstElement; break; case EnumOperations.Multiply: firstElement = (Convert.ToDouble(firstElement) * Convert.ToDouble(secondElement)).ToString(); tbResult.Text = firstElement; break; case EnumOperations.Divide: firstElement = (Convert.ToDouble(firstElement) / Convert.ToDouble(secondElement)).ToString(); tbResult.Text = firstElement; break; } } currentOperation = EnumOperations.Result; }
private void changeVehicleStatus() { string licenseNumber = insertLicenseNumber(); Vehicle vehicle; if (r_GarageManager.FindVehicle(licenseNumber, out vehicle)) { bool v_InvalidInput = true; Messages.ClearAndDisplayMessage(Messages.SelectVehicleStatus); Console.WriteLine(EnumOperations.ListEnumValues <eVehicleStatus>(k_EnumListWithNumbers)); while (v_InvalidInput) { int newStatus = getOptionFromUser(r_NumOfVehicleStatuses); try { r_GarageManager.ChangeVehicleStatus(licenseNumber, (eVehicleStatus)newStatus); Messages.ClearAndDisplayMessage(Messages.StatusHasBeenChanged); break; } catch (Exception e) { Console.WriteLine(e.Message); } } } else { Messages.ClearAndDisplayMessage(Messages.VehicleIsNotInGarage); } enterToContinue(); }
private void displayListOfVehiclesInGarage() { Messages.ClearAndDisplayMessage(Messages.SelectListType); int option = getOptionFromUser(k_TwoOptions); string listOfVehiclesToDisplay = string.Empty; switch (option) { case 1: listOfVehiclesToDisplay = r_GarageManager.DisplayAllVehicles(); break; case 2: Messages.ClearAndDisplayMessage(Messages.SelectSpecificList); Console.WriteLine(EnumOperations.ListEnumValues <eVehicleStatus>(k_EnumListWithNumbers)); eVehicleStatus statusOfVehiclesToShow = (eVehicleStatus)getOptionFromUser(r_NumOfVehicleStatuses); listOfVehiclesToDisplay = r_GarageManager.DisplayVehiclesByStatus(statusOfVehiclesToShow); break; } if (listOfVehiclesToDisplay == string.Empty) { listOfVehiclesToDisplay = Messages.EmptyList; } printAndEnterToContinue(listOfVehiclesToDisplay); }
private void ResetCalc() { currentOperation = EnumOperations.None; firstElement = "0"; secondElement = ""; lastSecondElement = ""; tbResult.Text = "0"; }
private eVehicleType getVehicleTypeFromUser() { Messages.ClearAndDisplayMessage(Messages.ChooseVehicleType); Console.WriteLine(EnumOperations.ListEnumValues <eVehicleType>(k_EnumListWithNumbers)); int numOfVehicleTypes = Enum.GetNames(typeof(eVehicleType)).Length; int vehicleTypeChosen = getOptionFromUser(numOfVehicleTypes); eVehicleType vehicleType = (eVehicleType)vehicleTypeChosen; return(vehicleType); }
private void initMenu() { string allEnumVehicleType = EnumOperations.ListEnumValues <eVehicleType>(true); m_ArrOfAllEnumVehicleType = allEnumVehicleType.Split('\n'); foreach (string newItem in m_ArrOfAllEnumVehicleType) { vehicleTypeComboBox.Items.Add(newItem.Replace("\r", string.Empty)); } }
private void btDivide_Click(object sender, EventArgs e) { switch (currentOperation) { case EnumOperations.None: break; case EnumOperations.Divide: { if (secondElement != "") { if (lastSecondElement == "") { firstElement = (Convert.ToDouble(firstElement) / Convert.ToDouble(secondElement)).ToString(); lastSecondElement = secondElement; secondElement = "0"; } else { firstElement = (Convert.ToDouble(firstElement) / Convert.ToDouble(lastSecondElement)).ToString(); } tbResult.Text = firstElement; } break; } case EnumOperations.Plus: case EnumOperations.Minus: case EnumOperations.Multiply: case EnumOperations.Result: secondElement = "0"; break; default: break; } currentOperation = EnumOperations.Divide; lastOperation = EnumOperations.Divide; }
public static T GetValue <T>(this Enum pEnumItem) { return(EnumOperations.GetValue <T>(pEnumItem)); }
public static T ToEnum <T>(this string name) { return(EnumOperations.ToEnum <T>(name)); }
public static string GetEnumDescription(this Enum pEnumItem) { return(EnumOperations.GetEnumDescription(pEnumItem)); }
public void DrawRectangleLightGrayDot(Rectangle rect) { this.Operation = EnumOperations.Operation_DrawRectangle; this.Rect = rect; this.Refresh(); }
public void DrawLines(List <Line> lines) { this.Operation = EnumOperations.Operation_DrawLines; this.Lines = lines; this.Refresh(); }
public HourGlassUserException(ExceptionType exceptionType, params object[] parameters) : base(string.Format(EnumOperations.GetDescriptionOf(exceptionType), parameters)) { }