Пример #1
0
        public async void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            if (viewing)
            {
                //we want to delete the note
                //ask the user if they really want to delete the note
                var message = new Windows.UI.Popups.MessageDialog("Do you want to Delete!");
                message.Commands.Add(new UICommand("Delete", new UICommandInvokedHandler(CommandInvokedHandler)));
                message.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(CommandInvokedHandler)));

                message.DefaultCommandIndex = 0;

                message.CancelCommandIndex = 1;

                await message.ShowAsync();
            }
            else
            {
                //add the note
                MyMapNote note = new MyMapNote();
                note.Title = titleTextBox.Text;
                note.Note  = noteTextBox.Text;
                //date time set but not used.
                note.Created = DateTime.Now;
                //setting long,lat fro center position
                note.Latitude  = Map.Center.Position.Latitude;
                note.Longitude = Map.Center.Position.Longitude;
                App.Notes.AddNote(note);



                this.Frame.Navigate(typeof(myNote));
            }
        }
Пример #2
0
        //private async  void AddNote_Loaded(object setter, NavigationEventArgs e)
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //map service token from bing maps
            Map.MapServiceToken = "TOfdeDRJwGImuiaL7W88~SlMn6bqFU6GCmOupV2lB-g~AsoKvGZZisSkTudn4cs2nwQzmGl7eS58HojnUjiskKBwBEYkH-7yUV7sRAXsADIr";
            //set map style for add note feature.
            Map.Style = MapStyle.AerialWithRoads;
            Geopoint pos;

            if (e.Parameter == null)
            {
                viewing = false;

                var location = new Geolocator();
                location.DesiredAccuracyInMeters = 50;
                var position = await location.GetGeopositionAsync();

                pos = position.Coordinate.Point;
            }
            else
            {
                viewing = true;

                myText            = (MyMapNote)e.Parameter;
                titleTextBox.Text = myText.Title;
                noteTextBox.Text  = myText.Note;
                //if viewing =true then we are in the delete mode
                // and add button content will change to delete
                // and the function will change to a delete function
                addBtn.Content = "Delete";

                var myPos = new Windows.Devices.Geolocation.BasicGeoposition();
                myPos.Latitude  = myText.Latitude;
                myPos.Longitude = myText.Longitude;

                //drop a ancor pin to mark center point
                pos = new Geopoint(myPos);
                MapIcon icon = new MapIcon();
                icon.Location = pos;
                icon.NormalizedAnchorPoint = new Point(0.5, 1.0);
                icon.Title  = "Note Location";
                icon.Image  = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Pin.png"));
                icon.ZIndex = 0;
                Map.MapElements.Add(icon);
                Map.Center = pos;
            }

            await Map.TrySetViewAsync(pos, 14D);
        }