예제 #1
0
        public void populateFavourites()
        {
            favesMenu.DropDownItems.Clear();

            // reads lines from fave file
            string[] faveText = Favourites.getFaves();


            int index = 0;

            //loops from last index as we want to display the last entered favourite first
            for (int i = faveText.Length - 1; i >= 0; i--)
            {
                //a space character indicates the beginning of the user assigned name and the end of the url (seeing a url can't contain spaces)
                string[] result = faveText[i].Split(' ');

                favesMenu.DropDownItems.Add(result[1]);
                //On tab strip item click, init tab with the url value assigned to that item
                ToolStripItem newFaveItem = favesMenu.DropDownItems[index];
                newFaveItem.Click += (a, e) => {
                    initNewTab(result[0]);
                };
                index++;
                //keeps favourites drop down list to a count of 10
                if (index > 9)
                {
                    return;
                }
            }
        }
        //used to update the name associated with the current favourited url
        private void modifyBtn_Click(object sender, EventArgs e)
        {
            List <string> readText = Favourites.getFaves().ToList();

            //a space character indicates the beginning of the user assigned name and the end of the url (seeing a url can't contain spaces)
            string[] result = null;
            try
            {
                result = readText[(readText.Count - 1) - favesDisplay.SelectedIndex].Split(' ');
            }
            catch (Exception noFaveToModify)
            {
                return;
            }

            string input = Microsoft.VisualBasic.Interaction.InputBox("Please enter a new name for the address " + result[0], "New name", result[1], -1, -1);

            if (input.Length < 1)
            {
                return;
            }

            string newLine = result[0] + " " + input;

            readText[(readText.Count - 1) - favesDisplay.SelectedIndex] = newLine;

            Favourites.setFavouritesFile(readText);

            favesDisplay.Items[favesDisplay.SelectedIndex] = newLine;

            //potentially delegate??? Seemed useless at time as I couldn't imagine ever adding more functionality to this event
            browse.populateFavourites();
        }
예제 #3
0
 public FavouritesDialogue(string title, string url, Favourites favourites)
 {
     InitializeComponent();
     TitleTextBox.Text = title;
     UrlTextBox.Text   = url;
     fav = favourites;
 }
        private void displayFaves()
        {
            // read lines from fave file
            string[] faveList = Favourites.getFaves();

            for (int i = faveList.Length - 1; i >= 0; i--)
            {
                favesDisplay.Items.Add(faveList[i]);
            }
        }
예제 #5
0
        private void faveBtn_Click(object sender, EventArgs e)
        {
            string prompt   = "Please enter the name you would like to assign to the web address " + addressTextBox.Text;
            string faveName = Microsoft.VisualBasic.Interaction.InputBox(prompt, "Favourite", "Enter Name", -1, -1);


            Favourites.addToFavouritesFile(addressTextBox.Text, faveName);

            OnFave();
        }
예제 #6
0
        public BrowserWindow()
        {
            InitializeComponent();
            MenuPicker.BringToFront();
            favourites = Favourites.Instance;
            history    = History.Instance;
            favourites.EntryChanged += Favourites_Changed;
            history.EntryChanged    += History_Changed;
            string path = Application.StartupPath;

            watcher = new FileWatcher(path);
            watcher.FSEventHandler += FS_Changed;
            watcher.WatcherError   += Watcher_Error;
            watcher.Run();
            favourites.DeserializeCollection();
            history.DeserializeCollection();
            Renderer.Navigated += Render_Navigated;
        }
        //Potential for improvement, currently deletes by rewriting over entire favourite file
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            List <string> readText = Favourites.getFaves().ToList();

            try
            {
                readText.RemoveAt((readText.Count - 1) - favesDisplay.SelectedIndex);
            }catch (Exception noFaveToDelete)
            {
                return;
            }

            Favourites.clearFavouritesFile();
            Favourites.setFavouritesFile(readText);

            favesDisplay.Items.RemoveAt(favesDisplay.SelectedIndex);

            //potentially delegate??? Seemed useless at time as I couldn't imagine ever adding more functionality to this event
            browse.populateFavourites();
        }
예제 #8
0
 private void clearFavouritesMenu_Click(object sender, EventArgs e)
 {
     favesMenu.DropDownItems.Clear();
     Favourites.clearFavouritesFile();
 }
예제 #9
0
        /// <summary>
        /// Asyncronously instantiate a PageContent object, replaces constructor
        /// </summary>
        /// <param name="url">The URL of the first page to open on instantiation</param>
        /// <param name="singletonHistory">Reference to the history object to manage updating the list</param>
        /// <returns></returns>
        public static async Task <PageContent> AsyncCreate(string url, History singletonHistory, Favourites singletonFavourites)
        {
            PageContent pc = new PageContent(url);

            pc.SingletonHistory    = singletonHistory;
            pc.SingletonFavourites = singletonFavourites;
            await pc.GetPage();

            // init LocalHistory
            PageHistory FirstPage = new PageHistory(pc.Url, pc.Title);

            pc.LocalHistory = FirstPage;

            return(pc);
        }