private async void MyMap_OnMapElementClick(MapControl sender, MapElementClickEventArgs args) { //Model.myMap_OnMapElementClick(sender , args); MapIcon myClickedIcon = args.MapElements.FirstOrDefault(x => x is MapIcon) as MapIcon; Sight clickedSight = myClickedIcon.ReadData(); ContentDialog1 dialog = new ContentDialog1(clickedSight); var result = await dialog.ShowAsync(); // primary button was clicked if (result == ContentDialogResult.Primary) { NavToSight(clickedSight); } }
public async void OnMapElementCLick(MapControl sender, MapElementClickEventArgs args, List <Building> buildingsVisited) { MapIcon myClickedIcon = args.MapElements.FirstOrDefault(x => x is MapIcon) as MapIcon; Building buildingClickedBuffer = myClickedIcon.ReadData(); dialog.Title = buildingClickedBuffer.Name; dialog.Content = "building type: " + buildingClickedBuffer.GetBuidlingType() + "\r" + "price of this building: " + buildingClickedBuffer.price + "\r" + "earnings per seccond: " + buildingClickedBuffer.EarningsP_S + "\r" + "is Bought = " + buildingClickedBuffer.Bought + "\r Last time collected: " + buildingClickedBuffer.timeLastCollected.ToString(); dialog.PrimaryButtonText = "Close"; this.ClickedBuilding = buildingClickedBuffer; if (buildingClickedBuffer.Bought) { dialog.SecondaryButtonText = "Not in range"; dialog.IsSecondaryButtonEnabled = false; foreach (Building b in buildingsVisited) { if (b.Name.Equals(buildingClickedBuffer.Name)) { dialog.IsSecondaryButtonEnabled = true; dialog.SecondaryButtonText = "Collect: " + Convert.ToInt32((DateTime.Now - buildingClickedBuffer.timeLastCollected).TotalSeconds * buildingClickedBuffer.EarningsP_S / 100); } } dialog.SecondaryButtonClick += collectButton_Click; } else { dialog.SecondaryButtonText = "buy for: " + buildingClickedBuffer.price; dialog.SecondaryButtonClick += buyButton_click; dialog.IsSecondaryButtonEnabled = false; foreach (Building b in buildingsVisited) { if (b.Name.Equals(buildingClickedBuffer.Name)) { dialog.IsSecondaryButtonEnabled = true; dialog.SecondaryButtonText = "buy for: " + buildingClickedBuffer.price; } } dialog.SecondaryButtonClick += buyButton_click; } await dialog.ShowAsync(); }
private void RedrawSight(MapIcon icon) { foreach (MapElement mapElement in _map.MapElements) { if (mapElement.GetType() != typeof(MapIcon)) { continue; } if (mapElement.Equals(icon)) { int index = _map.MapElements.IndexOf(mapElement); _map.MapElements.RemoveAt(index); RandomAccessStreamReference image; Sight s = icon.ReadData(); if (s.Name != "VVV") { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/entered-pin.png")); } else { image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/home-entered-pin.png")); } var ancherpoint = new Point(0.5, 1); var seenSight = new MapIcon { Title = s.Name, Location = s.Position, NormalizedAnchorPoint = ancherpoint, Image = image, ZIndex = 4, CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible }; seenSight.AddData(s); _map.MapElements.Add(seenSight); break; } } }