Ejemplo n.º 1
0
 /// <summary>
 /// Redraws category buttons in the correct order
 /// We need to call this to display the category buttons correctly, because if you just add it
 /// it will go to the front of the panel
 /// </summary>
 public void RedrawCats()
 {
     panel1.Controls.Clear();
     Categories = new List <string>();
     Categories = DatabaseClass.GetCategoriesList();
     if (Categories.Count == 3)
     {
         for (int i = 0; i < Buttons.Count - 1; i++)
         {
             if (i == 3)
             {
                 Buttons.RemoveAt(i);
                 i--;
             }
         }
         panel1.Controls.Add(Buttons[Buttons.Count - 1]);
         for (int i = 3 - 1; i >= 0; i--)
         {
             panel1.Controls.Add(Buttons[i]);
         }
     }
     else
     {
         for (int i = Buttons.Count - 1; i >= 0; i--)
         {
             panel1.Controls.Add(Buttons[i]);
         }
     }
 }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Region = new Region(new Rectangle(0, 0, Width, Height));

            //Fill list with categories
            Categories = new List <string>();
            foreach (string cat in DatabaseClass.GetCategoriesList())
            {
                Categories.Add(cat);
            }

            Buttons = new List <Button>();
            Buttons.Add(button1);
            Buttons.Add(button3);
            Buttons.Add(b_TvSeries);
            Buttons.Add(b_addCat);

            bool added = false;

            for (int i = 3; i < Categories.Count; i++)
            {
                added = true;
                CreateAndAddCatBut(Categories[i], false);
            }
            if (added)
            {
                RedrawCats();
            }
        }
Ejemplo n.º 3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataPanel.Controls.Clear();
            InitAddButton(DataPanel);
            entryComponents.Clear();

            string search = textBox1.Text;

            if (search == "")
            {
                return;     //should later add some message
            }
            switch (search) //super secret dev commands hehe
            {
            case "!wipecats":
                var cats = DatabaseClass.GetCategoriesList();
                for (int j = 3; j < cats.Count; j++)
                {
                    var entries = DatabaseClass.GetDataByCategory(cats[j], "");
                    if (entries != null)
                    {
                        foreach (Entry entry in entries)
                        {
                            DatabaseClass.RemoveEntry(category, entry.name);
                        }
                    }
                    DatabaseClass.RemoveCategory(cats[j]);
                }
                var pp = Parent.Parent as Form1;
                pp.RedrawCats();
                break;

            case "!wipeentries":
                var entriess = DatabaseClass.GetDataByCategory(category, "");
                foreach (Entry entry in entriess)
                {
                    DatabaseClass.RemoveEntry(category, entry.name);
                }
                break;

            case "!wipeall":
                DatabaseClass.RemoveAllEntries();
                DatabaseClass.RemoveNonMandatoryCategories();
                var ppp = Parent.Parent as Form1;
                ppp.RedrawCats();
                break;
            }
            var list = DatabaseClass.GetCategoryEntry(DatabaseClass.FindCategoryId(category), search);

            int i = 0;

            foreach (Entry ent in list)
            {
                EntryComponent entr = new EntryComponent(i, ent, category);
                DataPanel.Controls.Add(entr.mainPanel);
                entryComponents.Add(entr);
            }
        }