コード例 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            muctieu = (MucTieu)e.Parameter;
            nguoidung = connection.Table<NguoiDung>().Where(r => r.TenDangNhap == muctieu.TenDangNhap).FirstOrDefault();
            int tuoi = DateTime.Today.Year - DateTime.ParseExact(nguoidung.NgaySinh, "dd/MM/yyyy", new CultureInfo("vi-vn")).Year;
            chiso = new ChiSo(muctieu.CanNangBanDau, muctieu.ChieuCaoBanDau, nguoidung.GioiTinh, tuoi);
            // so ngay giam de nghi cho mac dinh = 30;
            int socangiamdenghi = chiso.tinhSoCanGiamDeNghi(); // cannang - cannanglytuong

            // muc 1
            DeNghi muc1 = new DeNghi();
            muc1.SoCanGiamDeNghi = socangiamdenghi;
            muc1.SoNgayGiamDeNghi = Convert.ToInt32(Math.Round(muc1.SoCanGiamDeNghi / 0.05));
            muc1Button.Content = string.Format("Giảm {0} kg trong vòng {1} ngày", muc1.SoCanGiamDeNghi, muc1.SoNgayGiamDeNghi);
            muc1Button.Tag = muc1;

            // muc 2 
            DeNghi muc2 = new DeNghi();
            muc2.SoCanGiamDeNghi = socangiamdenghi;
            muc2.SoNgayGiamDeNghi = Convert.ToInt32(Math.Round(muc2.SoCanGiamDeNghi / 0.1));
            muc2Button.Content = string.Format("Giảm {0} kg trong vòng {1} ngày", muc2.SoCanGiamDeNghi, muc2.SoNgayGiamDeNghi);
            muc2Button.Tag = muc2;

            // muc3
            DeNghi muc3 = new DeNghi();
            muc3.SoCanGiamDeNghi = socangiamdenghi;
            muc3.SoNgayGiamDeNghi = Convert.ToInt32(Math.Round(muc3.SoCanGiamDeNghi / 0.15));
             muc3Button.Content = string.Format("Giảm {0} kg trong vòng {1} ngày", muc3.SoCanGiamDeNghi, muc3.SoNgayGiamDeNghi);
            muc3Button.Tag = muc3;

            
        }
コード例 #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            nguoidung = (NguoiDung)e.Parameter;

            chiso = new ChiSo();
            chiso.GioiTinh = nguoidung.GioiTinh;
            DateTime birthday = DateTime.ParseExact(nguoidung.NgaySinh, "dd/MM/yyyy", new CultureInfo("vi-vn"));
            chiso.Tuoi = DateTime.Today.Year - birthday.Year;
        }
コード例 #3
0
ファイル: DangKy.xaml.cs プロジェクト: dracudakid/AppGiamCan
        private async void dangkyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if(tendangnhapTextBox.Text.Trim() == "" || matkhauPasswordBox.Password.Trim() == "")
                {
                    // neu khong nhap tendangnhap, matkhau thi se hien len thong bao
                    var msDialog = new MessageDialog("TÊN ĐĂNG NHẬP và MẬT KHẨU không được để trống");
                    await msDialog.ShowAsync();
                    return;
                }
                // kiem tra ngay sinh (ngay sinh khong duoc la ngay o tuong lai)
                if (ngaysinhDatePicker.Date > DateTime.Today)
                {
                    var msDialog = new MessageDialog("NGÀY SINH không chính xác");
                    await msDialog.ShowAsync();
                    return;
                }

                // kiem tra tendangnhap da co nguoidung su dung chua
                var nguoidungCollection = connection.Table<NguoiDung>();
                foreach (var nd in nguoidungCollection)
                {
                    if(nd.TenDangNhap == tendangnhapTextBox.Text)
                    {
                        var msDialog = new MessageDialog("TÊN ĐĂNG NHẬP đã tồn tại.\nVui lòng chọn tên đăng nhập khác.");
                        await msDialog.ShowAsync();
                        return;
                    }
                }

                //dua nguoidung vao database
                //lay ngaysinh, dua ve dang dd-MM-yyyy
                string ngaysinh = ngaysinhDatePicker.Date.ToString("dd/MM/yyyy");
                //lay gioitinh
                RadioButton selectedRadio = gioitinhPanel.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked == true);
                // tao moi nguoidung
                NguoiDung nguoidung = new NguoiDung(tendangnhapTextBox.Text, matkhauPasswordBox.Password, ngaysinh, selectedRadio.Content.ToString());
                //insert nguoidung 
                connection.Insert(nguoidung);

                //hien thi thong bao thanh cong
                var msDialog1 = new MessageDialog("Đăng ký thành công!");
                await msDialog1.ShowAsync();

                //tro ve trang MainPage de dang nhap
                Frame.Navigate(typeof(MainPage));


            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #4
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     NguoiDung = (NguoiDung)e.Parameter;
     this.DataContext = NguoiDung;
     ngaysinhDatePicker.Date = DateTime.ParseExact(NguoiDung.NgaySinh,"dd/MM/yyyy", new CultureInfo("vi-vn"));
     if (NguoiDung.GioiTinh == "Nam")
     {
         gioitinhPanel.Children.OfType<RadioButton>().FirstOrDefault(r => r.Content.ToString() == "Nam").IsChecked = true;
     }
     else
     {
         gioitinhPanel.Children.OfType<RadioButton>().FirstOrDefault(r => r.Content.ToString() == "Nữ").IsChecked = true;
     }
 }
コード例 #5
0
ファイル: Shell.xaml.cs プロジェクト: dracudakid/AppGiamCan
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            nguoidung = e.Parameter as NguoiDung;
            // kiem tra ngay hien tai da co trong db chua, chua co thi them vao
            muctieu = connection.Table<MucTieu>().Where(r => r.TenDangNhap == nguoidung.TenDangNhap && (r.TrangThai == "Đã bắt đầu" || r.TrangThai == "Chưa bắt đầu")).FirstOrDefault();

            string today = DateTime.Today.ToString("dd/MM/yyyy");

            thongkengay = (muctieu != null) ? connection.Table<ThongKeNgay>().Where(r => r.IdMucTieu == muctieu.IdMucTieu && r.Ngay == today).FirstOrDefault() : null;

            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;
        }
コード例 #6
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     nguoidung = TrangChu.nguoidung;
     muctieu = TrangChu.muctieu;
     if(muctieu != null)
     {
         if (muctieu.ThoiGianBatDau == null || muctieu.TrangThai == "Chưa bắt đầu")
         {
             muctieu.TrangThai = "Đã bắt đầu";
             muctieu.ThoiGianBatDau = DateTime.Today.ToString("dd/MM/yyyy");
             connection.Update(muctieu);
         }
     }
 }
コード例 #7
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";
     }
 }
コード例 #8
0
ファイル: LacVong.xaml.cs プロジェクト: dracudakid/AppGiamCan
        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();
            }
        }
コード例 #9
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                // lay nguoidung tu trang dang nhap vao
                nguoidung = (NguoiDung)e.Parameter;

                // lay muctieu hien tai cua nguoidung
                muctieu = getMucTieuHienTai(nguoidung);
            }
            catch (Exception)
            {
                MessageDialog msDialog = new MessageDialog("Một số lỗi đã xảy ra");
                await msDialog.ShowAsync();
                Frame.Navigate(typeof(MainPage));
            }
        }
コード例 #10
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // lấy người dùng hiện tại
            nguoidung = TrangChu.nguoidung;
            // lay muctieu hien tai
            muctieu = TrangChu.muctieu;
            
            // neu muctieu == null -> thu lay muctieu da hoan thanh truoc do
            if (muctieu == null) muctieu = connection.Table<MucTieu>().Where(r=>r.TenDangNhap == nguoidung.TenDangNhap && r.TrangThai=="Hoàn thành").OrderBy(r=>r.IdMucTieu).FirstOrDefault();

            if (muctieu != null)
            {
                // lay danh sách các ngày từ mục tiêu hiện tại
                ThongKeNgayList = connection.Table<ThongKeNgay>().Where(r => r.IdMucTieu == muctieu.IdMucTieu).ToList<ThongKeNgay>();
                // lấy danh sách các mục tiêu khác của người dùng hiện tại (để hiển thị)
                List<MucTieu> muctieukhacList = connection.Table<MucTieu>().Where(r => r.TenDangNhap == nguoidung.TenDangNhap && r.IdMucTieu != muctieu.IdMucTieu).ToList();
                ThongKeNgayKhacList = new List<ThongKeNgay>();
                // lấy danh sách các ngày từ các mục tiêu trước
                foreach (var muctieukhac in muctieukhacList)
                {
                    var list = connection.Table<ThongKeNgay>().Where(r => r.IdMucTieu == muctieukhac.IdMucTieu).ToList();
                    list.ForEach(r => ThongKeNgayKhacList.Add(r));
                }
            }
            else
            {
                ThongKeNgayList = new List<ThongKeNgay>();
                List<MucTieu> muctieukhacList = connection.Table<MucTieu>().Where(r => r.TenDangNhap == nguoidung.TenDangNhap).ToList();

                ThongKeNgayKhacList = new List<ThongKeNgay>();
                // lấy danh sách các ngày từ các mục tiêu trước
                foreach (var muctieukhac in muctieukhacList)
                {
                    var list = connection.Table<ThongKeNgay>().Where(r => r.IdMucTieu == muctieukhac.IdMucTieu).ToList();
                    list.ForEach(r => ThongKeNgayKhacList.Add(r));
                }
            }

            Initialize_Calendar(calendarDate);



        }
コード例 #11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            nguoidung = TrangChu.nguoidung;

            muctieu = TrangChu.muctieu;
            if (muctieu != null)
            {
                thongkengay = TrangChu.getThongKeNgayHienTai(muctieu);
                // lấy danh sách món ăn đã chọn từ ngày hôm đó
                monanDBList = connection.Table<ThucDon>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay).ToList<ThucDon>();

                
            }
            else
            {
                thongkengay = new ThongKeNgay();
                monanDBList = new List<ThucDon>();
            }
            // lấy danh sách các món ăn từ database
            monAnList = connection.Table<MonAn>().ToList<MonAn>();
            TongLuongKalo = 0;
        }
コード例 #12
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();
            }
        }
コード例 #13
0
ファイル: NhayDay.xaml.cs プロジェクト: dracudakid/AppGiamCan
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

            //image
            List<Uri> uriLst = new List<Uri>();
            for (int i = 1; i <= 2; i++)
            {
                uriLst.Add(new Uri("ms-appx:///Assets/nhayday0" + i + ".png"));
            }

            for (int i = 0; i < 2; 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);
                nhayday = connection.Table<ThongKeBaiTap>().Where(r => r.IdThongKeNgay == thongkengay.IdThongKeNgay && r.IdBaiTap == 5).FirstOrDefault();
                if (nhayday == null)
                {
                    nhayday = new ThongKeBaiTap()
                    {
                        IdBaiTap = 5,
                        IdThongKeNgay = thongkengay.IdThongKeNgay,
                        QuangDuong = 0,
                        SoBuoc = 0,
                        LuongKaloTieuHao = 0,
                        ThoiGianTap = 0
                    };
                    connection.Insert(nhayday);
                }
            }

            // mục tiêu == null || thống kê ngày == null -> tập nhưng không đưa vào database
            else
            {
                nhayday = new ThongKeBaiTap();
            }

        }
コード例 #14
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     nguoidung = (NguoiDung)e.Parameter;
     // dat mac dinh ngay la hom nay
     ngayDatePicker.Date = DateTime.Today;
 }
コード例 #15
0
 /// <summary>
 /// lấy mục tiêu hiện tại của người dùng
 /// </summary>
 /// <param name="nd">người dùng</param>
 /// <returns>mục tiêu hiện tại</returns>
 public static MucTieu getMucTieuHienTai(NguoiDung nd)
 {
     MucTieu muctieu = connection.Table<MucTieu>().Where(r => r.TenDangNhap == nd.TenDangNhap && (r.TrangThai == "Đã bắt đầu" || r.TrangThai == "Chưa bắt đầu")).FirstOrDefault();
     return muctieu;
 }
コード例 #16
0
ファイル: Shell.xaml.cs プロジェクト: dracudakid/AppGiamCan
        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();
            }
        }
コード例 #17
0
 /// <summary>
 /// lấy dữ liệu từ trang chủ gửi vào ( Người Dùng)
 /// </summary>
 /// <param name="e"></param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     NguoiDung = (NguoiDung)e.Parameter;
     this.DataContext = NguoiDung;
 }
コード例 #18
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();
            }
        }
コード例 #19
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();
            }

        }
コード例 #20
0
ファイル: DapXe.xaml.cs プロジェクト: dracudakid/AppGiamCan
        //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;
            }


        }