void OnPushpinTap(object sender, GestureEventArgs e) { if (null != ((Pushpin)sender).Tag && typeof(MulticityChargerMarker) == ((Pushpin)sender).Tag.GetType()) { return; } e.Handled = true; var pushpinContent = ((Pushpin)sender).Content; var border = pushpinContent as Border; bookingControl.Deactivate(); if (border != null) { if (Visibility.Collapsed == border.Visibility) { foreach (var pushpin in activeLayer.Children.ToArray()) { if (pushpin is Pushpin) { DeactivatePushpin(pushpin as Pushpin); } } if (((Pushpin)sender).Tag is Car2GoMarker) { mainPageApplicationBarBookCarButton.IsEnabled = true; if (((Car2GoMarker)((Pushpin)sender).Tag).isBooked) { mainPageApplicationBarBookCarButton.IconUri = new Uri("Resources/appbar.timer.cancel.png", UriKind.RelativeOrAbsolute); } } else if ((((Pushpin)sender).Tag is DriveNowMarker) || (((Pushpin)sender).Tag is MulticityMarker)) { mainPageApplicationBarBookCarButton.IsEnabled = true; } var parentLayer = VisualTreeHelper.GetParent((Pushpin)sender) as MapLayer; parentLayer.Children.Remove((Pushpin)sender); activeLayer.Children.Add((Pushpin)sender); //((Pushpin)sender).Tag = parentLayer; ((Pushpin)sender).Opacity = 1; border.Visibility = Visibility.Visible; if (null != ((Pushpin)sender).Tag && typeof(MulticityMarker) == ((Pushpin)sender).Tag.GetType()) { Multicity.LoadChargeState(sender as Pushpin); } } else { DeactivatePushpin(sender as Pushpin); } } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { ValidateTrialMode(); var multicity = new Multicity(); multicity.Updated += OnLayerUpdated; multicity.LoadPOIs(); this.Resources.Add("multicity", multicity); var driveNow = new DriveNow(); driveNow.Updated += OnLayerUpdated; driveNow.LoadPOIs(); this.Resources.Add("driveNow", driveNow); var car2Go = new Car2Go(); car2Go.Updated += OnLayerUpdated; car2Go.LoadPOIs(); this.Resources.Add("car2go", car2Go); StartFlurry(); UpdateFlipTile( "", "FreeCars", "\n car2go\n DriveNow\n multicity", "Find free rides around you - car2go, DriveNow, multicity", 0, new Uri("/", UriKind.Relative), null, //new Uri("/ApplicationIcon.png", UriKind.Relative), null, null, new Uri("/Resources/wide_back_tile.png", UriKind.Relative), null); var currentVersion = GetAppAttribute("Version"); var lastAppVersion = (string)GetAppSetting("last_version"); if (null != lastAppVersion && lastAppVersion == currentVersion) { IsFirstLaunch = false; } else { IsFirstLaunch = true; } SetAppSetting("last_version", currentVersion); }
void UpdateMulticityLayers(Multicity multicity) { //var myLocation = myLocationPushpin.Location; var centerLocation = map.Center; var cultureInfo = new CultureInfo("en-US"); var multcityCarsBrush = new SolidColorBrush(Colors.Red); var multcityChargersBrush = new SolidColorBrush(Colors.Green); multicityCarsLayer.Children.Clear(); var tempList = new List <Pushpin>(); foreach (var car in multicity.Markers) { try { var distanceToMapCenter = (int)car.position.GetDistanceTo(centerLocation); var fuelTextBlock = new TextBlock { Text = !string.IsNullOrEmpty(car.fuelState) ? car.fuelState + "%" : "", }; if (markersMaxDistance < distanceToMapCenter) { continue; } if (null == car.fuelState) { car.Updated += (updatedCar, eventArgs) => { if (car.fuelState != ((MulticityMarker)updatedCar).fuelState) { try { car.fuelState = ((MulticityMarker)updatedCar).fuelState; fuelTextBlock.Text = car.fuelState + "%"; } catch { } } fuelTextBlock.Text = car.fuelState + "%"; }; } var pushpinContent = new Border { Child = new StackPanel { Orientation = System.Windows.Controls.Orientation.Vertical, VerticalAlignment = System.Windows.VerticalAlignment.Center, Children = { new TextBlock { Text = car.model, }, new TextBlock { Text = car.licensePlate, }, new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, Children = { new Image { Source = new BitmapImage(new Uri("/Resources/battery28x28.png", UriKind.Relative)), Margin = new Thickness(0, 0, 12, 0), }, fuelTextBlock, }, }, }, }, Visibility = Visibility.Collapsed, }; var pushpin = new Pushpin() { Location = car.position, Name = car.hal2option.tooltip, Opacity = .6, Background = multcityCarsBrush, Content = pushpinContent, Tag = car, }; pushpin.Tap += OnPushpinTap; try { multicityCarsLayer.Children.Add(pushpin); } catch (ArgumentException) { } } catch (ArgumentException) { } } multicityFlinksterLayer.Children.Clear(); multicityChargingLayer.Children.Clear(); foreach (var station in multicity.MulticityChargers) { try { var coordinate = new GeoCoordinate( Double.Parse(station.lat, cultureInfo.NumberFormat), Double.Parse(station.lng, cultureInfo.NumberFormat)); var distanceToMapCenter = (int)(coordinate.GetDistanceTo(centerLocation)); if (markersMaxDistance < distanceToMapCenter) { continue; } var pushpin = new Pushpin() { Location = coordinate, Name = station.hal2option.tooltip, Opacity = .6, Background = multcityChargersBrush, Content = new Border { Child = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, Children = { new Image { Source = new BitmapImage(new Uri("/Resources/plug28x28.png", UriKind.Relative)), Height = 38, Width = 38, }, new TextBlock { Text = station.hal2option.markerInfo.free, }, }, }, }, Tag = station, }; pushpin.Tap += OnPushpinTap; multicityCarsLayer.Children.Add(pushpin); } catch (ArgumentException) { } } }