Exemplo n.º 1
0
 void Instance_ReadyEvent(MiniGame.MiniGameControl mg, LoopList.LoopList loopList)
 {
     if (loopList.IsShowing(mg))
     {
         mg.MinigameSkeletonEvent(KinectHelper.Instance.GetFixedSkeleton(), KinectHelper.Instance.DepthImagePixels, KinectHelper.Instance.ColorPixels);
         KinectHelper.Instance.SetTransform(mg);
     }
     else
     {
         mg.Stop();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Loads offers from db and add it to loop list
        /// </summary>
        /// <param name="kinectProjectUiBuilder"></param>
        /// <param name="firstShownOffer">offer which should shown first</param>
        public void LoadElementsIntoList(KinectProjectUiBuilder kinectProjectUiBuilder, TravelOffer firstShownOffer)
        {
            var offerDao = new TravelOfferDao();
            List <LoopListEntry> list   = new List <LoopListEntry> ();
            List <TravelOffer>   dbList = offerDao.SelectAllTopOffers();

            foreach (var offer in dbList)
            {
                Grid grid = new Grid();
                BuildBackground(grid, offer.ImgPath);
                BuildInfoBox(grid, offer);

                LoopListEntry entry = new LoopListEntry {
                    FrameworkElement = grid, Id = offer.OfferId
                };

                if (offer.OfferId == firstShownOffer.OfferId)
                {
                    list.Insert(0, entry);
                }
                else
                {
                    list.Add(entry);
                }
            }
            try
            {
                MiniGame.MiniGameControl mg = new MiniGame.MiniGameControl();
                mg.Start(KinectHelper.Instance.Sensor);
                KinectHelper.Instance.ReadyEvent += (sender, _) => Instance_ReadyEvent(mg, kinectProjectUiBuilder.GetLoopList());

                LoopListEntry entry = new LoopListEntry {
                    FrameworkElement = mg, Id = -1
                };
                list.Add(entry);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            kinectProjectUiBuilder.AddRow("Top", list);

            //todo maybe ask db for categories and not enum
            foreach (CategoryEnum category in Enum.GetValues(typeof(CategoryEnum)).Cast <CategoryEnum>())
            {
                list   = new List <LoopListEntry>();
                dbList = offerDao.SelectOfferyByCategory(category);
                foreach (var offer in dbList)
                {
                    Grid grid = new Grid();
                    BuildBackground(grid, offer.ImgPath);
                    BuildInfoBox(grid, offer);
                    LoopListEntry entry = new LoopListEntry {
                        FrameworkElement = grid, Id = offer.OfferId
                    };
                    list.Add(entry);
                }
                kinectProjectUiBuilder.AddRow(dbList.First().Category.CategoryName, list);
            }
        }