Exemplo n.º 1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //Loading.Visibility = Visibility.Visible;


            string id = e.Parameter as string;

            items1 = await Table1.Where(s => s.Id == id).ToCollectionAsync();

            if (items1 != null)
            {
                Scrap    s   = items1[0];
                string[] str = s.Point_List.Split(',');
                for (int i = 0; i < str.Length; i++)
                {
                    string po = str[i];
                    items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync();

                    Pointer p = new Pointer();
                    if (items2.Count > 0)
                    {
                        p = items2[0];
                        li.Add(p);
                    }
                }
            }
            await StartPreviewAsync();

            for (int i = 0; i < li.Count; i++)
            {
                PointerViewAR p = new PointerViewAR();
                p.Id    = li[i].Id;
                p.lat   = li[i].lat;
                p.lon   = li[i].lon;
                p.Pitch = li[i].Pitch;
                p.Title = li[i].Title;
                p.Yaw   = li[i].Yaw;
                p.Desc  = li[i].Desc;
                p.Media = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(li[i].Media_Url));
                li2.Add(p);
            }

            myBool = true;
        }
Exemplo n.º 2
0
        private async Task loadPoint()
        {
            //TODO Flush older scrapes
            Tags.Text = "Loading Tour";
            myBool    = false;
            Scrap s = li[i];

            string[] str = s.Point_List.Split(',');
            for (int i = 0; i < str.Length; i++)
            {
                string po = str[i];
                items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync();

                Pointer p = new Pointer();
                if (items2.Count > 0)
                {
                    p = items2[0];
                    li3.Add(p);
                }
            }//all pointers loaded for one scrap
            for (int i = 0; i < li3.Count; i++)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    PointerViewAR p = new PointerViewAR();
                    p.Id            = li3[i].Id;
                    p.lat           = li3[i].lat;
                    p.lon           = li3[i].lon;
                    p.Pitch         = li3[i].Pitch;
                    p.Title         = li3[i].Title;
                    p.Yaw           = li3[i].Yaw;
                    p.Desc          = li3[i].Desc;
                    p.Media         = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(li3[i].Media_Url));
                    li2.Add(p);
                });
            }
            //all images loaded
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Tags.Text = "Destination is " + li[i].Title;
            });

            myBool = true;
        }
Exemplo n.º 3
0
        private async void Geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            if (myBool || first)
            {
                pos = args.Position;
                try
                {
                    string   pur       = App.u.TourPurchases;
                    string[] purchases = pur.Split(',');

                    items4 = await Table4.Where(t =>
                                                purchases.Contains(t.Id)).ToCollectionAsync();

                    List <string> scrapeId = new List <string>();
                    foreach (Tour t in items4)
                    {
                        string[] temp = t.Scrap_List.Split(',');
                        for (int i = 0; i < temp.Length; i++)
                        {
                            scrapeId.Add(temp[i]);
                        }
                    }
                    myBool = false;
                    first  = false;

                    items3 = await Table3.Where(t =>
                                                (t.lat - pos.Coordinate.Latitude <0.0018018018 &&
                                                                                  t.lat - pos.Coordinate.Latitude> -0.0018018018 &&
                                                 t.lon - pos.Coordinate.Longitude <0.0018018020 &&
                                                                                   t.lon - pos.Coordinate.Longitude> -0.0018018020 &&
                                                 (t.UserId == App.userId || scrapeId.Contains(t.Id))
                                                )).ToCollectionAsync();

                    myBool = true;
                    first  = true;
                    //TODO : add logic to get only those he has bought or created
                    // query updated , testing left
                    if (items3.Count != 0)
                    {
                        first  = false;
                        myBool = false;
                        foreach (Scrap s in items3)
                        {
                            if (id.Contains(s.Id))
                            {
                            }
                            else
                            {
                                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    textBox.Text = "Loading new Scrapes";
                                });

                                id.Add(s.Id);
                                li.Add(s);
                                string[] str = s.Point_List.Split(',');
                                for (int i = 0; i < str.Length; i++)
                                {
                                    string po = str[i];
                                    items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync();

                                    Pointer p = new Pointer();
                                    if (items2.Count > 0)
                                    {
                                        p = items2[0];
                                        li3.Add(p);
                                    }
                                }//all pointers loaded for one scrap

                                for (int i = 0; i < li3.Count; i++)
                                {
                                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                    {
                                        PointerViewAR p = new PointerViewAR();
                                        p.Id            = li3[i].Id;
                                        p.lat           = li3[i].lat;
                                        p.lon           = li3[i].lon;
                                        p.Pitch         = li3[i].Pitch;
                                        p.Title         = li3[i].Title;
                                        p.Yaw           = li3[i].Yaw;
                                        p.Desc          = li3[i].Desc;
                                        p.Media         = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(li3[i].Media_Url));
                                        li2.Add(p);
                                    });
                                }
                                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    textBox.Text = "Done";
                                });
                            }
                        }
                        foreach (Scrap s in li)
                        {
                            if (items3.Contains(s))
                            {
                            }
                            else
                            {
                                myBool = false;
                                li.Remove(s);
                                id.Remove(s.Id);
                                string[] str = s.Point_List.Split(',');
                                for (int i = 0; i < str.Length; i++)
                                {
                                    string po = str[i];
                                    //items2 = await Table2.Where(t => t.Id == po).ToCollectionAsync();
                                    List <Pointer> p = new List <Pointer>();

                                    p = li3.Where(tr => tr.Id == str[i]).ToList <Pointer>();
                                    li3.Remove(p[0]);
                                    List <PointerViewAR> pt = new List <PointerViewAR>();
                                    pt = li2.Where(tr => tr.Id == str[i]).ToList <PointerViewAR>();
                                    li2.Remove(pt[0]);
                                }//all pointers removed for one scrap
                            }
                        }
                        myBool = true;
                    }
                }
                catch (Exception ex)
                {
                    myBool = true;
                }
            }
        }