Exemplo n.º 1
0
        //Save the changes to file and memory
        private void SaveButton_Click(object sender, EventArgs e)
        {
            //validate face key, input santization
            if (!PublicMethods.faceValid(FaceKeyTextBox.Text.Substring(2)))
            {
                MessageBox.Show("Error: Invalid Face Key", "Error");
                return;
            }
            //create new tuple for changed favorite and insert it into List to be written
            Tuple <string, string> changedFave = new Tuple <string, string>(NameTextBox.Text, FaceKeyTextBox.Text);

            faves[index] = changedFave;

            //write favorites to file. Not perfect solution, but functional enough
            StreamWriter writer = new StreamWriter(File.Open("favorites.txt", FileMode.Create));

            foreach (Tuple <string, string> fave in faves)
            {
                writer.WriteLine(fave.Item1 + "\t" + fave.Item2);
            }
            writer.Close();
            //reopen manage favorites, causes refresh of favorites to memory. Also not idea, but works
            ManageFavorites mF = new ManageFavorites(faves);

            mF.Show();
            this.Close();
        }
Exemplo n.º 2
0
        //ManageFavorites menu button has been clicked, open manage favorites form
        private void ManageFavorites_Click(object sender, EventArgs e)
        {
            List <Tuple <string, string> > faves = getFaves();

            if (faves.Count > 0)
            {
                ManageFavorites mf = new ManageFavorites(faves);
                mf.Show();
            }
            else
            {
                MessageBox.Show("No Favorites found.");
            }
        }