示例#1
0
        private async void Initialize()
        {// Create new Map with basemap
            Map myMap = new Map(Basemap.CreateImageryWithLabels());

            myMap.InitialViewpoint = new Viewpoint(34.05293, -118.24368, 6000);

            // Assign the map to the MapView
            MyMapView.Map = myMap;



            try
            {
                // Initialize the LocatorTask with the provided service Uri
                _geocoder = await LocatorTask.CreateAsync(_serviceUri);

                var vm = CoreDependencyService.GetViewModel <SearchViewModel>();
                vm.MapView = MyMapView;
                // Enable the UI controls now that the LocatorTask is ready
                MySuggestButton.IsEnabled = true;
                MySearchBar.IsEnabled     = true;
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        public CurrentLocationPage()
        {
            InitializeComponent();
            Initialize();
            var vm = CoreDependencyService.GetViewModel <SearchViewModel>();

            vm.MapView = MyMapView;
        }
示例#3
0
 public UsersCell() : base()
 {
     ContextActions.Add(new MenuItem()
     {
         Text    = "Make Favorite",
         Command = new Command(async(obj) =>
         {
             var item = ((RandomUser)BindingContext);
             await CoreDependencyService.GetViewModel <AppViewModel>().AddToFavorites(item);
         })
     });
 }
示例#4
0
 public FavoritesCell() : base()
 {
     ContextActions.Add(new MenuItem()
     {
         Text          = "Delete",
         IsDestructive = true,
         Command       = new Command(async(obj) =>
         {
             var item = ((RandomUser)BindingContext);
             await CoreDependencyService.GetViewModel <AppViewModel>().RemoveFavorites(item);
         })
     });
 }
示例#5
0
        public TodoPageCell()
        {
            this.Height = 65;
            title       = new Label()
            {
                Margin   = new Thickness(0, 8, 0, 0),
                FontSize = 22
            };
            date = new Label()
            {
                FontSize  = 14,
                TextColor = Color.DarkGray,
                Margin    = new Thickness(0, 0, 0, 8),
            };

            var rightPanel = new StackLayout()
            {
                Children = { title, date }
            };

            var img = new CachedImage()
            {
                Margin                = new Thickness(10, 0, 3, 0),
                HeightRequest         = 55,
                WidthRequest          = 55,
                DownsampleHeight      = 55,
                DownsampleWidth       = 55,
                Aspect                = Aspect.AspectFit,
                CacheDuration         = TimeSpan.FromDays(30),
                VerticalOptions       = LayoutOptions.Center,
                DownsampleUseDipUnits = true,
                Source                = "todorowimage.png"
            };

            this.ContextActions.Add(new MenuItem()
            {
                Text          = "Delete",
                IsDestructive = true,
                Command       = new Command(async(obj) => {
                    var item = (Todo)BindingContext;
                    await CoreDependencyService.GetViewModel <TodoViewModel>().DeleteItem(item);
                })
            });


            View = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Children    = { img, rightPanel }
            };
        }
        public void TimeElapsedEvent()
        {
            //example of routing execution to some view model in the application
            var vm = CoreDependencyService.GetViewModel <SimpleViewModel>();

            vm.DisplayNotification(new LocalNotification()
            {
                Id      = 1,
                Title   = "Timer Event",
                Icon    = "icon.png",
                Message = $"The timer event fired {DateTime.Now.ToShortTimeString()}"
            });

#if DEBUG
            Console.WriteLine("*****************   I am a little teapot *****************************");
#endif
        }
示例#7
0
        private void Delete()
        {
            var str = (string)this.BindingContext;

            CoreDependencyService.GetViewModel <ContextMenuViewModel>().OnViewMessageReceived("NameDeleted", str);
        }