public Address_Validation_Helper(Location_Reference location, Panel parent)
        {
            Location = location;
            Parent = parent;

            SearchControl = new GeoSearchPopup();
            Popup = new Popup { Child = SearchControl };
            parent.Children.Add(Popup);
        }
        protected Ellipse DrawPoint(Location_Reference locationRef)
        {
            //return new Ellipse();

            var point = new Ellipse();
            point.Width = 10;
            point.Height = 10;
            point.Fill = new SolidColorBrush(Colors.Red);
            point.Opacity = 0.65;
            var location = new Location(locationRef.Location.Latitude, locationRef.Location.Longitude);
            MapLayer.SetPosition(point, location);
            MapLayer.SetPositionOrigin(point, PositionOrigin.Center);
            //point.Tag = itineraryItem;
            //point.MouseEnter += new System.Windows.Input.MouseEventHandler(point_MouseEnter);
            //point.MouseLeave += new System.Windows.Input.MouseEventHandler(point_MouseLeave);

            return point;
        }
        public LocationViewModel()
        {
            ExternalReference = Guid.NewGuid().ToString();
            Shipping = DateTime.Today.AddDays(1);

            if (random.Next(10) % 10 > 5)
                Destination = new Location_Reference("CLIENT1", "Cliente 1", new Location(44, 23));
            //Destination = new Location_Reference
            //{
            //    Id = "client1",
            //    Name = "Client 1",
            //    Location = new Location(44, 23),
            //    Search_Address = "boh",
            //};
            else
                Destination = Location_Reference.Empty;
            Amount = new Amount { Unit="KG", Value = 10 };
        }
 protected void Find_Address(Location_Reference location)
 {
     var geocoding = maps.ServiceHelper.GetGeocodeService();
     geocoding.ReverseGeocodeCompleted += (sender, e) =>
     {
         var correlated = e.UserState as Location_Reference;
         if (e.Result.Results.Count == 1)
             correlated.Resolve_Address(e.Result.Results.Select(s=> s.Address).First());
             //Correct_Position(correlated, e.Result.Results.Single());
         else
             correlated.Invalidate();
     };
     geocoding.ReverseGeocodeAsync(new maps.GeocodeService.ReverseGeocodeRequest
     {
         Credentials = new Microsoft.Maps.MapControl.Credentials() { Token = maps.ServiceHelper.GeocodeServiceCredentials },
         Culture = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(),
         Location = location.Location
     }, location);
 }
        public void Change_Destination(Address_Validated result)
        {
            if (result == null)
                return;
            Destination = new Location_Reference(result.Location, result.Address);
            //Destination = new Location_Reference()
            //{
            //    Location = result.Location,
            //    Resolved_Address = result.Address,
            //    Search_Address = result.Address.FormattedAddress,
            //};

            //Destination.Validate();

            //System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            //{
            //    Location = result.Location;
            //    Resolved_Address = result.Address;
            //    Search_Address = result.Address.FormattedAddress;

            //    Validate();
            //});
        }
 public void Change_Destination(string externalId, string name, Location location)
 {
     Destination = new Location_Reference(externalId, name, location);
 }