// Saves entry form inputs into a new pin void SaveFormInfo() { tempCustomPin.MarkerID = pinID; tempCustomPin.Category = CategoryEntry; tempCustomPin.Label = TitleEntry; tempCustomPin.Description = DescriptionEntry; tempCustomPin.StartTime = StartTimeEntry; tempCustomPin.EndTime = EndTimeEntry; tempCustomPin.Address = new ImageService().CategoryToImage(CategoryEntry); CustomPinList.Add(tempCustomPin); PermanentCustomPinList.Add(tempCustomPin); pinID += 1; ResetAll(); }
// Reorders the quick view list based on the sort category selected public void UpdateQuickView(bool toggleMode = false) { List <CustomPin> tempList = PermanentCustomPinList.ToList(); List <CustomPin> sortedList = new List <CustomPin>(); // Sort-By feature if (toggleMode) { if (SortButtonText == "Sort By: Time") { SortButtonText = "Sort By: Distance"; } else if (SortButtonText == "Sort By: Distance") { SortButtonText = "Sort By: Time"; } } if (SortButtonText == "Sort By: Time") { sortedList = tempList.OrderBy(pin => Int32.Parse(pin.TimeRemaining.Replace("h ", "0").Replace("min left", ""))).ToList(); } else if (SortButtonText == "Sort By: Distance") { sortedList = tempList.OrderBy(pin => Int32.Parse(pin.DistanceFromUser.Replace("m", ""))).ToList(); } // Filter feature CustomPinList.Clear(); if (categoriesToShow == "all") { sortedList.ForEach((pin) => CustomPinList.Add(pin)); } else { foreach (CustomPin pin in sortedList) { if (pin.Category == categoriesToShow) { CustomPinList.Add(pin); } } } AddPinsToMap(); }
// Updates all pins' remaining time. If 0, remove from list public void UpdatePinTimeRemaining() { // Changing a property doesn't fire INotifyPropertyChange (dev bug), replacing pin does for (int i = 0; i < PermanentCustomPinList.Count; i++) { CustomPin pin = PermanentCustomPinList[i]; string timeLeft = new FormatService().FormatTimeRemainingToString(pin.EndTime, DateTime.Now.TimeOfDay); if (timeLeft == "expired") { PermanentCustomPinList.RemoveAt(i); } else { pin.TimeRemaining = timeLeft; PermanentCustomPinList[i] = pin; } } }
// Create fake pins from MockDataStore on the map async void CreateFakePins() { var mockPins = await DataStore.GetItemsAsync(true); foreach (var pin in mockPins) { // MockPin's position and end time is an random offset. Add to current for randomness double lat = pin.Position.Latitude + userPosition.Latitude; double lng = pin.Position.Longitude + userPosition.Longitude; pin.Position = new Position(lat, lng); pin.EndTime += DateTime.Now.TimeOfDay; pin.MarkerID = pinID; CustomPinList.Add(pin); PermanentCustomPinList.Add(pin); pinID += 1; } ResetAll(); }