コード例 #1
0
ファイル: StationUtils.cs プロジェクト: SpiderMaster/BikeNow
        public static IList<Station> ParseStations(Stream stream)
        {
            using (var reader = new BinaryReader (stream, System.Text.Encoding.UTF8, true)) {
                var count = reader.ReadInt32 ();
                var stations = new Station[count];
                for (int i = 0; i < count; i++) {
                    stations [i] = new Station {
                        Id = reader.ReadInt32 (),
                        Street = reader.ReadString (),
                        Name = reader.ReadString(),
                        StationType = reader.ReadInt32(),
                        b = reader.ReadBoolean(),
                        su = reader.ReadBoolean(),
                        t = reader.ReadBoolean(),
                        bk = reader.ReadBoolean(),
                        bl = reader.ReadBoolean(),
                        Latitude = reader.ReadDouble(),
                        Longitude = reader.ReadDouble(),
                        EmptySlotCount = reader.ReadInt32(),
                        dx = reader.ReadInt32(),
                        BikeCount = reader.ReadInt32(),
                        bx = reader.ReadInt32()
                    };
                }

                return stations;
            }
        }
コード例 #2
0
 public static StationCardFragment WithStation(Station station, GeoPoint currentLocation, BikeActionStatus status)
 {
     var r = new StationCardFragment ();
     r.station = station;
     r.currentLocation = currentLocation;
     r.status = status;
     return r;
 }
コード例 #3
0
        async Task SetMapStationPins(Station[] stations, float alpha = 1)
        {
            var stationsToUpdate = stations.Where(station =>
                {
                    Marker marker;
                    var stats = station.BikeCount + "|" + station.EmptySlotCount;
                    if (existingMarkers.TryGetValue(station.Id, out marker))
                    {
                        if (marker.Snippet == stats && !showedStale)
                            return false;
                        marker.Remove();
                    }
                    return true;
                }).ToArray();

            var pins = await Task.Run(() => stationsToUpdate.ToDictionary(station => station.Id, station =>
                    {
                        var w = 24.ToPixels();
                        var h = 40.ToPixels();
                        if (station.Locked)
                            return pinFactory.GetClosedPin(w, h);
                        else if (!station.Installed)
                            return pinFactory.GetNonInstalledPin(w, h);
                        var ratio = (float)TruncateDigit(station.BikeCount / ((float)station.Capacity), 2);
                        return pinFactory.GetPin(ratio,
                            station.BikeCount,
                            w, h,
                            alpha: alpha);
                    }));

            foreach (var station in stationsToUpdate)
            {
                var pin = pins[station.Id];

                var snippet = station.BikeCount + "|" + station.EmptySlotCount;
                if (station.Locked)
                    snippet = string.Empty;
                else if (!station.Installed)
                    snippet = "not_installed";

                var markerOptions = new MarkerOptions()
          .SetTitle(station.Id + "|" + station.Street + "|" + station.Name)
          .SetSnippet(snippet)
          .SetPosition(new Android.Gms.Maps.Model.LatLng(station.Location.Lat, station.Location.Lon))
          .SetIcon(BitmapDescriptorFactory.FromBitmap(pin));
                existingMarkers[station.Id] = map.AddMarker(markerOptions);
            }
        }
コード例 #4
0
ファイル: Station.cs プロジェクト: SpiderMaster/BikeNow
 public bool Equals(Station other)
 {
     return other.Id == Id;
 }
コード例 #5
0
ファイル: Station.cs プロジェクト: Sumit2668/BikeNow
 public bool Equals(Station other)
 {
     return(other.Id == Id);
 }