Ejemplo n.º 1
0
        /// <summary>
        /// Returns route info object with given name. If not found, returns error message within MessageBox.
        /// </summary>
        /// <param name="label">Route label.</param>
        /// <returns>Route info object.</returns>
        public static Structures.Basic.RoutesInfoBasic.RouteInfoBasic GetRouteInfoFromLabel(string label)
        {
            if (string.IsNullOrEmpty(label))
            {
                return(null);
            }

            Structures.Basic.RoutesInfoBasic.RouteInfoBasic route = DataFeedDesktop.Basic.RoutesInfo.FindByLabel(label);

            if (route == null)
            {
                MessageBox.Show(Settings.Localization.UnableToFindRouteInfo + ": " + label, Settings.Localization.RouteInfoNotFound, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(route);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns route info object with given name. If not found, returns error message.
        /// </summary>
        /// <param name="label">Route label.</param>
        /// <returns>Route info object.</returns>
        public static Structures.Basic.RoutesInfoBasic.RouteInfoBasic GetRouteInfoFromLabel(string label)
        {
            if (string.IsNullOrEmpty(label))
            {
                return(null);
            }

            Structures.Basic.RoutesInfoBasic.RouteInfoBasic route = DataFeedClient.Basic.RoutesInfo.FindByLabel(label);

            if (route == null)
            {
                PlatformDependentSettings.ShowMessage(Settings.Localization.UnableToFindRouteInfo + ": " + label);
            }

            return(route);
        }
Ejemplo n.º 3
0
        private void addButton_Click(object sender, System.EventArgs e)
        {
            Structures.Basic.RoutesInfoBasic.RouteInfoBasic route = Request.GetRouteInfoFromLabel(lineTextBox.Text);

            if (route == null || LineInfoCached.Select(route.ID) != null)
            {
                return;
            }

            var fav = new LineInfoCached(route.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 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
            }
        }