public Master() { ContentView menuLabel = new ContentView { Padding = new Thickness(10, 36, 0, 5), Content = new Label { TextColor = Color.Black, Text = "--- Saved ---", } }; lista = new ListView(); lista.ItemTemplate = new DataTemplate(typeof(CustomListChuchu)); var all = App.DAUtil.AllUser(); var oc = new ObservableCollection <Lugars>(all); lista.ItemsSource = oc; lista.BindingContext = oc; lista.SeparatorVisibility = Xamarin.Forms.SeparatorVisibility.None; this.Master = new ContentPage { Title = "Saved", Content = new StackLayout { Children = { menuLabel, lista } }, }; lista.ItemTapped += (sender, e) => { Lugars item = (Lugars)e.Item; //navigate to nxt map var positio = new Position(item.Lat, item.Lng); AllMap.map.Pins.Add(new Pin { Type = PinType.Place, Position = positio, Label = item.Name, Address = "sds" }); AllMap.map.MoveToRegion(MapSpan.FromCenterAndRadius(positio, Distance.FromMiles(15))); //Detail = new NavigationPage(new SelectedMap(item)); ((ListView)sender).SelectedItem = null; this.IsPresented = false; }; Detail = new NavigationPage(new MainPage()); }
public SelectedMapa(Lugars item) //useless { selected = item; RelativeLayout main = new RelativeLayout(); this.Title = selected.Name; var goTo = new ToolbarItem { Text = " + ", Command = new Command(async() => await Navigation.PushModalAsync(new Master())) }; this.ToolbarItems.Add(goTo); var stack = new StackLayout { Spacing = 0 }; var positio = new Position(selected.Lat, selected.Lng); AllMap.map.Pins.Add(new Pin { Type = PinType.Place, Position = positio, Label = selected.Name, Address = "sds" }); stack.Children.Add(AllMap.map); main.Children.Add(stack, Constraint.RelativeToParent((p) => { return(p.X); }), Constraint.RelativeToParent((p) => { return(p.Y); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.RelativeToParent((p) => { return(p.Height); }) ); Content = main; }
public int DeleteUser(Lugars i) { return(db.Delete(i)); }
public int UpdateUser(Lugars i) { return(db.Update(i)); }
public int AddUser(Lugars i) { return(db.Insert(i)); }
public MainPage() { //PlacesAutoComplete autoComplete = new PlacesAutoComplete(true) { ApiToUse = PlacesAutoComplete.PlacesApi.Google }; autoComplete.SetBinding(PlacesAutoComplete.PlaceSelectedCommandProperty, "PlaceSelectedCommand"); autoComplete.SetBinding(PlacesAutoComplete.BoundsProperty, "MapRegion"); Button btn = new Button { Text = "Show", HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 50, WidthRequest = 100, BackgroundColor = Color.Aqua }; Title = "Map"; RelativeLayout main = new RelativeLayout(); //var als = App.DAUtil.AllUser(); //for (int i = 0; i < als.Count;i++) //{ // map.Pins.Add(new Pin // { // Type = PinType.Place, // Position = new Position(als[i].Lat,als[i].Lng), // Label = als[i].Name, // Address = "sds" // }); //} //map.FitMapRegionToPositions(((System.Collections.Generic.IEnumerable<Xamarin.Forms.Maps.Position>)(IEnumerable)(x)),false); var stack = new StackLayout { Spacing = 0 }; //stack.Children.Add(autoComplete); stack.Children.Add(AllMap.map); main.Children.Add(stack, Constraint.RelativeToParent((p) => { return(p.X); }), Constraint.RelativeToParent((p) => { return(p.Y); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.RelativeToParent((p) => { return(p.Height); }) ); Form form = new Form(); form.IsVisible = false; main.Children.Add(form, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Width); }) ); main.Children.Add(btn, Constraint.RelativeToParent((p) => { return(p.Width / 2 - btn.WidthRequest / 2); }), Constraint.RelativeToParent((p) => { return(p.Height - btn.HeightRequest - 10); }) ); //main.Children.Add( // autoComplete, // Constraint.Constant(0), // Constraint.Constant(0)); Content = main; btn.Clicked += (sender, e) => { var animation = new Animation(callback: d => form.Rotation = d, start: button.Rotation, end: button.Rotation + 360, easing: Easing.SpringOut); animation.Commit(form, "Loop", length: 800); form.IsVisible = true; btn.IsVisible = false; }; button.Clicked += async(sender, e) => { try { double lat = 0, lng = 0; var approximateLocations = await geo.GetPositionsForAddressAsync(autoComplete._entry.Text); foreach (var position in approximateLocations) { lat = position.Latitude; lng = position.Longitude; break; } var positio = new Position(lat, lng); AllMap.map.Pins.Add(new Pin { Type = PinType.Place, Position = positio, Label = "pin", Address = "sds" }); var insert = new Lugars() { Name = autoComplete._entry.Text, Lat = lat, Lng = lng }; App.DAUtil.AddUser(insert); var all = App.DAUtil.AllUser(); var oc = new ObservableCollection <Lugars>(all); Master.lista.ItemsSource = oc; AllMap.map.MoveToRegion(MapSpan.FromCenterAndRadius(positio, Distance.FromMiles(15))); var animation = new Animation(callback: d => btn.Rotation = d, start: button.Rotation, end: button.Rotation + 360, easing: Easing.SpringOut); animation.Commit(btn, "Loop", length: 800); form.IsVisible = false; btn.IsVisible = true; } catch { await DisplayAlert("---", "---", "OK"); var animation = new Animation(callback: d => btn.Rotation = d, start: button.Rotation, end: button.Rotation + 360, easing: Easing.SpringOut); animation.Commit(btn, "Loop", length: 800); form.IsVisible = false; btn.IsVisible = true; } }; }