Exemple #1
0
        public void FinishedLoadCategory(List<Category> list)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeCallbackCategoryList(FinishedLoadCategory), list);
                return;
            }

            //adding All to search in all category
            Category all = new Category();
            all.id = 0;
            all.name = "All";
            list.Insert(0, all);

            //adding a favorite category, this is kind of special category.
            Category fav = new Category();
            fav.id = -1;
            fav.name = "Favorites";
            list.Insert(1, fav);

            comboBoxCategory.Items.Clear();
            categories.Clear();
            foreach (Category i in list)
            {
                categories.Add(i);
                comboBoxCategory.Items.Add(i.name);
            }
            comboBoxCategory.SelectedIndex = 0;
            is_get_category = true;
            EnableSearch();
        }
Exemple #2
0
        public void GetCategories()
        {
            List<Category> list = new List<Category>();

            WebClient client = new WebClient();
            string content = client.DownloadString(AppConst.SERVER_ADDRESS + "/get_category");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(content);
            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("category");
            foreach (XmlNode node in nodeList)
            {
                Category item = new Category();
                item.id = int.Parse(node.Attributes["id"].Value);
                item.name = Utility.URLDecode(node.Attributes["name"].Value);
                list.Add(item);
            }

            callback.FinishedLoadCategory(list);
        }