//Gets the name of each favorite in the favorites bar and fill the LabelControl tab with it //Non used favorites in the tab are set to invisible private void SetFavoritesBar() { string[] parsedFavsBar = ManageFavorites.GetFavoritesBar(); LabelControl[] tabFavsBar = new LabelControl[] { fav1, fav2, fav3, fav4, fav5, fav6, fav7, fav8, fav9, fav10 }; int i = 0; while (i < parsedFavsBar.Length / 2) { if (i != parsedFavsBar.Length / 2 - 1) { tabFavsBar[i].Text = MakeFavoriteNameFit(parsedFavsBar[2 * i]) + " | "; } else { tabFavsBar[i].Text = MakeFavoriteNameFit(parsedFavsBar[2 * i]); } tabFavsBar[i].Visible = true; i++; } while (i < tabFavsBar.Length) { tabFavsBar[i].Visible = false; i++; } }
//Fills the list boxes with document title and URL of each favorites //Does the same for the favorites bar private void FillListBoxes() { string[] favorites = ManageFavorites.GetFavorites(); string[] favoritesBar = ManageFavorites.GetFavoritesBar(); int i = 0; foreach (string str in favorites) { if (i % 2 == 0) { listBoxTitle.Items.Add(str); } else { listBoxUrl.Items.Add(str); } i++; } i = 0; foreach (string str in favoritesBar) { if (i % 2 == 0) { listBoxBarTitle.Items.Add(str); } else { listBoxBarUrl.Items.Add(str); } i++; } }
//Happens when the user clicks on the favorites bar private void fav_Click(object sender, EventArgs e) { string[] parsedFavsBar = ManageFavorites.GetFavoritesBar(); for (int i = 0; i < parsedFavsBar.Length; i = i + 2) { if (IsIdentical(parsedFavsBar[i], (LabelControl)sender)) { WebBrowser web = tabControl.SelectedTab.Controls[0] as WebBrowser; web.Navigate(parsedFavsBar[i + 1]); break; } } }