Esempio n. 1
0
        private void favourite_Checked(object sender, RoutedEventArgs e)
        {
            this.favouriteNO.Visibility  = Visibility.Hidden;
            this.favouriteYES.Visibility = Visibility.Visible;

            if (product.city == null)
            {
                this.favouriteNO.Visibility  = Visibility.Visible;
                this.favouriteYES.Visibility = Visibility.Hidden;
                return;
            }
            bool exists = false;

            for (int i = 0; i < Favourites.Count; i++)
            {
                if (product.city.id == Favourites.ElementAt(i).id)
                {
                    exists = true;
                }
            }
            if (!exists)
            {
                Favourites.Add(new City(product.city.id, product.city.name, product.city.coord, product.city.country, product.city.population));
                favWin.listView.Items.Add(product.city.name + "," + product.city.country);
                SaveFavourites();
            }
        }
Esempio n. 2
0
 private void checkBox_Click(object sender, RoutedEventArgs e)
 {
     City = this.CityText.Text;
     if (checkBox.IsChecked == true)
     {
         if (loadedData.cityExists(City) == true)
         {
             if (PomocniFavourites.Contains(City.ToUpper()) == false)
             {
                 Favourites.Add(City);
                 PomocniFavourites.Add(City.ToUpper());
                 if (Favourites.Count() == 6)
                 {
                     Favourites.RemoveAt(0);
                     PomocniFavourites.RemoveAt(0);
                 }
                 this.errorMessage.Content = "";
             }
             else
             {
                 this.errorMessage.Content = "City is already added to favourites.";
             }
         }
         else
         {
             this.errorMessage.Content = "City couldn't be added to favourites. Please check the spelling and internet connection.";
         }
     }
     else
     {
         this.errorMessage.Content = "";
     }
     WriteFavorites();
 }
Esempio n. 3
0
 public RacePreviewModel(Race race, Track track, List <Trait> traits, List <Strategy> strategies, List <SeasonTeam> favourites)
 {
     Race  = race;
     Track = track;
     if (traits != null)
     {
         foreach (var trait in traits)
         {
             TrackTraits.Add(trait);
         }
     }
     if (strategies != null)
     {
         foreach (var strat in strategies)
         {
             Strategies.Add(strat);
         }
     }
     if (favourites != null)
     {
         foreach (var team in favourites)
         {
             Favourites.Add(team);
         }
     }
 }
Esempio n. 4
0
        public void ReadFavourites()
        {
            string currentDirectory = Directory.GetCurrentDirectory();
            string path             = System.IO.Path.Combine(currentDirectory, "Favourites.txt");

            if (!File.Exists(path))
            {
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.Close();
                }
            }
            try
            {
                using (StreamReader sr = File.OpenText(path))
                {
                    string s = "";
                    while ((s = sr.ReadLine()) != null)
                    {
                        Favourites.Add(s);
                        PomocniFavourites.Add(s.ToUpper());
                    }
                }
            }
            catch (FileNotFoundException fnf)
            {
                Console.WriteLine(fnf.ToString());
            }
        }
Esempio n. 5
0
 public void AddFavouriteMonster(Monster monster)
 {
     Favourites.Add(new CustomerFavourite()
     {
         MonsterId = monster.Id, CustomerId = CustomerId, Monster = monster, Customer = this
     });
 }
        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;
                    }
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Adds a url to the user's saved favourites list.
 /// Will not work if name entered is a duplicate.
 /// </summary>
 /// <param name="name">The name to be associated with this favourite</param>
 /// <param name="url">THe url to be favourited</param>
 public static void AddFavourite(String name, String url)
 {
     if (!Favourites.ContainsKey(name))
     {
         try
         {
             using (StreamWriter sw = File.AppendText(savedPagesFileName))
             {
                 sw.WriteLine("f," + name + "," + url);
             }
             logBox.Text = "Favourite added with name: " + name;
             //Add favourite within program before writing to file. Ensures user doesn't see update in program but changes are not saved.
             Favourites.Add(name, url);
             foreach (TabUserControl tab in AllTabs)
             {
                 tab.RefreshFavouritesBox();
             }
         }
         catch (IOException ioe)
         {
             logBox.Text = "Failed to add favourite, error saving data.";
         }
         catch (Exception e)
         {
             logBox.Text = "Failed to add favourite, unknown error." + e.Message;;
         }
     }
     else
     {
         logBox.Text = "You tried to add a favourite with a duplicate name. Favourite not added. Name: " + name;
     }
 }
Esempio n. 8
0
        public string SaveArticle()
        {
            var result = Serializator.BinarySerialize(_currentFeedItem);

            if (!Favourites.Contains(_currentFeedItem.HashCode))
            {
                Favourites.Add(_currentFeedItem.HashCode, _currentFeedItem);
            }
            // Categories[CategoryType.Favourites.ToString()].(_currentFeedItem);
            return(result);
        }
Esempio n. 9
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();
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        /// <summary>
        /// Loads the user's favourites from a file if there is one.
        /// </summary>
        private void LoadFavourites()
        {
            if (File.Exists(savedPagesFileName))                               //Check if the file where home page is stored exists
            {
                using (StreamReader sr = new StreamReader(savedPagesFileName)) //Read through the file of saved pages
                {
                    string line = "";

                    while ((line = sr.ReadLine()) != null)
                    {
                        String[] parts = line.Split(',');
                        if (parts.Length == 3 && parts[0].Equals("f")) //If a saved favourite
                        {
                            if (!Favourites.ContainsKey(parts[1]))
                            {
                                Favourites.Add(parts[1], parts[2]);
                            }
                        }
                    }
                    RefreshFavouritesBox();
                }
            }
        }
Esempio n. 12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            favourites = new Favourites((IMainWindow)this);
            uiFavouritesListView.ItemsSource = favourites.Servers;

            if (Config.Settings.ServerBrowserFavourites != null)
            {
                foreach (String s in Config.Settings.ServerBrowserFavourites)
                {
                    favourites.Add(s);
                }
            }

            uiOptionsStartListenServerCheckBox.IsChecked = Config.Settings.ServerBrowserStartListenServer;
            uiOptionsCloseWhenFinishedCheckBox.IsChecked = Config.Settings.ServerBrowserCloseWhenFinished;
            WindowState = Config.Settings.ServerBrowserWindowState;
        }
Esempio n. 13
0
 internal void AddFavourite(IValueTag valueTag) => Favourites.Add(valueTag);
Esempio n. 14
0
 public void AddFavourite(Favourite favourite)
 {
     Favourites.Add(favourite);
 }