public SettingsViewModel() { AddCommand = new RelayCommand(() => { var fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Pathlist.Add(fbd.SelectedPath); } }); RemoveCommand = new RelayCommand(() => { Pathlist.RemoveAt(SelectedPathIndex); }); ReplaceCommand = new RelayCommand(() => { var fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Pathlist[SelectedPathIndex] = fbd.SelectedPath; } }); OkCommand = new RelayCommand(() => { FileLocator.Pathlist = Pathlist.ToList(); FileLocator.SaveConfiguration(); DialogResult = true; }); Pathlist = new ObservableCollection <string>(FileLocator.Pathlist); }
public Pathlist FindPath(List <Pathlist> pathList, List <Location> allLocations, Location startLocation, Location endlocation, int alternateNum) { FilterLocations(allLocations, startLocation, endlocation); FindPossibleLocations(pathList, allLocations, startLocation); FindCloseLocations(allLocations, startLocation); Pathlist nextLocation = FindNextLocation(allLocations, endlocation, alternateNum); return(nextLocation); }
public Pathlist AddLocationToPathlist(Location location) { Pathlist pathLocation = new Pathlist(); pathLocation.Id = Guid.NewGuid(); pathLocation.latitude = location.latitude; pathLocation.longitude = location.longitude; pathLocation.name = location.name; return(pathLocation); }
private void RemoveAction(Pathlist pathlist) { if (PlaylistCollection.Contains(pathlist)) { PlaylistCollection.Remove(pathlist); } if (!removePlaylist.Contains(pathlist)) { removePlaylist.Add(pathlist); } RaisePropertyChanged(() => this.PlayCollectionCountString); }
public Pathlist FindNextLocation(List <Location> allLocations, Location endLocation, int alternateNum) { foreach (Location location in allLocations) { location.distanceFromLocation = -1; if (location.closePlace == true) { location.distanceFromLocation = calculateDistance(location, endLocation); } } double closestValue = double.MaxValue; for (int townNum = 0; townNum < alternateNum; townNum++) { closestValue = double.MaxValue; foreach (Location location in allLocations) { if (location.possibleLocation = true && location.closePlace == true && location.distanceFromLocation < closestValue && location.distanceFromLocation != -1) { closestValue = location.distanceFromLocation; } } Location notAlternateLocation = FindLocationByDistance(closestValue, allLocations); if (notAlternateLocation == endLocation && townNum == 0) { Pathlist endingLocation = AddLocationToPathlist(endLocation); return(endingLocation); } notAlternateLocation.closePlace = false; } closestValue = double.MaxValue; foreach (Location location in allLocations) { if (location.closePlace == true && location.distanceFromLocation < closestValue && location.distanceFromLocation != -1) { closestValue = location.distanceFromLocation; } } Location closeLocation = FindLocationByDistance(closestValue, allLocations); Pathlist pathLocation = new Pathlist(); pathLocation = AddLocationToPathlist(closeLocation); SetDistance(closestValue); return(pathLocation); }
public async ValueTask <List <Pathlist> > CompileList(Location startLocation, Location endLocation, int alternateNum) { List <Pathlist> pathlists = new List <Pathlist>(); pathlists.Add(AddLocationToPathlist(startLocation)); if (startLocation == endLocation) { return(pathlists); } resetDistance(); SetDistance(calculateDistance(startLocation, endLocation)); List <Location> allLocation = this.locationStorageBroker.SelectAllLocationsAsync().ToList(); Pathlist checkedLocation = FindPath(pathlists, allLocation, startLocation, endLocation, alternateNum); pathlists.Add(checkedLocation); resetLocations(allLocation); Location nextLocation = new Location(); while (checkedLocation.latitude != endLocation.latitude || checkedLocation.longitude != endLocation.longitude) { double nextLongitude = checkedLocation.longitude; double nextLatitude = checkedLocation.latitude; foreach (Location location in allLocation) { if (location.longitude == nextLongitude && location.latitude == nextLatitude) { nextLocation = location; } } checkedLocation = FindPath(pathlists, allLocation, nextLocation, endLocation, alternateNum); pathlists.Add(checkedLocation); resetLocations(allLocation); } return(pathlists); }