Beispiel #1
0
        //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++;
            }
        }
Beispiel #2
0
        //Manages which buttons are enabled or not depending on the actual element selected
        private void listBoxTitle_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selected = listBoxTitle.SelectedIndex;

            if (selected != -1)
            {
                visitButton.Enabled  = true;
                deleteButton.Enabled = true;
                if (ManageFavorites.FavoriteIsInListBoxBar(listBoxTitle.Items[selected].ToString(), listBoxBarTitle.Items))
                {
                    deleteBarButton.Enabled = true;
                    addBarbutton.Enabled    = false;
                }
                else
                {
                    addBarbutton.Enabled    = true;
                    deleteBarButton.Enabled = false;
                }
            }
            else
            {
                visitButton.Enabled     = false;
                deleteButton.Enabled    = false;
                addBarbutton.Enabled    = false;
                deleteBarButton.Enabled = false;
            }
        }
Beispiel #3
0
        //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++;
            }
        }
Beispiel #4
0
        private void favoriteButton_Click(object sender, EventArgs e)
        {
            WebBrowser web = tabControl.SelectedTab.Controls[0] as WebBrowser;

            if (web != null)
            {
                ManageFavorites.AddFavorite(web.DocumentTitle + Environment.NewLine);
                ManageFavorites.AddFavorite(web.Url.ToString() + Environment.NewLine);
            }
        }
Beispiel #5
0
        //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;
                }
            }
        }
Beispiel #6
0
 private void InitializeBrowser()
 {
     ManageFavorites.Initialize();
     ManageHistory.Initialize();
     ManageSettings.Initialize();
     SetFavoritesBar();
     browserName = ManageSettings.GetBrowserName();
     this.Text   = browserName;
     homeUrl     = ManageSettings.GetHomeURL();
     withHistory = ManageSettings.GetHistoryBoolean();
     webBrowser.Navigate(homeUrl);
     actualUrl                                 = homeUrl;
     urlTextEdit.Text                          = homeUrl;
     tabControl.TabPages[0].Text               = webBrowser.DocumentTitle;
     webBrowser.ScriptErrorsSuppressed         = true;
     webBrowser.IsWebBrowserContextMenuEnabled = false;
 }
Beispiel #7
0
        //Checks if modifications have been made and if so, send modified lists to the ManageFavorites class
        private void Favorites_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (favListModified)
            {
                int i = 0;

                while (i < listBoxTitle.Items.Count)
                {
                    listBoxFinal.Items.Add(listBoxTitle.Items[i]);
                    listBoxFinal.Items.Add(listBoxUrl.Items[i]);
                    i++;
                }
                i = 0;
                while (i < listBoxBarTitle.Items.Count)
                {
                    listBoxBarFinal.Items.Add(listBoxBarTitle.Items[i]);
                    listBoxBarFinal.Items.Add(listBoxBarUrl.Items[i]);
                    i++;
                }
                ManageFavorites.ActualizeFavoritesList(listBoxFinal.Items);
                ManageFavorites.ActualizeFavoritesBarList(listBoxBarFinal.Items);
            }
        }