private void FavoritesButtonClicked(object sender, EventArgs e) { try { Structures.Basic.StationsBasic.StationBasic station = Request.GetStationFromString(stopEntry.Text); if (station == null) { PlatformDependentSettings.ShowMessage(Settings.Localization.UnableToFindStation + ": " + stopEntry.Text); return; } if (StationInfoCached.Select(station.ID) != null) { return; } var fav = new StationInfoCached(station.ID); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CacheDepartureBoardAsync(fav.ConstructNewRequest()); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed favoritesStackLayout.Children.Add(new FavoriteItemContentView(favoritesStackLayout, scrollView, fav, stopEntry)); } catch { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CheckBasicDataValidity(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } }
/// <summary> /// Returns station object with given name. If not found, returns error message within MessageBox. /// </summary> /// <param name="name">Name of the station.</param> /// <returns>Station object.</returns> public static Structures.Basic.StationsBasic.StationBasic GetStationFromString(string name) { Structures.Basic.StationsBasic.StationBasic source = DataFeedDesktop.Basic.Stations.FindByName(name); if (source == null) { MessageBox.Show(Settings.Localization.UnableToFindStation + ": " + name, Settings.Localization.StationNotFound, MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(source); }
/// <summary> /// Returns station object with given name. If not found, returns error message. /// </summary> /// <param name="name">Name of the station.</param> /// <returns>Station object.</returns> public static Structures.Basic.StationsBasic.StationBasic GetStationFromString(string name) { Structures.Basic.StationsBasic.StationBasic source = DataFeedClient.Basic.Stations.FindByName(name); if (source == null) { PlatformDependentSettings.ShowMessage(Settings.Localization.UnableToFindStation + ": " + name); } return(source); }
/// <summary> /// Tries to obtain station info and return window with results. /// </summary> /// <param name="stationName">Station name.</param> /// <param name="dt">Datetime.</param> /// <param name="count">Number of departures.</param> /// <param name="isStation">Indicates whether it is station or stop.</param> /// <param name="routeLabel">Route label.</param> /// <param name="win">Window with request.</param> /// <returns>Window with results.</returns> public static async Task <DepartureBoardResultsWindow> GetStationInfoWindowAsync(string stationName, DateTime dt, int count, bool isStation, string routeLabel, NewStationInfoWindow win) { Structures.Basic.StationsBasic.StationBasic station = GetStationFromString(stationName); Structures.Basic.RoutesInfoBasic.RouteInfoBasic route = GetRouteInfoFromLabel(routeLabel); if (station == null || (route == null && !string.IsNullOrWhiteSpace(routeLabel))) { return(null); } var dbRequest = new StationInfoRequest(station.ID, dt, count, isStation, route == null ? -1 : route.ID); var dbResponse = await SendDepartureBoardRequestAsync(dbRequest); return(dbResponse == null ? null : new DepartureBoardResultsWindow(dbResponse, station.Name, dt, true, win)); }
private void addButton_Click(object sender, System.EventArgs e) { Structures.Basic.StationsBasic.StationBasic station = Request.GetStationFromString(stationTextBox.Text); if (station == null || StationInfoCached.Select(station.ID) != null) { return; } var fav = new StationInfoCached(station.ID); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CacheDepartureBoardAsync(fav.ConstructNewRequest()); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed favoritesListBox.Items.Add(fav); favorites.Add(fav); }
private void addButton_Click(object sender, System.EventArgs e) { Structures.Basic.StationsBasic.StationBasic source = Request.GetStationFromString(sourceTextBox.Text); Structures.Basic.StationsBasic.StationBasic target = Request.GetStationFromString(targetTextBox.Text); if (source == null || target == null || JourneyCached.Select(source.ID, target.ID) != null) { return; } var fav = new JourneyCached(source.ID, target.ID); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CacheJourneyAsync(fav.ConstructNewRequest()); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed favoritesListBox.Items.Add(fav); favorites.Add(fav); }
/// <summary> /// Tries to obtain journeys and returns window with results. /// </summary> /// <param name="sourceName">Source station name.</param> /// <param name="targetName">Target station name.</param> /// <param name="dt">Datetime.</param> /// <param name="transfers">Max transfers.</param> /// <param name="count">Number of journeys.</param> /// <param name="coefficient">Coefficient for the footpaths.</param> /// <param name="mot">Mean of transport.</param> /// <param name="win">Window with request.</param> /// <param name="comp">Comparer for journeys.</param> /// <returns>Window with results</returns> public static async Task <JourneyResultsWindow> GetRouterWindowAsync(string sourceName, string targetName, DateTime dt, int transfers, int count, double coefficient, MeanOfTransport mot, NewJourneyWindow win, IComparer <Journey> comp = null) { Structures.Basic.StationsBasic.StationBasic source = GetStationFromString(sourceName); Structures.Basic.StationsBasic.StationBasic target = GetStationFromString(targetName); if (source == null || target == null) { return(null); } var routerRequest = new RouterRequest(source.ID, target.ID, dt, transfers, count, coefficient, mot); var routerResponse = await SendRouterRequestAsync(routerRequest); if (comp != null && routerResponse != null) { routerResponse.Journeys.Sort(comp); } return(routerResponse == null ? null : new JourneyResultsWindow(routerResponse, source.Name, target.Name, dt, win)); }
private async void FindButtonClicked(object sender, EventArgs e) { try { Structures.Basic.StationsBasic.StationBasic source = Request.GetStationFromString(sourceStopEntry.Text); Structures.Basic.StationsBasic.StationBasic target = Request.GetStationFromString(targetStopEntry.Text); if (source == null) { PlatformDependentSettings.ShowMessage(Settings.Localization.UnableToFindStation + ": " + sourceStopEntry.Text); return; } if (target == null) { PlatformDependentSettings.ShowMessage(Settings.Localization.UnableToFindStation + ": " + targetStopEntry.Text); return; } var routerRequest = new RouterRequest(source.ID, target.ID, leavingTimeDatePicker.Date.Add(leavingTimeTimePicker.Time), (int)transfersSlider.Value, (int)countSlider.Value, Settings.WalkingSpeedCoefficient, Settings.GetMoT()); findButton.IsEnabled = false; var routerResponse = await Request.SendRouterRequestAsync(routerRequest); findButton.IsEnabled = true; if (routerResponse != null) { await Navigation.PushAsync(new FindJourneyResultsPage(routerResponse, source.Name, target.Name), true); } } catch { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CheckBasicDataValidity(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } }
private async void FindButtonClicked(object sender, EventArgs e) { try { Structures.Basic.StationsBasic.StationBasic station = Request.GetStationFromString(stopEntry.Text); if (station == null) { return; } Structures.Basic.RoutesInfoBasic.RouteInfoBasic route = linePicker.SelectedItem == null ? null : Request.GetRouteInfoFromLabel(linePicker.SelectedItem.ToString()); if (route == null && linePicker.SelectedItem != null) { return; } var dbRequest = new StationInfoRequest(station.ID, leavingTimeDatePicker.Date.Add(leavingTimeTimePicker.Time), (int)countSlider.Value, true, route == null ? -1 : route.ID); findButton.IsEnabled = false; var dbResponse = await Request.SendDepartureBoardRequestAsync(dbRequest); findButton.IsEnabled = true; if (dbResponse != null) { await Navigation.PushAsync(new DepartureBoardResultsPage(dbResponse, true, station.Name), true); } } catch { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Request.CheckBasicDataValidity(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } }