public void AddTruckAndFillWithDetails(eTypeOfVeichle i_TypeOfVeichile, string i_LicenceID, string i_VehicleModel, float i_EngineCurrentEnergy, List <Tire> i_Tires, bool i_IsDangarus, float i_TruckCapacity) { switch (i_TypeOfVeichile) { case eTypeOfVeichle.Truck: if (Vehicles == null) { Vehicles = new List <Vehicle>(); } if (Trucks == null) { Trucks = new List <Truck>(); } Truck truck = VeichileFactory.CreateTruck(i_TypeOfVeichile); truck.LicenceID = i_LicenceID; truck.Model = i_VehicleModel; truck.Engine.CurrentEnergy = i_EngineCurrentEnergy; truck.Tires = i_Tires; truck.IsHazardous = i_IsDangarus; truck.TruckCapacity = i_TruckCapacity; Trucks.Add(truck); Vehicles.Add(truck); break; } }
private void AddingNewTruck(string name, string model, string vin, string engineVol, DateTime manYear) { double engineVolume = 0; if (engineVol != "") { engineVolume = ParseToDouble(engineVol); } if (model != "" && vin != "" && engineVolume != 0) { Truck.Name = TruckName(name); Truck.Model = model; Truck.VIN = vin; Truck.EngineVolume = engineVolume; Truck.ManufactureYear = manYear; Truck.DefectsDescription.Add(defectTextBox.Text); Trucks.Add(Truck); TrucksListBox.DataSource = null; TrucksListBox.DataSource = Trucks; this.Close(); } else { MessageBox.Show("Заполните обязательные поля!"); } }
void AddTruck(TruckData td) { if (!Trucks.Contains(td)) { Trucks.Add(td); } else { var tcnt = truckData.Where(m => m.ManifestId == td.ManifestId).FirstOrDefault(); Trucks.Remove(tcnt); Trucks.Add(td); } }
private void GuiUpdate(string obj) //MEthode wird asugeführt wenn der clienthandler was empfängt { obj = "W-15b@Wien@Ladung1@10@4@Ladung2@30@1000"; //kann selbst gestaltet wrden String[] unformated = obj.Split('@'); var loads = new ObservableCollection <LoadVm>(); for (int i = 2; i < unformated.Length; i = i + 3) { loads.Add(new LoadVm(unformated[i], int.Parse(unformated[i + 1]), int.Parse(unformated[i + 2]))); //loads auslesen mit schleife weil mehrer loads pro truck } TruckVm newTruck = new TruckVm(unformated[0], unformated[1], loads); //neuen truck fühlen mit den elementen aus obj App.Current.Dispatcher.Invoke(() => // lanbda expressions - braucht ma weil mehrer threads die in die gui "eingreifen" - "syncht die threads und seralsierts" { Trucks.Add(newTruck); }); }
public void Pack(IEnumerable <BaseContainer> Containers) { Containers = OrderContainers(Containers); foreach (var c in Containers) { var FirstTruckWhereItFits = Trucks.FirstOrDefault(x => x.Fits(c)); if (FirstTruckWhereItFits == null) { Trucks.Add(new Truck((Rectangle)TrucksCapacity.Clone())); var LastTruck = Trucks.Last(); LastTruck.Add(c); } else { FirstTruckWhereItFits.Add(c); continue; } } }
public string AddCar(Car c) { if (c is SUV) { SUVs.Add(c); } else if (c is Van) { Vans.Add(c); } else if (c is Truck) { Trucks.Add(c); } else if (c is Sedan) { Sedans.Add(c); } AllCars.Add(c); return("Added " + c.Make + " " + c.Model + " at $" + c.Price); }
public async Task LoadAsync() { var trucks = TruckInfoSampleData.GetSampleData(); Trucks.Clear(); await Task.Delay(2000); foreach (var truck in trucks) { Trucks.Add(new TruckVM() { ID = truck.ID, Name = truck.Name, Style = truck.Style }); } await Repository .GetObject <IDialogService>() .ShowDialogAsync("Initialization", "Data loaded", "OK", null); }
//wird von ClientHandler ausgeführt wenn etwas empfangen wird -> Delegate private void GuiUpdate(string obj) { //obj = "S1-A54AB@Graz@Ladung1@10@4@Ladung2@100@400"; //ein Array wird empfangen und Split zeigt verschiedene IDs : Name, Source ... String[] unformated = obj.Split('@'); var loads = new ObservableCollection <LoadVM>(); for (int i = 2; i < unformated.Length; i = i + 3) { loads.Add(new LoadVM(unformated[i], int.Parse(unformated[i + 1]), int.Parse(unformated[i + 2]))); } //Dem Truck werden Index von Array übergeben TruckVM newTruck = new TruckVM(unformated[0], unformated[1], loads); //braucht man wenn mehrere Threads zugreifen können App.Current.Dispatcher.Invoke(() => { Trucks.Add(newTruck); }); }
private async Task <bool> tryDownloadTrucksFromCloud() { bool trucksDownloaded = false; using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { try { Logging.Logger.Log("INFO", "Fetch local trucks."); var localTrucks = dp.TruckRepository.GetAll(); Logging.Logger.Log("INFO", "Fetch local Drivers."); var localDrivers = dp.DriverRepository.GetAll(); Logging.Logger.Log("INFO", "Fetch current truck."); var currentTruck = dp.SettingsRepository.GetCurrentTruck(); Logging.Logger.Log("INFO", "Fetch current driver."); var currentDriver = dp.SettingsRepository.GetCurrentDriver(); if (currentDriver == null || currentTruck == null) //if no truck or driver set try to pull down from cloud and set a truck/driver { Logging.Logger.Log("INFO", "Initialize document db context."); CottonDBMS.Cloud.DocumentDBContext.Initialize(endpoint, key); Logging.Logger.Log("INFO", "Download trucks from cloud."); var trucks = await DocumentDBContext.GetAllItemsAsync <TruckEntity>(p => p.EntityType == EntityType.TRUCK); Logging.Logger.Log("INFO", "Download drivers from cloud."); var drivers = await DocumentDBContext.GetAllItemsAsync <DriverEntity>(p => p.EntityType == EntityType.DRIVER); if (localTrucks.Count() == 0) { Logging.Logger.Log("INFO", "Adding local trucks."); Trucks.Add(new ComboBoxItemViewModel { DisplayText = "-- Choose Truck --", ID = "" }); foreach (var t in trucks) { Logging.Logger.Log("INFO", "Adding truck " + t.Name); dp.TruckRepository.Add(t); Trucks.Add(new ComboBoxItemViewModel { DisplayText = t.Name, ID = t.Id.ToString() }); } } if (localDrivers.Count() == 0) { Drivers.Add(new ComboBoxItemViewModel { DisplayText = "-- Choose Driver --", ID = "" }); foreach (var d in drivers) { Logging.Logger.Log("INFO", "Adding driver " + d.Name); Drivers.Add(new ComboBoxItemViewModel { DisplayText = d.Name, ID = d.Id.ToString() }); dp.DriverRepository.Add(d); } } Logging.Logger.Log("INFO", "Saving db changes"); dp.SaveChanges(); Logging.Logger.Log("INFO", "Db changes saved"); trucksDownloaded = true; } else { Logging.Logger.Log("INFO", "Driver and truck already set."); } } catch (Exception exc) { Logging.Logger.Log(exc); } return(trucksDownloaded); } }
public DefaultPackager(Rectangle TrucksCapacity) { this.TrucksCapacity = TrucksCapacity; Trucks.Add(new Truck((Rectangle)TrucksCapacity.Clone())); }