private async void AddPlace_Click(object sender, RoutedEventArgs e)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async delegate
     {
         if (PName == string.Empty)
         {
             await new MessageDialog("Specify a name for this place").ShowAsync();
         }
         else
         {
             try
             {
                 SavedPlacesVM.AddNewPlace(new SavedPlacesVM.SavedPlaceClass()
                 {
                     Latitude  = MapView.MapControl.Center.Position.Latitude,
                     Longitude = MapView.MapControl.Center.Position.Longitude,
                     PlaceName = PNameHolder.Text
                 });
             }
             catch (Exception ex)
             {
                 await new MessageDialog(ex.Message).ShowAsync();
             }
         }
     });
 }
Ejemplo n.º 2
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var context = DataContext as BookmarkAddNeedsClass;

            if (DefaultName.IsChecked.Value)
            {
                try
                {
                    SavedPlacesVM.AddNewPlace(new SavedPlacesVM.SavedPlaceClass()
                    {
                        PlaceName = context.PlaceName, Latitude = context.Location.Position.Latitude, Longitude = context.Location.Position.Longitude
                    });
                    if (PinLiveTile.IsChecked.Value)
                    {
                        //var pd = await ViewModel.PlaceControls.PlaceDetailsHelper.GetPlaceDetails((DataContext as BookmarkAddNeedsClass).PlaceID);
                        Uri           square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
                        SecondaryTile tile = new SecondaryTile(new Random(1).Next(Int32.MaxValue).ToString(), "Home", $"{context.Location.Position.Latitude},{context.Location.Position.Longitude}", square150x150Logo, TileSize.Square150x150);
                        tile.DisplayName = PlaceNameText.Text;
                        tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                        tile.VisualElements.ShowNameOnWide310x150Logo   = true;
                        tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                        tile.VisualElements.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-200.png");
                        tile.VisualElements.Square310x310Logo           = new Uri("ms-appx:///Assets/LargeTile.scale-200.png");
                        await tile.RequestCreateAsync();
                    }
                }
                catch (Exception ex)
                {
                    await new MessageDialog(ex.Message).ShowAsync();
                    await this.ShowAsync();
                }
            }
            else
            {
                try
                {
                    SavedPlacesVM.AddNewPlace(new SavedPlacesVM.SavedPlaceClass()
                    {
                        PlaceName = PlaceNameText.Text, Latitude = context.Location.Position.Latitude, Longitude = context.Location.Position.Longitude
                    });
                    if (PinLiveTile.IsChecked.Value)
                    {
                        Uri           square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
                        SecondaryTile tile = new SecondaryTile(new Random(1).Next(Int32.MaxValue).ToString(), "Home", $"{context.Location.Position.Latitude},{context.Location.Position.Longitude}", square150x150Logo, TileSize.Square150x150);
                        tile.DisplayName = PlaceNameText.Text;
                        tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                        tile.VisualElements.ShowNameOnWide310x150Logo   = true;
                        tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                        tile.VisualElements.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-200.png");
                        tile.VisualElements.Square310x310Logo           = new Uri("ms-appx:///Assets/LargeTile.scale-200.png");
                        await tile.RequestCreateAsync();
                    }
                }
                catch (Exception ex)
                {
                    await new MessageDialog(ex.Message).ShowAsync();
                    await this.ShowAsync();
                }
            }
        }
Ejemplo n.º 3
0
 private async void DraggablePin_Tapped(object sender, TappedRoutedEventArgs e)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async delegate
     {
         if (ClassInitializer.GetType() == typeof(DirectionsMainUserControl))
         {
             var Pointer = (await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/InAppIcons/GMP.png")));
             if (DirectionsMainUserControl.Origin == null)
             {
                 DirectionsMainUserControl.Origin = _map.Center;
                 _map.MapElements.Add(new MapIcon()
                 {
                     Location = _map.Center,
                     NormalizedAnchorPoint = new Point(0.5, 1.0),
                     Title = "Origin",
                     Image = RandomAccessStreamReference.CreateFromFile(Pointer),
                 });
                 DirectionsMainUserControl.OriginAddress = await GeocodeHelper.GetAddress(_map.Center);
             }
             else if (DirectionsMainUserControl.Destination == null)
             {
                 DirectionsMainUserControl.Destination = _map.Center;
                 _map.MapElements.Add(new MapIcon()
                 {
                     Location = _map.Center,
                     NormalizedAnchorPoint = new Point(0.5, 1.0),
                     Title = "Destination",
                     Image = RandomAccessStreamReference.CreateFromFile(Pointer)
                 });
                 DirectionsMainUserControl.DestinationAddress = await GeocodeHelper.GetAddress(_map.Center);
             }
         }
         if (ClassInitializer.GetType() == typeof(SavedPlacesUserControl))
         {
             if (SavedPlacesUserControl.PName == string.Empty)
             {
                 await new MessageDialog("Specify a name for this place").ShowAsync();
             }
             else
             {
                 try
                 {
                     SavedPlacesVM.AddNewPlace(new SavedPlacesVM.SavedPlaceClass()
                     {
                         Latitude  = _map.Center.Position.Latitude,
                         Longitude = _map.Center.Position.Longitude,
                         PlaceName = SavedPlacesUserControl.PName
                     });
                 }
                 catch (Exception ex)
                 {
                     await new MessageDialog(ex.Message).ShowAsync();
                 }
             }
         }
     });
 }