public void updateFavourite()
        {
            var value = IsFavourite;

            if (value)
            {
                bool exists = false;
                for (int i = 0; i < Favourites.Count; i++)
                {
                    if (CurrentCityId == Favourites.ElementAt(i).Id)
                    {
                        exists = true;
                    }
                }
                if (!exists)
                {
                    Favourites.Add(new City(CurrentCityName, CurrentCityId));
                    SaveFavourites();
                }
            }
            else
            {
                for (int i = 0; i < Favourites.Count; i++)
                {
                    if (CurrentCityId == Favourites.ElementAt(i).Id)
                    {
                        Favourites.Remove(Favourites.ElementAt(i));
                        SaveFavourites();
                        break;
                    }
                }
            }
        }
Example #2
0
        private async Task RemoveFavouriteAsync(FavouriteDomain favourite)
        {
            if (await ApplicationService.DisplayAlertAsync("", $"Премахване на {favourite.Name}?", "Да", "Не"))
            {
                await FavouriteDomain.RemoveAsync(favourite.StopCode);

                Favourites.Remove(favourite);

                ApplicationService.DisplayToast($"{favourite.Name} е премахната");
                RaisePropertyChanged("HasFavourites");
            }
        }
Example #3
0
        /// <summary>
        /// Toggles the favourited state of the given property.
        /// </summary>
        public void SetPropertyFavourited(Property property, bool isFavourited)
        {
            if (!isFavourited && IsPropertyFavourited(property))
            {
                var matchingProperty = Favourites.Single(p => p.Guid == property.Guid);
                Favourites.Remove(matchingProperty);
            }
            else if (isFavourited && !IsPropertyFavourited(property))
            {
                Favourites.Add(property);
            }

            PersistState();
        }
Example #4
0
        /// <summary>
        /// Toggles the favourited state of the given property.
        /// </summary>
        public void ToggleFavourite(Property property)
        {
            if (IsPropertyFavourited(property))
            {
                var matchingProperty = Favourites.Single(p => p.Guid == property.Guid);
                Favourites.Remove(matchingProperty);
            }
            else
            {
                Favourites.Add(property);
            }

            PersistState();
        }
Example #5
0
        public bool RemoveArticle()
        {
            bool result = false;

            if (_currentFeedItem != null)
            {
                int hash = _currentFeedItem.HashCode;
                if (Favourites.Contains(_currentFeedItem.HashCode))
                {
                    Favourites.Remove(hash);
                    result   = _currentFeedItem.RemoveFromFavourites();
                    MainFeed = MetaTag + FavouriteArticles;
                }
            }
            return(result);
        }
 private void favourite_Unchecked(object sender, RoutedEventArgs e)
 {
     this.favouriteYES.Visibility = Visibility.Hidden;
     this.favouriteNO.Visibility  = Visibility.Visible;
     this.favouriteNO.Visibility  = Visibility.Visible;
     for (int i = 0; i < Favourites.Count; i++)
     {
         if (product.city.id == Favourites.ElementAt(i).id)
         {
             Favourites.Remove(Favourites.ElementAt(i));
             favWin.listView.Items.Remove(product.city.name + "," + product.city.country);
             SaveFavourites();
             break;
         }
     }
 }
        /// <summary>
        /// Removes one or more favourites from the user's current list.
        /// </summary>
        /// <param name="names">A list of the names of all favourites to remove</param>
        public static void RemoveFavourites(List <string> names)
        {
            if (names == null)
            {
                logBox.Text = "Error removing favourites.";
                return;
            }
            foreach (string name in names)
            {
                if (Favourites.ContainsKey(name))
                {
                    Favourites.Remove(name);
                }
            }

            foreach (TabUserControl tab in AllTabs)
            {
                tab.RefreshFavouritesBox();
            }

            try
            {
                using (StreamWriter sw = new StreamWriter(savedPagesFileName))
                {
                    sw.WriteLine("h," + homeUrl); //Save homepage

                    foreach (KeyValuePair <string, string> favourite in Favourites)
                    {
                        sw.WriteLine("f," + favourite.Key + "," + favourite.Value);
                    }
                }
            }catch (IOException ioe)
            {
                logBox.Text = "Error removing favourites from saved data.";
            }
            catch (Exception e)
            {
                logBox.Text = "Unexpected error removing favourites." + e.Message;
            }
        }
Example #8
0
 internal void RemoveFavourite(IValueTag valueTag) => Favourites.Remove(valueTag);
Example #9
0
 public void RemoveFavourite(Favourite favourite)
 {
     Favourites.Remove(favourite);
 }