Пример #1
0
        public void RefreshItems(StatisticsItem[] items, DateTime since, DateTime to)
        {
            var scenarios = items.Select(x =>
                                         new LocationsView.ScenarioInfo()
            {
                Id   = x.Target.ID,
                Name = x.Target.Name
            })
                            .Distinct()
                            .ToArray();

            var history = scenarios
                          .Select(x => new LocationsView.GeolocationScenarioHistoryView()
            {
                ScenarioInfo = x,
                Datas        = items
                               .Where(z => z.Target.ID == x.Id)
                               .Select(z => GeolocationData.FromString(z.Value))
                               .Where(z =>
                                      !double.IsNaN(z.Latitude) &&
                                      !double.IsNaN(z.Longtitude) &&
                                      !double.IsInfinity(z.Latitude) &&
                                      !double.IsInfinity(z.Longtitude))
                               .ToArray()
            }).ToArray();

            locationsView.RefreshWith(history);
        }
        private void ItemView_Click(object sender, RoutedEventArgs e)
        {
            var data = GeolocationData.FromString(((ScenarioModel)DataContext).ScenarioValue);

            if (data.IsEmpty)
            {
                MessageView.ShowMessage(
                    "Данные о геокоординатах пусты...",
                    "Невозможно открыть геокоординаты",
                    Icons.Icon.MapGps);
            }
            else
            {
                // Open through yandex maps
                var browserUrl = @"https://yandex.ru/maps/?mode=whatshere&whatshere%5Bpoint%5D={0}%2C{1}&whatshere%5Bzoom%5D=13";
                var lat        = data.Latitude.ToString().Replace(",", ".");
                var lng        = data.Longtitude.ToString().Replace(",", ".");

                var url = string.Format(browserUrl, lng, lat);

                try
                {
                    Process.Start(url);
                }
                catch
                {
                    Process.Start("IEXPLORE.EXE", url); //crutch
                }
            }
        }
Пример #3
0
        public void GeolocationData_should_handle_location()
        {
            var geo = new GeolocationData(1.0123456789, 2.0123456789);

            Assert.AreEqual(true, geo.HasCoordinates);
            Assert.IsNull(geo.Address);
            Assert.AreEqual("1.0123456789,2.0123456789", geo.ToString());
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value != null)
     {
         return(GeolocationData.FromString(value.ToString()).DateTime.ToString());
     }
     return(string.Empty);
 }
Пример #5
0
        public void GeolocationData_should_handle_address()
        {
            var geo = new GeolocationData("Test address");

            Assert.AreEqual(false, geo.HasCoordinates);
            Assert.AreEqual("Test address", geo.Address);
            Assert.AreEqual("Test address", geo.ToString());
        }
Пример #6
0
        public void GeolocationData_should_handle_nulls()
        {
            var geo = new GeolocationData(null);

            Assert.AreEqual(false, geo.HasCoordinates);
            Assert.IsNull(geo.Address);
            Assert.IsNotNull(geo.ToString());
            Assert.AreEqual("", geo.ToString());
        }
Пример #7
0
        private void ItemView_Click(object sender, EventArgs e)
        {
            var model = (SwitchScenarioModel)BindingContext;
            var data  = GeolocationData.FromString(model.ScenarioValue);
            var label = data.DateTime.ToString() + "\r\n" + model.ScenarioName;

            Singleton.Resolve <IGeolocationView>()?
            .View(new Lazurite.Shared.Geolocation(data.Latitude, data.Longtitude, false), label);
        }
Пример #8
0
        public async Task <GeolocationResponse> SaveAsync(GeolocationData geolocationData)
        {
            try
            {
                await _geolocationRepository.AddAsync(geolocationData);

                await _unitOfWork.CompleteAsync();

                return(new GeolocationResponse(geolocationData));
            }
            catch (Exception ex)
            {
                return(new GeolocationResponse($"An error occurred when saving the category: {ex.Message}"));
            }
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     try
     {
         if (value != null)
         {
             var dateTime = GeolocationData.FromString(value.ToString()).DateTime;
             return(dateTime.ToShortDateString() + " " + dateTime.ToString("HH:mm"));
         }
         return(string.Empty);
     }
     catch
     {
         return(string.Empty);
     }
 }
        private void ItemView_Click(object sender, EventArgs e)
        {
            var model = (SwitchScenarioModel)BindingContext;
            var data  = GeolocationData.FromString(model.ScenarioValue);

            if (data.IsEmpty)
            {
                Controls.MessageView.Show("Данные о геокоординатах пусты...", LazuriteUI.Icons.Icon.MapGps, DialogView.GetDialogHost(this));
            }
            else
            {
                var label = data.DateTime.ToString() + "\r\n" + model.ScenarioName;
                Singleton.Resolve <IGeolocationView>()?
                .View(new Lazurite.Shared.Geolocation(data.Latitude, data.Longtitude, false), label);
            }
        }
Пример #11
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Button          selected     = sender as Button;
            string          uriString    = null;
            SampleDataItem  item         = DefaultViewModel["Item"] as SampleDataItem;
            GeolocationData userLocation = this.DefaultViewModel[UserLocationName] as GeolocationData;

            if (selected != null && item != null && userLocation != null)
            {
                string latStart = userLocation.UserLocation.Position.Latitude.ToString();
                string lngStart = userLocation.UserLocation.Position.Longitude.ToString();
                string lat      = item.Location.Position.Latitude.ToString();
                string lng      = item.Location.Position.Longitude.ToString();
                string name     = Uri.EscapeDataString(item.Subtitle);
                string address  = Uri.EscapeDataString(item.Address);


                switch (selected.Name)
                {
                case "Button1":      // Center & Zoom
                    uriString = "bingmaps:?cp=" + lat + "~" + lng + "&lvl=14";
                    break;

                case "Button2":      // Pin
                    uriString = "bingmaps:?collection=point." + lat + "_" + lng + "_" + name + "&lvl=14";
                    break;

                case "Button3":      // Directions
                    uriString = "bingmaps:?rtp=pos." + latStart + "_" + lngStart + "~adr." + address;
                    break;

                case "Button4":      // Start Voice Nav
                    uriString = "ms-drive-to:?destination.latitude=" + lat + "&destination.longitude=" + lng + "&destination.name=" + name;
                    break;

                default:
                    break;
                }
            }
            if (uriString != null)
            {
                await Windows.System.Launcher.LaunchUriAsync(new Uri(uriString));
            }
        }
Пример #12
0
        private void ItemView_Click(object sender, RoutedEventArgs e)
        {
            //open through yandex maps
            var browserUrl = @"https://yandex.ru/maps/?mode=whatshere&whatshere%5Bpoint%5D={0}%2C{1}&whatshere%5Bzoom%5D=13";
            var data       = GeolocationData.FromString(((ScenarioModel)DataContext).ScenarioValue);
            var lat        = data.Latitude.ToString().Replace(",", ".");
            var lng        = data.Longtitude.ToString().Replace(",", ".");

            var url = string.Format(browserUrl, lng, lat);

            try
            {
                Process.Start(url);
            }
            catch
            {
                Process.Start("IEXPLORE.EXE", url); //crutch
            }
        }
Пример #13
0
        private async void MapControl_Loaded(object sender, RoutedEventArgs e)
        {
            MapControl      map          = (MapControl)sender;
            SampleDataItem  item         = (SampleDataItem)DefaultViewModel["Item"];
            GeolocationData userLocation = (GeolocationData)DefaultViewModel[UserLocationName];

            Geopoint             start       = userLocation.UserLocation;
            Geopoint             end         = item.Location;
            MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteAsync(start, end);

            if (routeResult.Status == MapRouteFinderStatus.Success)
            {
                MapRoute     route     = routeResult.Route;
                MapRouteView routeView = new MapRouteView(route);
                map.Routes.Add(routeView);
                var maneuvers = route.Legs[0].Maneuvers;
                maneuverList.ItemsSource = maneuvers;
                await map.TrySetViewBoundsAsync(route.BoundingBox, new Thickness(15, 30, 15, 30), MapAnimationKind.None);
            }
        }
        public void RefreshItems(ScenarioStatistic[] scenarioStatistics, DateTime since, DateTime to)
        {
            var history =
                scenarioStatistics
                .Select(x => new LocationsView.GeolocationScenarioHistoryView()
            {
                ScenarioInfo = new LocationsView.ScenarioInfo()
                {
                    Id   = x.ScenarioInfo.ID,
                    Name = x.ScenarioInfo.Name
                },
                Datas =
                    x.Statistic
                    .Select(z => GeolocationData.FromString(z.Value))
                    .Where(z =>
                           !double.IsNaN(z.Latitude) &&
                           !double.IsNaN(z.Longtitude) &&
                           !double.IsInfinity(z.Latitude) &&
                           !double.IsInfinity(z.Longtitude))
                    .ToArray()
            }).ToArray();

            locationsView.RefreshWith(history);
        }
Пример #15
0
 private GeolocationResponse(bool success, string message, GeolocationData geolocationData) : base(success, message)
 {
     GeolocationData = geolocationData;
 }
Пример #16
0
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="geolocationData">Saved category.</param>
 /// <returns>Response.</returns>
 public GeolocationResponse(GeolocationData geolocationData) : this(true, string.Empty, geolocationData)
 {
 }
Пример #17
0
 public GeolocationDataResource Convert(GeolocationData localGeolocationData)
 {
     return(_mapper.Map <GeolocationDataResource>(localGeolocationData));
 }
 public Task DeleteAsync(GeolocationData geolocationData)
 {
     _applicationDbContext.GeolocationData.Remove(geolocationData);
     return(_applicationDbContext.SaveChangesAsync());
 }
Пример #19
0
 public async Task AddAsync(GeolocationData geolocationData)
 {
     await _context.GeolocationData.AddAsync(geolocationData);
 }
 public async Task <GeolocationResponse> SaveAsync(GeolocationData geolocationData)
 {
     return(await Task.Run(() => new GeolocationResponse(geolocationData)));
 }
Пример #21
0
 public void Remove(GeolocationData geolocationData)
 {
     _context.GeolocationData.Remove(geolocationData);
 }
 public Task AddAsync(GeolocationData geolocationData)
 {
     _applicationDbContext.GeolocationData.AddAsync(geolocationData);
     return(_applicationDbContext.SaveChangesAsync());
 }