示例#1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            txtusername.Text = App.user.F_Name + " " + App.user.L_Name;

            if (App.transaction_table != null)
            {
                current_transaction = App.transaction_table;

                if (current_transaction.Volunteer_Id != null)
                {
                    current_volunteer = Volunteer.Get_VolunteerById(current_transaction.Volunteer_Id ?? default(int));

                    txtvolname.Text = current_volunteer.F_Name + " " + current_volunteer.L_Name;

                    if (current_transaction.Driver_Id != null)
                    {
                        current_driver = Driver.Get_DriverById(current_transaction.Driver_Id ?? default(int));

                        txtdriname.Text = current_driver.F_Name + " " + current_driver.L_Name;
                    }
                }
            }
            else
            {
                var dialog = new MessageDialog("Volunteer Has Cancelled the Session");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(UserHome));
            }
        }
示例#2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            if (App.transaction_table != null)
            {
                txtusername.Text   = App.transaction_table.User_Name;
                txtusermobile.Text = App.transaction_table.User_Mobile_Number;
                txtitems.Text      = App.transaction_table.Items;

                txtvolname.Text   = App.transaction_table.Volunteer_Name;
                txtvolmobile.Text = App.transaction_table.Volunteer_Mobile;


                SetMap();
            }
            else
            {
                var dialog = new MessageDialog("Session has been cancelled");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(DriverHome));
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            if (App.transaction_table != null)
            {
                txtusername.Text   = App.transaction_table.User_Name;
                txtusermobile.Text = App.transaction_table.User_Mobile_Number;
                txtitems.Text      = App.transaction_table.Items;

                MapService.ServiceToken = "Ajh0II1uJBt4Y_waGLLyq5R3ftW8N_x1NWUTsXq3m2pInKFpPw6sBctqeDG0RqFI";
                geolocator = new Geolocator();

                coordinate = await geolocator.GetGeopositionAsync();

                // Create a MapIcon.
                MapIcon mapIcon1 = new MapIcon();

                mapIcon1.Location = coordinate.Coordinate.Point;
                mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon1.Title  = "You";
                mapIcon1.ZIndex = 0;
                MyMap.MapElements.Add(mapIcon1);

                MapIcon mapIcon2 = new MapIcon();

                string[] commapos = App.transaction_table.L_User.Split(",".ToCharArray());
                double   ulat     = double.Parse(commapos[0]);
                double   ulond    = double.Parse(commapos[1]);
                mapIcon2.Location = new Geopoint(new BasicGeoposition {
                    Latitude = ulat, Longitude = ulond
                });
                mapIcon2.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon2.Title  = "User";
                mapIcon2.ZIndex = 0;

                // Add the MapIcon to the map.
                MyMap.MapElements.Add(mapIcon2);

                await MyMap.TrySetViewAsync(coordinate.Coordinate.Point, 16D);

                BasicGeoposition userlocation = new BasicGeoposition()
                {
                    Latitude = ulat, Longitude = ulond
                };

                // Reverse geocode the specified geographic location.
                MapLocationFinderResult result =
                    await MapLocationFinder.FindLocationsAtAsync(new Geopoint(userlocation));

                // If the query returns results, display the name of the town
                // contained in the address of the first result.
                if (result.Status == MapLocationFinderStatus.Success)
                {
                    txtuseraddress.Text = result.Locations[0].Address.StreetNumber + " " + result.Locations[0].Address.Street + " " + result.Locations[0].Address.Neighborhood + " " + result.Locations[0].Address.Region;
                }

                if (App.transaction_table.Status == "Active" && App.transaction_table.Driver_Id == null)
                {
                    txtdriaddress.Visibility = Visibility.Collapsed;
                    txtdrimobile.Visibility  = Visibility.Collapsed;
                    txtdriname.Visibility    = Visibility.Collapsed;
                    lbldriaddress.Visibility = Visibility.Collapsed;
                    lbldrimobile.Visibility  = Visibility.Collapsed;
                    lbldriname.Visibility    = Visibility.Collapsed;
                }

                if (App.transaction_table.Driver_Id != null)
                {
                    txtdriname.Text   = App.transaction_table.Driver_Name;
                    txtdrimobile.Text = App.transaction_table.Driver_Mobile;

                    MapIcon mapIcon3 = new MapIcon();

                    string[] commapos2 = App.transaction_table.L_Driver.Split(",".ToCharArray());
                    double   dlat      = double.Parse(commapos2[0]);
                    double   dlond     = double.Parse(commapos2[1]);
                    mapIcon3.Location = new Geopoint(new BasicGeoposition {
                        Latitude = dlat, Longitude = dlond
                    });
                    mapIcon3.NormalizedAnchorPoint = new Point(0.5, 1.0);
                    mapIcon3.Title  = "Driver";
                    mapIcon3.ZIndex = 0;

                    // Add the MapIcon to the map.
                    MyMap.MapElements.Add(mapIcon3);

                    BasicGeoposition driverlocation = new BasicGeoposition()
                    {
                        Latitude = dlat, Longitude = dlond
                    };

                    // Reverse geocode the specified geographic location.
                    MapLocationFinderResult dresult =
                        await MapLocationFinder.FindLocationsAtAsync(new Geopoint(driverlocation));

                    // If the query returns results, display the name of the town
                    // contained in the address of the first result.
                    if (dresult.Status == MapLocationFinderStatus.Success)
                    {
                        txtdriaddress.Text = dresult.Locations[0].Address.StreetNumber + " " + dresult.Locations[0].Address.Street + " " + dresult.Locations[0].Address.Neighborhood + " " + dresult.Locations[0].Address.Region;
                    }
                }
            }
            else
            {
                var dialog = new MessageDialog("User Has Cancelled The Session");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(VolunteerHome));
            }
        }