Ejemplo n.º 1
0
        void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            if (e.Action == 1)
            {
                try
                {
                    RedZone newRedZone = lstRedZones.Items.Last() as RedZone;
                    layers = new MapLayer();

                    image           = new BitmapImage();
                    image.UriSource = (new Uri(newRedZone.FbUser.Picture.data.url, UriKind.Absolute));

                    brush                = new ImageBrush();
                    brush.ImageSource    = image;
                    ellipse              = new Ellipse();
                    ellipse.DataContext  = newRedZone;
                    ellipse.Height       = newRedZone.Radius / 5;
                    ellipse.Width        = newRedZone.Radius / 5;
                    ellipse.Fill         = brush;
                    ellipse.RightTapped += ellipse_RightTapped;

                    layers.Children.Add(ellipse);
                    MapLayer.SetPosition(ellipse, new Location(newRedZone.Latitude, newRedZone.Longitude));

                    myMap.Children.Add(layers);
                }
                catch (Exception)
                {
                    ///ToDo
                    ///Remover la lista de usuarios que ya no se encuentran
                }
            }
        }
Ejemplo n.º 2
0
        void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                RedZone newRedZone = lstRedZones.Items.Last() as RedZone;
                layers = new MapLayer();

                image           = new BitmapImage();
                image.UriSource = (new Uri(newRedZone.FbUser.Picture.data.url, UriKind.Absolute));

                brush               = new ImageBrush();
                brush.ImageSource   = image;
                ellipse             = new Ellipse();
                ellipse.DataContext = newRedZone;
                ellipse.Height      = newRedZone.Radius / 5;
                ellipse.Width       = newRedZone.Radius / 5;
                ellipse.Fill        = brush;
                ellipse.Hold       += ellipse_Hold;

                overlay = new MapOverlay();
                overlay.GeoCoordinate = new GeoCoordinate(newRedZone.Latitude, newRedZone.Longitude);
                overlay.Content       = ellipse;
                layers.Add(overlay);

                myMap.Layers.Add(layers);
            }
        }
Ejemplo n.º 3
0
        async void ellipse_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            RedZone   zone = (sender as Ellipse).DataContext as RedZone;
            PopupMenu menu = new PopupMenu();

            menu.Commands.Add(new UICommand(AppResources.General_GetDirections, (command) =>
            {
                staticObjects.GoalLongitude        = zone.Longitude;
                staticObjects.GoalLatitude         = zone.Latitude;
                staticObjects.FriendProfilePicture = new Uri(zone.FbUser.Picture.data.url, UriKind.Absolute);
                (DataContext as RedZonesViewModel).GetDirections.Execute(null);
            }));

            menu.Commands.Add(new UICommand(AppResources.General_ShareFacebook, (command) =>
            {
                Share.ShareToFacebook("http://bing.com/maps/default.aspx" +
                                      "?cp=" + zone.Latitude + "~" + zone.Longitude +
                                      "&lvl=18" +
                                      "&style=r",
                                      "Sobre la zona " + zone.Address + "." +
                                      String.Format(String.Format(
                                                        AppResources.General_RedZoneWarning_Message,
                                                        zone.Address,
                                                        zone.FbUser.Name,
                                                        zone.Description)),
                                      zone.FbUser.Picture.data.url);
            }));
            menu.Commands.Add(new UICommand(AppResources.General_ShareEmail, (command) =>
            {
                SetSharingContent(zone, zone.FbUser.Name);
                Share.ShowShareBar();
            }));
            await menu.ShowForSelectionAsync(Screen.GetElementRect((FrameworkElement)sender));
        }
Ejemplo n.º 4
0
 void lstRedZones_Tapped(object sender, TappedRoutedEventArgs e)
 {
     if (lstRedZones.SelectedItem != null)
     {
         RedZone zone = lstRedZones.SelectedItem as RedZone;
         myMap.ZoomLevel = 15;
         myMap.Center    = new Location(zone.Latitude, zone.Longitude);
         SetSharingContent(zone, zone.FbUser.Name);
     }
 }
Ejemplo n.º 5
0
        private void SetSharingContent(RedZone zone, string fbUserName)
        {
            Share.Title       = "SmartGuard - Zona peligrosa";
            Share.Description = "Comparte la posicion de tus amigos";
            DateTime date = zone.RegisteredAt;

            Share.Message = String.Format(AppResources.General_RedZoneWarning_Message, zone.Address, fbUserName, zone.Description) + "\n\n Para ver la zona en un mapa, haz click en el siguiente link:\n http://bing.com/maps/default.aspx" +
                            "?cp=" + zone.Latitude + "~" + zone.Longitude +
                            "&lvl=18" +
                            "&style=r";
        }
Ejemplo n.º 6
0
 void btnGetDirections_Click(object sender, EventArgs e)
 {
     if (lstRedZones.SelectedItem != null)
     {
         RedZone eli = lstRedZones.SelectedItem as RedZone;
         GPS.GetDirections(new GeoCoordinate(eli.Latitude, eli.Longitude));
     }
     else
     {
         MessageBox.Show(AppResources.RedZone_SelectedItemError, AppResources.GPS_GetDirections, MessageBoxButton.OK);
     }
 }
Ejemplo n.º 7
0
        private RedZone CreateRedZone(
            ThreatController threatController,
            ILookup <ZoneLocation, DamageToken> initialDamage,
            Doors redDoors,
            WhiteZone whiteZone,
            Interceptors interceptors)
        {
            var redZone = new RedZone(threatController, whiteZone.LowerWhiteStation.CentralReactor, redDoors, this, interceptors);

            DamageZone(initialDamage, ZoneLocation.Red, redZone);
            return(redZone);
        }
Ejemplo n.º 8
0
        void lstRedZones_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (lstRedZones.SelectedItem != null)
            {
                RedZone       selectedRedZone = lstRedZones.SelectedItem as RedZone;
                GeoCoordinate coordinates     = new GeoCoordinate(selectedRedZone.Latitude, selectedRedZone.Longitude);
                coordinates.Latitude  -= 0.0002;
                coordinates.Longitude += 0.0002;

                myMap.Center    = coordinates;
                myMap.ZoomLevel = 18;
            }
        }
Ejemplo n.º 9
0
        private void ShareRedZone(RedZone redZone)
        {
            if (redZone != null)
            {
                ShareContent.Title   = String.Format("[{0}] - {1}", AppResources.ApplicationTitle, AppResources.General_RedZoneWarning);
                ShareContent.Message = String.Format(
                    AppResources.General_RedZoneWarning_Message,
                    redZone.FbUser.Name,
                    AppResources.Says,
                    redZone.Description);
                ShareContent.Link = new Uri("http://bing.com/maps/default.aspx" +
                                            "?cp=" + redZone.Latitude + "~" + redZone.Longitude +
                                            "&lvl=18" +
                                            "&style=r", UriKind.Absolute);

                NavigationService.Navigate(new Uri("/Views/Share.xaml", UriKind.Relative));
            }
        }
Ejemplo n.º 10
0
        async void btnAdd_Click(object sender, EventArgs e)
        {
            RedZone redZone = new RedZone();

            redZone.City         = staticObjects.City;
            redZone.Country      = staticObjects.Country;
            redZone.Description  = txtDescription.Text;
            redZone.FacebookID   = App.fbUserID;
            redZone.Latitude     = coordinate.Latitude;
            redZone.Longitude    = coordinate.Longitude;
            redZone.Radius       = int.Parse(txtRadius.Text);
            redZone.PartitionKey = (redZone.City + redZone.Country).Replace(" ", "");
            redZone.RegisteredAt = DateTime.UtcNow;
            redZone.RowKey       = redZone.Latitude.ToString() + redZone.Longitude.ToString();


            bool result = await(this.DataContext as UploadRedZoneViewModel).TryUploadNewRedZone(redZone);
        }
Ejemplo n.º 11
0
        void ellipse_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            RedZone     zone = (sender as Ellipse).DataContext as RedZone;
            ContextMenu menu = new ContextMenu();
            MenuItem    item = new MenuItem();

            item.Header      = AppResources.ShareView_Title;
            item.DataContext = zone;
            item.Tap        += ShareRedZone;
            menu.Items.Add(item);

            MenuItem itemTwo = new MenuItem();

            itemTwo.Header      = AppResources.GPS_GetDirections;
            itemTwo.Tap        += GetDirections;
            itemTwo.DataContext = zone;
            menu.Items.Add(itemTwo);

            ContextMenuService.SetContextMenu(sender as Ellipse, menu);
        }
Ejemplo n.º 12
0
        void GetDirections(object sender, System.Windows.Input.GestureEventArgs e)
        {
            RedZone eli = (sender as MenuItem).DataContext as RedZone;

            GPS.GetDirections(new GeoCoordinate(eli.Latitude, eli.Longitude));
        }
Ejemplo n.º 13
0
        void ShareRedZone(object sender, System.Windows.Input.GestureEventArgs e)
        {
            RedZone redZone = (sender as MenuItem).DataContext as RedZone;

            ShareRedZone(redZone);
        }
Ejemplo n.º 14
0
 public async Task <bool> TryUploadNewRedZone(RedZone redZone)
 {
     return(await Queries.TryInsertEntityAsync("RedZone", redZone));
 }