Пример #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ScenarioEnableButton.IsEnabled  = true;
            ScenarioDisableButton.IsEnabled = false;
            ScenarioPauseButton.IsEnabled   = false;

            nguoidung = TrangChu.nguoidung;
            muctieu   = TrangChu.muctieu;
            if (muctieu != null)
            {
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                chaybo      = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 1).FirstOrDefault();
                if (chaybo == null)
                {
                    chaybo = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 1,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        SoBuoc           = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(chaybo);
                }
            }

            // mục tiêu == null || thống kê ngày == null -> tập nhưng không đưa vào database
            else
            {
                chaybo = new ThongKeBaiTap();
            }
        }
Пример #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            List <Uri> uriLst = new List <Uri>();

            for (int i = 1; i <= 13; i++)
            {
                uriLst.Add(new Uri("ms-appx:///Assets/lacvong" + i + ".png"));
            }
            for (int i = 0; i < 13; i++)
            {
                imgLst.Add(new BitmapImage(uriLst[i]));
            }

            threadImg = ThreadPoolTimer.CreatePeriodicTimer(UpdateSprite, TimeSpan.FromMilliseconds(100));

            //kiem tra bai tap nay da co trong database chua
            nguoidung = TrangChu.nguoidung;

            // lấy mục tiêu hiện tại (có thể null)
            muctieu = TrangChu.muctieu;
            if (muctieu != null)
            {
                // lấy thống kê ngày hiện tại (có thể null)
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                //check da tap lan nao trong ngay chua

                lacVong = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 6).FirstOrDefault();
                if (lacVong == null)
                {
                    lacVong = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 6,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(lacVong);
                }
            }

            // neu khong thi cho tap nhung khong dua vao database
            else
            {
                lacVong = new ThongKeBaiTap();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //image
            List <Uri> uriLst = new List <Uri>();

            for (int i = 1; i <= 5; i++)
            {
                uriLst.Add(new Uri("ms-appx:///Assets/dungngoi" + i + ".png"));
            }

            for (int i = 0; i < 5; i++)
            {
                imgLst.Add(new BitmapImage(uriLst[i]));
            }
            threadImg = ThreadPoolTimer.CreatePeriodicTimer(UpdateSprite, TimeSpan.FromMilliseconds(400));

            ScenarioEnableButton.IsEnabled  = true;
            ScenarioDisableButton.IsEnabled = false;
            ScenarioPauseButton.IsEnabled   = false;

            nguoidung = TrangChu.nguoidung;
            muctieu   = TrangChu.muctieu;
            if (muctieu != null)
            {
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                dungngoi    = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 4).FirstOrDefault();
                if (dungngoi == null)
                {
                    dungngoi = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 4,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        SoBuoc           = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(dungngoi);
                }
            }

            // mục tiêu == null || thống kê ngày == null -> tập nhưng không đưa vào database
            else
            {
                dungngoi = new ThongKeBaiTap();
            }
        }
Пример #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // lấy thông tin từ  trang muc tap
            mucTap muctap = (mucTap)e.Parameter;

            tenBt      = muctap.tenBaiTap;
            level      = muctap.level;
            tenBT.Text = tenBt;
            nguoidung  = TrangChu.nguoidung;
            muctieu    = TrangChu.muctieu;


            //image
            List <Uri> uriLst = new List <Uri>();

            if (tenBt == "Gập bụng")
            {
                for (int i = 1; i <= 4; i++)
                {
                    uriLst.Add(new Uri("ms-appx:///Assets/gapbung" + i + ".png"));
                }
            }
            else
            {
                for (int i = 1; i <= 6; i++)
                {
                    uriLst.Add(new Uri("ms-appx:///Assets/hitdat" + i + ".png"));
                }
            }

            for (int i = 0; i < 4; i++)
            {
                imgLst.Add(new BitmapImage(uriLst[i]));
            }

            threadImg = ThreadPoolTimer.CreatePeriodicTimer(UpdateSprite, TimeSpan.FromMilliseconds(200));


            // lay thong tin bai tap bung hay hit dat dua vao ten
            baiTapBung = connection.Table <BaiTap>().Where(r => r.TenBaiTap == tenBt).FirstOrDefault();
            idBT       = baiTapBung.IdBaiTap;

            if (muctieu != null)
            {
                thongKeNgay    = TrangChu.getThongKeNgayHienTai(muctieu);
                thongKeTapBung = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongKeNgay.IdThongKeNgay && r.IdBaiTap == idBT).FirstOrDefault();
                if (thongKeTapBung == null)
                {
                    thongKeTapBung = new ThongKeBaiTap()
                    {
                        IdThongKeNgay    = thongKeNgay.IdThongKeNgay,
                        IdBaiTap         = idBT,
                        LuongKaloTieuHao = 0,
                        SoLan            = 0
                    };
                    connection.Insert(thongKeTapBung);
                }
            }
            else
            {
                thongKeTapBung = new ThongKeBaiTap();
            }
        }
Пример #5
0
        //get current location
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            nguoidung = TrangChu.nguoidung;


            // lấy mục tiêu hiện tại (có thể null)
            muctieu = TrangChu.getMucTieuHienTai(nguoidung);
            if (muctieu != null)
            {
                // lấy thống kê ngày hiện tại (có thể null)
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                //check da tap lan nao trong ngay chua

                dapXe = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 2).FirstOrDefault();
                if (dapXe == null)
                {
                    dapXe = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 2,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(dapXe);
                }
            }

            // neu khong thi cho tap nhung khong dua vao database
            else
            {
                dapXe = new ThongKeBaiTap();
            }


            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:

                // Get the current location
                position = await locator.GetGeopositionAsync();

                point           = position.Coordinate.Point;
                myMap.ZoomLevel = 15;

                // Set map location
                await myMap.TrySetViewAsync(point);

                locator.MovementThreshold = 1;

                //create a icon in current location
                icon       = new MapIcon();
                icon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/pin.png"));
                icon.NormalizedAnchorPoint = new Point(0.5, 1);
                icon.Location = position.Coordinate.Point;
                icon.Title    = "You are here";
                myMap.MapElements.Add(icon);
                //  locator = new Geolocator { ReportInterval = 500 };

                // Subscribe to PositionChanged event to get location updates
                locator.PositionChanged += OnPositionChanged;
                break;

            case GeolocationAccessStatus.Denied:
                // Handle when access to location is denied
                break;

            case GeolocationAccessStatus.Unspecified:
                // Handle when an unspecified error occurs
                break;
            }
        }
Пример #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //Uri uri1 = new System.Uri("ms-appx:///Assets/tabata1.png");
            //Uri uri2 = new System.Uri("ms-appx:///Assets/tabata2.png");
            //Uri uri3 = new System.Uri("ms-appx:///Assets/tabata3.png");
            //Uri uri4 = new System.Uri("ms-appx:///Assets/tabata4.png");
            //Uri uri5 = new System.Uri("ms-appx:///Assets/tabata5.png");
            //List<Uri> uriLst = new List<Uri>();
            //uriLst.Add(uri1);
            //uriLst.Add(uri2);
            //uriLst.Add(uri3);
            //uriLst.Add(uri4);
            //uriLst.Add(uri5);
            List <Uri> uriLst = new List <Uri>();

            for (int i = 1; i <= 5; i++)
            {
                uriLst.Add(new Uri("ms-appx:///Assets/tabata" + i + ".png"));
            }
            //List<ImageSource> imglstSou = new List<ImageSource>();
            //for(int i = 0; i < 5; i++)
            //{
            //    imglstSou.Add(new BitmapImage(uriLst[i]));
            //}
            for (int i = 0; i < 5; i++)
            {
                imgLst.Add(new BitmapImage(uriLst[i]));
            }
            threadImg = ThreadPoolTimer.CreatePeriodicTimer(UpdateSprite, TimeSpan.FromMilliseconds(400));

            //kiem tra bai tap nay da co trong database chua
            nguoidung = TrangChu.nguoidung;

            // lấy mục tiêu hiện tại (có thể null)
            muctieu = TrangChu.muctieu;
            if (muctieu != null)
            {
                // lấy thống kê ngày hiện tại (có thể null)
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                //check da tap lan nao trong ngay chua

                tabata = connection.Table <ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 8).FirstOrDefault();
                if (tabata == null)
                {
                    tabata = new ThongKeBaiTap()
                    {
                        IdBaiTap         = 8,
                        IdThongKeNgay    = thongkengay.IdThongKeNgay,
                        QuangDuong       = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap      = 0
                    };
                    connection.Insert(tabata);
                }
            }

            // neu khong thi cho tap nhung khong dua vao database
            else
            {
                tabata = new ThongKeBaiTap();
            }
        }