예제 #1
0
        private void Border_Tapped(object sender, TappedRoutedEventArgs e)
        {
            BitmapIcon border = sender as BitmapIcon;
            TrainStop  stop   = border.DataContext as TrainStop;

            if (!Frame.Navigate(typeof(SectionPage), stop.Id))
            {
            }
        }
예제 #2
0
    public void PutStop(Vector2Int trackpos)
    {
        Track t   = tracks[trackpos];
        var   pos = new Vector3(trackpos.x, 0, trackpos.y);

        var       baseRot = Quaternion.LookRotation(new Vector3(t.next.x, 0, t.next.y));
        TrainStop stop    = Instantiate(woodCutterPrefab, pos, baseRot, this.transform);

        stops.Add(trackpos, stop);
    }
예제 #3
0
        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem item = sender as MenuFlyoutItem;

            if (item != null)
            {
                TrainStop stazione = item.DataContext as TrainStop;
                Settings.removeFavs(stazione.Id);
            }
        }
예제 #4
0
 private int searchByName(string query)
 {
     try
     {
         TrainStop stazione = treni.Single(x => x.Name.Equals(query, StringComparison.OrdinalIgnoreCase));
         return(stazione.Id);
     } catch (InvalidOperationException ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
         return(0);
     }
 }
예제 #5
0
        public void Edit(TrainStop trainStop)
        {
            var ts = _context.TrainStops.Find(trainStop.Id);

            if (ts != null)
            {
                ts.City = trainStop.City;
                ts.Name = trainStop.Name;

                _context.TrainStops.Update(ts);
                _context.SaveChanges();
            }
        }
예제 #6
0
        private async void NearestStop()
        {
            nearestStopId          = 0;
            ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
            testoControllo.Text    = "Sto ottenendo la posizione...";
            try
            {
                Geoposition geoposition = await Settings.getPosition();

                Geopoint punto = new Geopoint(new BasicGeoposition()
                {
                    Latitude  = geoposition.Coordinate.Point.Position.Latitude,
                    Longitude = geoposition.Coordinate.Point.Position.Longitude
                });
                testoControllo.Text = "Sto cercando la stazione più vicina...";
                TrainStop nearest = Settings.nearestStop(punto, await DBSource.Stations);
                nearestStopId        = nearest.Id;
                testoControllo.Text  = nearest.Name;
                listView.ItemsSource = await DBSource.getPartenze(nearest.Id, DateTime.Now, false, 7);

                positionNotFound       = false;
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            } catch (DisabledPositionException ex) {
                testoControllo.Text    = ex.Message;
                positionNotFound       = true;
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            catch (PositionNotFoundException ex)
            {
                testoControllo.Text    = ex.Message;
                positionNotFound       = true;
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            catch (ArgumentOutOfRangeException)
            {
                testoControllo.Text    = "Errore. Non ci sono dati.";
                positionNotFound       = false;
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            catch (System.UnauthorizedAccessException)
            {
                testoControllo.Text    = "Posizione non disponibile.";
                positionNotFound       = true;
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            if (refresh != null)
            {
                refresh.IsEnabled = true;
            }
            System.Diagnostics.Debug.WriteLine(positionNotFound);
        }
예제 #7
0
        /// <summary>
        /// Popola la pagina con il contenuto passato durante la navigazione.  Vengono inoltre forniti eventuali stati
        /// salvati durante la nuova creazione di una pagina in una sessione precedente.
        /// </summary>
        /// <param name="sender">
        /// Origine dell'evento. In genere <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Dati evento che forniscono il parametro di navigazione passato a
        /// <see cref="Frame.Navigate(Type, Object)"/> quando la pagina è stata inizialmente richiesta e
        /// un dizionario di stato mantenuto da questa pagina nel corso di una sessione
        /// precedente.  Lo stato è null la prima volta che viene visitata una pagina.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: creare un modello dati appropriato per il DOMINIO problematico per sostituire i dati di esempio.
            //var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter);
            //this.DefaultViewModel["Group"] = group;
            //MessageDialog msg = new MessageDialog(e.NavigationParameter.ToString());
            //await msg.ShowAsync();
            int stopId = (int)e.NavigationParameter;

            trainStop = await DBSource.getStop(stopId);

            ToggleAppBarButton(!SecondaryTile.Exists(AppbarTileId));
            updateFavButton(!Settings.inFavs(trainStop.Id));
            Titolo.Text = trainStop.Name;
            getPartenze((bool)Settings.ShowAll);
            if (Settings.Spot)
            {
                Ad.Visibility = Windows.UI.Xaml.Visibility.Visible;
                UpdateLayout();
            }
        }
예제 #8
0
 public ActionResult <Train> Edit(TrainStop trainStop)
 {
     _trainStopService.Edit(trainStop);
     return(Ok());
 }
예제 #9
0
        public ActionResult <TrainStop> Create(TrainStop trainStop)
        {
            var ts = _trainStopService.Create(trainStop);

            return(Ok(ts));
        }
예제 #10
0
        private void prepareListViewStationTimetable(Timetable timetable, String stationName)
        {
            listViewStationTimetable.BeginUpdate();
            listViewStationTimetable.Items.Clear();

            // determine trainStation
            TrainStation station = TrainStationCache.getInstance().getCacheContentOnName(stationName);
            // find all lines passing this station
            List <TrainLineVariable> lines = findTrainLinesVariable(station.getTrainLines(), timetable);

            foreach (TrainLineVariable line in lines)
            {
                TrainStop stop = line.Line.getTrainStopOnStation(station.Name);

                Time arrival   = stop.TimeArrival;
                Time departure = stop.TimeDeparture;

                int m = (END_TIME_OF_ST - START_TIME_OF_ST).ToMinutes();
                // loop until we are still in interval -> max M
                for (int i = 0; i *(int)line.Period < m; i++)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = line.LineNumber.ToString();
                    lvi.Tag  = line.LineNumber.ToString();

                    // if areival is not equal 00:00
                    if (!arrival.Equals(Time.MinValue))
                    {
                        // start time of timetable + arrival on station + period time solutionFactor
                        lvi.SubItems.Add((START_TIME_OF_ST + arrival + line.StartTime + Time.ToTime(i * (int)line.Period)).ToString());
                    }
                    // otherwise
                    else
                    {
                        // if stop is the first, there no arrival exists
                        if (stop.OrderInTrainLine.Equals(0))
                        {
                            lvi.SubItems.Add("");
                        }
                        // otherwise (time is 00:00 but the stop is not first) use departure
                        else
                        {
                            lvi.SubItems.Add((START_TIME_OF_ST + departure + line.StartTime + Time.ToTime(i * (int)line.Period)).ToString());
                        }
                    }

                    // if departure is not equal 00:00
                    if (!departure.Equals(Time.MinValue))
                    {
                        lvi.SubItems.Add((START_TIME_OF_ST + departure + line.StartTime + Time.ToTime(i * (int)line.Period)).ToString());
                    }
                    // otherwise
                    else
                    {
                        // if stop is a first one, there it is a legal time, use it
                        if (stop.OrderInTrainLine.Equals(0))
                        {
                            lvi.SubItems.Add((START_TIME_OF_ST + Time.MinValue + line.StartTime + Time.ToTime(i * (int)line.Period)).ToString());
                        }
                        // otherwise (time is 00:00 but the stop is not first)
                        else
                        {
                            // it has to be last stop, which has no departure (not continue)
                            lvi.SubItems.Add("");
                        }
                    }

                    listViewStationTimetable.Items.Add(lvi);
                }
            }



            listViewStationTimetable.EndUpdate();
        }
예제 #11
0
 public void Delete(TrainStop trainStop)
 {
     _context.TrainStops.Remove(trainStop);
     _context.SaveChanges();
 }
예제 #12
0
 public TrainStop Create(TrainStop trainStop)
 {
     _context.TrainStops.Add(trainStop);
     _context.SaveChanges();
     return(trainStop);
 }