Esempio n. 1
0
        private void btnAddPod_Click(object sender, EventArgs e)
        {
            var podUrl        = txtAddPod.Text;
            var podName       = txtEnterName.Text;
            var getCategory   = (string)cbNewCategories.SelectedItem;
            int intervalValue = (int)numericUpdateFrequency.Value;

            try
            {
                Validation.checkIfEmpty(podUrl);
                Validation.checkIfNull(podUrl);
                Validation.checkIfEmpty(podName);
                Validation.checkIfEmpty(intervalValue);
                Validation.checkIfNull(getCategory);
                {
                    podcastList.AddPod(podUrl, podName, intervalMS, getCategory); //Adderar podcasten till ett objekt sedan till en lista

                    foreach (var item in cbNewCategories.Items)
                    {
                        categoryList.addCategoryToList(item.ToString());
                    }

                    XmlCommunication.SaveListData(podcastList.GetPodcastList(), "pods.xml");
                    fillCbCategories(); //Ändra staten av comboboxen kategori
                    MessageBox.Show("Podden har nu lagts till! :)");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 public MainForm()
 {
     InitializeComponent();
     setCategoryListOnLoad();
     XmlCommunication.loadCategory(categoryList);
     XmlCommunication.loadPodcasts(podcastList);
 }
Esempio n. 3
0
 private void load()
 {
     categoryList = XmlCommunication.LoadCategory();
     foreach (var item in categoryList.GetCategoryList())
     {
         cbCategories.Items.Add(item.Name);
     }
 }
Esempio n. 4
0
 private void setCategoryListOnLoad()
 {
     foreach (var item in cbNewCategories.Items)
     {
         categoryList.addCategoryToList(item.ToString());
         cbCategories.Items.Add(item.ToString());
     }
     XmlCommunication.SaveListData(categoryList.GetCategoryList(), "Category.xml");
 }
Esempio n. 5
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (rbAddNew.Checked)
     {
         categoryList.addCategoryToList(txtName.Text);
         XmlCommunication.SaveListData(categoryList.GetCategoryList(), "Category.xml");
     }
     else if (rbChange.Checked)
     {
         string checkedCategory = (string)cbCategories.SelectedItem;
         foreach (var category in categoryList.GetCategoryList())
         {
             if (category.Name == checkedCategory)
             {
                 category.Name = txtName.Text;
                 XmlCommunication.SaveListData(categoryList.GetCategoryList(), "Category.xml");
             }
         }
     }
 }
Esempio n. 6
0
        private void btnAddPod_Click(object sender, EventArgs e)
        {
            podcast.Name     = txtNewName.Text;
            podcast.Url      = txtNewUrl.Text;
            podcast.Category = (string)cbCategories.SelectedItem;
            podcast.Interval = intervalMS;
            try
            {
                Validation.checkIfEmpty(podcast.Interval);
                Validation.checkIfEmpty(podcast.Name);
                Validation.checkIfNull(podcast.Category);
                Validation.checkIfEmpty(podcast.Url);

                XmlCommunication.SaveListData(podcastList.GetPodcastList(), "Podcasts.xml");
                MessageBox.Show("Ändringen är nu klar! :)");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }