Example #1
0
        private void OnNavigated(object sender, NavigationEventArgs e)
        {
            this.SplitView.IsPaneOpen = false;

            if ((sender as Frame).Content.GetType() == typeof(TrangChu))
            {
                var tc = (sender as Frame).Content as TrangChu;
                if (e.Parameter.GetType() == typeof(NguoiDung))
                {
                    nguoidung = e.Parameter as NguoiDung;
                    muctieu   = TrangChu.getMucTieuHienTai(nguoidung);

                    thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);

                    tendangnhapTextBlock.Text = nguoidung.TenDangNhap;
                    tuoiTextBlock.Text        = (DateTime.Today.Year - DateTime.ParseExact(nguoidung.NgaySinh, "dd/MM/yyyy", new CultureInfo("vi-vn")).Year).ToString();
                    gioitinhTextBlock.Text    = nguoidung.GioiTinh;
                }
            }
            // neu tro ve trang MainPage thi loại bỏ shell
            if ((sender as Frame).Content.GetType() == typeof(MainPage))
            {
                Frame.Navigate(typeof(MainPage));
                Frame.BackStack.Clear();
            }
        }
Example #2
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     nguoidung = e.Parameter as NguoiDung;
     muctieu   = TrangChu.getMucTieuHienTai(nguoidung);
     if (muctieu != null)
     {
         tkNgay       = TrangChu.getThongKeNgayHienTai(muctieu);
         kaloBox.Text = tkNgay.LuongKaloNgoaiDuKien.ToString();
     }
     else
     {
         tkNgay       = new ThongKeNgay();
         kaloBox.Text = "0";
     }
 }
Example #3
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;
            }
        }