コード例 #1
0
        public static Color Convert(RideInfo source)
        {
            if (source == null)
            {
                return(Color.Gray);
            }

            var battery = source.BatteryLevel;

            if (source.Time.IsLate())
            {
                return(Color.Gray);
            }

            if (battery.RangeBetteryLevel() == BetteryLevel.Low)
            {
                return(Color.Red);
            }
            if (battery.RangeBetteryLevel() == BetteryLevel.Medium)
            {
                return(Color.Orange);
            }

            return(Color.Black);
        }
コード例 #2
0
ファイル: ActiveRideCenter.cs プロジェクト: hoomanali/TagRide
        public static async Task <string> ActiveRideStarted(
            RideInfo rideInfo,
            UserRideOffer driver,
            IEnumerable <UserRideRequest> riders)
        {
            ActiveRideStatus status =
                new ActiveRideStatus
            {
                Id          = IdGenerator.GenerateNewId(rideInfo),
                Version     = 0,
                RideInfo    = rideInfo,
                RideState   = ActiveRideStatus.State.InProgress,
                RidersState = new ConcurrentDictionary <string, ActiveRideStatus.RiderState>(
                    riders.Select(
                        (r) => new KeyValuePair <string, ActiveRideStatus.RiderState>(
                            r.User.UserInfo.UserId,
                            ActiveRideStatus.RiderState.Waiting))),
                RidersGameElements = new ConcurrentDictionary <string, RequestGameElements>(
                    riders
                    .Where((r) => r.RideRequest.GameElements != null)
                    .Select((r) => new KeyValuePair <string, RequestGameElements>(
                                r.User.UserInfo.UserId,
                                r.RideRequest.GameElements))),
                DriverGameElements = driver.RideOffer.GameElements
            };

            Task postTask = Program.DataStore.PostActiveRideStatus(status);

            activeRides.TryAdd(status.Id, status);
            await postTask;

            RideStarted?.Invoke(status);

            return(status.Id);
        }
コード例 #3
0
        public void RideInfoView(RideInfo rideInfo)
        {
            if (!SetState(ViewState.RideInfo))
            {
                return;
            }

            homeSearchBarLocationCallback = null;
            homeLongPressCallback         = null;
            locationSelectedCallback      = null;

            Map.HasZoomEnabled   = false;
            Map.HasScrollEnabled = false;
            Map.IsShowingUser    = true;

            searchBar.IsVisible              = false;
            confirmButton.IsVisible          = false;
            rideInProgressControls.IsVisible = false;

            IEnumerable <Position> route = rideInfo.Route.Stops.Select((s) => s.Location.ToTKPosition());

            Map.Polylines = new TK.CustomMap.Overlays.TKPolyline[]
            {
                new TK.CustomMap.Overlays.TKPolyline
                {
                    LineCoordinates = route.ToList(),
                    LineWidth       = 5,
                    Color           = Color.Blue
                }
            };

            Map.FitMapRegionToPositions(route, true, 20);
        }
コード例 #4
0
ファイル: DatabaseAccess.cs プロジェクト: bikedataproject/app
 public Task <int> SaveRideInfoAsync(RideInfo rideInfo)
 {
     if (rideInfo.ID != 0)
     {
         return(Database.UpdateAsync(rideInfo));
     }
     else
     {
         return(Database.InsertAsync(rideInfo));
     }
 }
コード例 #5
0
        public void RideInProgressView(RideInfo rideInfo, Action finishCallback, Action cancelCallback)
        {
            if (!SetState(ViewState.RideInProgress))
            {
                return;
            }

            rideFinishCallback = finishCallback;
            rideCancelCallback = cancelCallback;

            homeSearchBarLocationCallback = null;
            homeLongPressCallback         = null;
            locationSelectedCallback      = null;

            Map.HasZoomEnabled   = false;
            Map.HasScrollEnabled = false;
            Map.IsShowingUser    = true;

            searchBar.IsVisible              = false;
            confirmButton.IsVisible          = false;
            rideInProgressControls.IsVisible = true;

            var route = rideInfo.Route.Stops.Select((s) => s.Location.ToTKPosition());

            Map.Polylines = new TK.CustomMap.Overlays.TKPolyline[]
            {
                new TK.CustomMap.Overlays.TKPolyline
                {
                    LineCoordinates = route.ToList(),
                    LineWidth       = 5,
                    Color           = Color.Blue
                }
            };

            try
            {
                Map.FitMapRegionToPositions(route, true, 20);
            }
            catch (InvalidOperationException)
            {
                Map.MapReady += (a, b) =>
                                Map.FitMapRegionToPositions(route, true, 20);
            }
        }
コード例 #6
0
ファイル: PendingRide.cs プロジェクト: hoomanali/TagRide
        /// <summary>
        /// Create a new <see cref="PendingRide"/>
        /// </summary>
        /// <param name="rideInfo">The original ride info of this ride</param>
        /// <param name="offer">The ride offer of this pending ride</param>
        /// <param name="requests">All the ride requests apart of this pending ride</param>
        /// <param name="rideMatcher">Used to create a new route if anything changes durring the confirmation phase</param>
        /// <param name="driverExpireTime">Time in milliseconds the driver has to confirm</param>
        /// <param name="riderExpireTime">Time in milliseconds the riders have to confirm, after the driver confirms</param>
        public PendingRide(RideInfo rideInfo,
                           UserRideOffer offer,
                           ICollection <UserRideRequest> requests,
                           IRideMatcher rideMatcher,
                           double driverExpireTime = 120000,
                           double riderExpireTime  = 120000)
        {
            RideInfo = rideInfo;
            Id       = IdGenerator.GenerateNewId(this);

            this.offer       = offer;
            this.requests    = requests;
            this.rideMatcher = rideMatcher;

            userToUserRequest.TryAdd(offer.User, offer);
            foreach (UserRideRequest rr in requests)
            {
                userToUserRequest.TryAdd(rr.User, rr);
            }

            driverTimer = new Timer
            {
                AutoReset = false,
                Interval  = driverExpireTime,
                Enabled   = false
            };
            riderTimer = new Timer
            {
                AutoReset = false,
                Interval  = riderExpireTime,
                Enabled   = false
            };

            driverTimer.Elapsed += (a, b) =>
            {
                offer.SetExpired();
                Cancel();
                UserTimedOut?.Invoke(offer.User.UserInfo.UserId, true, this);
            };
            riderTimer.Elapsed += async(a, b) => await DoneGettingConfirmations();
        }