Beispiel #1
0
 private void buttonDeleteTime_Click(object sender, EventArgs e)
 {
     if (gridViewTimes.FocusedRowHandle >= 0)
     {
         BusDeparture busTime = (BusDeparture)gridViewTimes.GetFocusedRow();
         bindingSourceTimes.Remove(busTime);
         _context.BusDeparture.DeleteObject(busTime);
         BindTimes();
         _modified = true;
     }
 }
Beispiel #2
0
            private async Task <BusDeparture[]> GetStopDepartures(BusStop stop)
            {
                var client     = new HttpClient();
                var jsonString = await client.GetStringAsync(_baseURL + stop.StopId.ToString() + "?format=json");

                var departures = BusDeparture.FromJson(jsonString);

                for (int i = 0; i < departures.Length; i++)
                {
                    departures[i].BusStop = stop;
                }
                return(departures);
            }
Beispiel #3
0
            public RGBWColor GetColorForDeparture(BusDeparture departure)
            {
                var stop     = departure.BusStop;
                var timeleft = departure.DepartureTime - DateTime.Now;
                var s        = Services.Theme.GetColorStyle(true);

                // TODO: Display something for 'not actual'
                // TODO: Display countdown thing
                // TODO: Goodness as floating point value

                var extraTime = timeleft - stop.WalkTime;

                if (extraTime < TimeSpan.Zero)
                {
                    return(new RGBWColor(0, 0, 0, 0));
                }
                else if (extraTime < TimeSpan.FromMinutes(1))
                {
                    return(s.BadColor);
                }
                else if (extraTime < TimeSpan.FromMinutes(2))
                {
                    return(s.MidColor);
                }
                else if (extraTime < TimeSpan.FromMinutes(4))
                {
                    return(s.BestColor);
                }
                else if (extraTime < TimeSpan.FromMinutes(7))
                {
                    return(s.GoodColor);
                }
                else if (extraTime < TimeSpan.FromMinutes(15))
                {
                    return(s.GoodColor * 0.5);
                }

                return(s.BadColor);
            }