void DownloadXMLStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
                return;

            XDocument doc = XDocument.Parse(e.Result);
            //MessageBox.Show(doc.Document.ToString());

            XNode firstChild = doc.FirstNode;
            var rootElement = doc.Elements();

            //create a menu
            StoreMenu theMenu = new StoreMenu();
            theMenu.theTableID = tableID;

            //loop though the XML. EXTRACT
            string theCats = "";
            foreach (XElement root in rootElement)
            {//at document root
                theCats += root.Name+"   ";
                var cats = root.Elements();

                //Create Catogry List
                //moved to top to make access in this class everywqhere
                
                //at each catagory
                foreach (XElement cat in cats)
                {//for each catgory          
                    theCats += cat.Attribute("Name").Value + "      ";

                    //add categories name to list
                    category tmpCat = new category(cat.Attribute("Name").Value);

                    //get teh childen (items)
                    var catItems = cat.Elements();
                    List<Items> itemsList = new List<Items>();
                    foreach (XElement item in catItems)
                    {
                        Items tmpItem = new Items(item.Attribute("Name").Value, item.Attribute("Desciption").Value, item.Attribute("Price").Value, item.Attribute("ID").Value);
                        itemsList.Add(tmpItem);
                        theCats += item.Attribute("Name").Value + " ";
                    }
                    tmpCat.theItems = itemsList;

                    theCategoriesList.Add(tmpCat);

                }
                int lawlfake = theCategoriesList.Count;

                //Application.Current.ApplicationLifetimeObjects.Add(theCategoriesList);

                //NavigationService.Navigate(new Uri("/PanoramaPage1.xaml", UriKind.Relative));

                //ObjectNav.NavigationExtensions.Navigate(this, "/PanoramaPage1.xaml", theCategoriesList);

              

                //List<AlphaKeyGroup<category>> DataSource = AlphaKeyGroup<category>.CreateGroups(theCategoriesList,
                //System.Threading.Thread.CurrentThread.CurrentUICulture,
                //(category s) => { return s.theName; }, true);

                //catLongList.ItemsSource = DataSource;
                //theCats += cat.FirstAttribute.Value;

                //populate pano with menu
                //List<string> tmpstringlist = new List<string>();
                int count=0;
                foreach (category TMPCAT in theCategoriesList)
                {
                    List<string> tmpstringlist = new List<string>();
                    foreach (Items tmpitems in TMPCAT.theItems)
                    {
                        tmpstringlist.Add("+ "+tmpitems.theName);
                        tmpstringlist.Add("   " + tmpitems.theDescription);
                    }

                    switch (count)
                    {
                        case 0:
                            llDrinks.ItemsSource = tmpstringlist.ToList();
                            break;
                        case 1:
                            llStarter.ItemsSource = tmpstringlist.ToList();
                            break;
                        case 2:
                            llMain.ItemsSource = tmpstringlist.ToList();
                            break;
                        case 3:
                            llDesert.ItemsSource = tmpstringlist.ToList(); 
                            break;
                    }

                    count++;
                }


              
             
                

                
                //foreach (category cat in theCategoriesList)
                //{
                //    panoPaneDrinks.Header = cat.theName;
                //    foreach (Items item in cat.theItems)
                //    {
                //        List<AlphaKeyGroup<Items>> DataSource = AlphaKeyGroup<Items>.CreateGroups(cat.theItems,
                //        System.Threading.Thread.CurrentThread.CurrentUICulture,
                //        (Items s) => { return s.theName; }, true);

                        

                //    }
                //}
            }
            
            
            //MessageBox.Show(theCats);
            updateSummary();

        }
Exemplo n.º 2
0
        void DownloadXMLStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            XDocument doc = XDocument.Parse(e.Result);
            //MessageBox.Show(doc.Document.ToString());

            XNode firstChild  = doc.FirstNode;
            var   rootElement = doc.Elements();

            //create a menu
            StoreMenu theMenu = new StoreMenu();

            theMenu.theTableID = tableID;

            //loop though the XML. EXTRACT
            string theCats = "";

            foreach (XElement root in rootElement)
            {//at document root
                theCats += root.Name + "   ";
                var cats = root.Elements();

                //Create Catogry List
                //moved to top to make access in this class everywqhere

                //at each catagory
                foreach (XElement cat in cats)
                {//for each catgory
                    theCats += cat.Attribute("Name").Value + "      ";

                    //add categories name to list
                    category tmpCat = new category(cat.Attribute("Name").Value);

                    //get teh childen (items)
                    var          catItems  = cat.Elements();
                    List <Items> itemsList = new List <Items>();
                    foreach (XElement item in catItems)
                    {
                        Items tmpItem = new Items(item.Attribute("Name").Value, item.Attribute("Desciption").Value, item.Attribute("Price").Value, item.Attribute("ID").Value);
                        itemsList.Add(tmpItem);
                        theCats += item.Attribute("Name").Value + " ";
                    }
                    tmpCat.theItems = itemsList;

                    theCategoriesList.Add(tmpCat);
                }
                int lawlfake = theCategoriesList.Count;

                //Application.Current.ApplicationLifetimeObjects.Add(theCategoriesList);

                //NavigationService.Navigate(new Uri("/PanoramaPage1.xaml", UriKind.Relative));

                //ObjectNav.NavigationExtensions.Navigate(this, "/PanoramaPage1.xaml", theCategoriesList);



                //List<AlphaKeyGroup<category>> DataSource = AlphaKeyGroup<category>.CreateGroups(theCategoriesList,
                //System.Threading.Thread.CurrentThread.CurrentUICulture,
                //(category s) => { return s.theName; }, true);

                //catLongList.ItemsSource = DataSource;
                //theCats += cat.FirstAttribute.Value;

                //populate pano with menu
                //List<string> tmpstringlist = new List<string>();
                int count = 0;
                foreach (category TMPCAT in theCategoriesList)
                {
                    List <string> tmpstringlist = new List <string>();
                    foreach (Items tmpitems in TMPCAT.theItems)
                    {
                        tmpstringlist.Add("+ " + tmpitems.theName);
                        tmpstringlist.Add("   " + tmpitems.theDescription);
                    }

                    switch (count)
                    {
                    case 0:
                        llDrinks.ItemsSource = tmpstringlist.ToList();
                        break;

                    case 1:
                        llStarter.ItemsSource = tmpstringlist.ToList();
                        break;

                    case 2:
                        llMain.ItemsSource = tmpstringlist.ToList();
                        break;

                    case 3:
                        llDesert.ItemsSource = tmpstringlist.ToList();
                        break;
                    }

                    count++;
                }



                //foreach (category cat in theCategoriesList)
                //{
                //    panoPaneDrinks.Header = cat.theName;
                //    foreach (Items item in cat.theItems)
                //    {
                //        List<AlphaKeyGroup<Items>> DataSource = AlphaKeyGroup<Items>.CreateGroups(cat.theItems,
                //        System.Threading.Thread.CurrentThread.CurrentUICulture,
                //        (Items s) => { return s.theName; }, true);



                //    }
                //}
            }


            //MessageBox.Show(theCats);
            updateSummary();
        }