Esempio n. 1
0
        private static TooltipData CreateToolTip(StopData arrivalData)
        {
            TooltipData tipData = new TooltipData {
                Icon = ToolTipIcon.Info
            };

            if (arrivalData.Routes.Count == 0) {
                tipData.Title = "No Routes";
                return tipData;
            }

            RouteData routeData = arrivalData.Routes.First();
            tipData.Title = "Route: " + routeData.RouteId + " - " + routeData.DestinationName;

            StringBuilder tip = new StringBuilder();

            if (routeData.Trips.Count == 0) {
                tip.AppendLine("No Trips");
                return tipData;
            }

            foreach (TripData trip in routeData.Trips) {
                tip.AppendLine("ETA: " + trip.ETA.TotalMinutes + " m.");
            }

            tip.AppendLine("Updated at: " + DateTime.Now.ToString("HH:mm:ss"));

            tipData.Content = tip.ToString();
            return tipData;
        }
Esempio n. 2
0
        private static TooltipData CreateToolTip(StopData arrivalData)
        {
            TooltipData tipData = new TooltipData {
                Icon = ToolTipIcon.Info
            };

            if (arrivalData.Routes.Count == 0)
            {
                tipData.Title = "No Routes";
                return(tipData);
            }

            RouteData routeData = arrivalData.Routes.First();

            tipData.Title = "Route: " + routeData.RouteId + " - " + routeData.DestinationName;

            StringBuilder tip = new StringBuilder();

            if (routeData.Trips.Count == 0)
            {
                tip.AppendLine("No Trips");
                return(tipData);
            }

            foreach (TripData trip in routeData.Trips)
            {
                tip.AppendLine("ETA: " + trip.ETA.TotalMinutes + " m.");
            }

            tip.AppendLine("Updated at: " + DateTime.Now.ToString("HH:mm:ss"));

            tipData.Content = tip.ToString();
            return(tipData);
        }
Esempio n. 3
0
        private void RequestUpdate()
        {
            TooltipData data = new TooltipData();
            StopData    eta  = null;

            try {
                eta = _backend.RequestDataForStopAndRouteNumber(ConfigSettings.Default.StopNumber,
                                                                ConfigSettings.Default.RouteNumber);
                data = CreateToolTip(eta);
            } catch (Exception e) {
                data.Icon    = ToolTipIcon.Error;
                data.Title   = "Error Loading";
                data.Content = e.Message;
            }

            _notify.BalloonTipIcon  = data.Icon;
            _notify.BalloonTipTitle = data.Title;
            _notify.BalloonTipText  = data.Content;

            if (eta != null && eta.Routes.Count > 0)
            {
                RouteData routeData = eta.Routes.First();
                if (routeData.Trips.Count > 0)
                {
                    TripData nextTrip = routeData.Trips.OrderBy(z => z.ETA).FirstOrDefault();
                    if (nextTrip != null)
                    {
                        if (ConfigSettings.Default.EnableAlerts &&
                            (DateTime.Now.TimeOfDay >= TimeSpan.FromSeconds(ConfigSettings.Default.AlertStart)) &&
                            (DateTime.Now.TimeOfDay <= TimeSpan.FromSeconds(ConfigSettings.Default.AlertEnd)) &&
                            nextTrip.ETA.TotalMinutes <= ConfigSettings.Default.AlertWhenETA &&
                            nextTrip.ETA != _lastETA)
                        {
                            _notify.ShowBalloonTip(10);
                            _lastETA = nextTrip.ETA;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private void RequestUpdate()
        {
            TooltipData data = new TooltipData();
            StopData eta = null;

            try {
                eta = _backend.RequestDataForStopAndRouteNumber(ConfigSettings.Default.StopNumber,
                                                                ConfigSettings.Default.RouteNumber);
                data = CreateToolTip(eta);
            } catch (Exception e) {
                data.Icon = ToolTipIcon.Error;
                data.Title = "Error Loading";
                data.Content = e.Message;
            }

            _notify.BalloonTipIcon = data.Icon;
            _notify.BalloonTipTitle = data.Title;
            _notify.BalloonTipText = data.Content;

            if (eta != null && eta.Routes.Count > 0) {
                RouteData routeData = eta.Routes.First();
                if (routeData.Trips.Count > 0) {
                    TripData nextTrip = routeData.Trips.OrderBy(z => z.ETA).FirstOrDefault();
                    if (nextTrip != null) {
                        if (ConfigSettings.Default.EnableAlerts &&
                            (DateTime.Now.TimeOfDay >= TimeSpan.FromSeconds(ConfigSettings.Default.AlertStart)) &&
                            (DateTime.Now.TimeOfDay <= TimeSpan.FromSeconds(ConfigSettings.Default.AlertEnd)) &&
                            nextTrip.ETA.TotalMinutes <= ConfigSettings.Default.AlertWhenETA &&
                            nextTrip.ETA != _lastETA) {
                            _notify.ShowBalloonTip(10);
                            _lastETA = nextTrip.ETA;
                        }
                    }
                }
            }
        }