private void IssoLVHistory_ItemTapped(object sender, ItemTappedEventArgs e) { var index = ((ObservableCollection <TableRow>)issoLVHistory.ItemsSource).IndexOf(e.Item as TableRow); var table = _connection.Query <RATING>("select * from RATING where C_ISSO=? and RATINGDATE=?", _cIsso, _rows[index].DateMonth).ToList()[0]; AddNewRating page; if (table.SYNC) { page = new AddNewRating(_cIsso, _currentRating, table.CURRENTRATING, TypeNewRating.IsPreviewed, _currentPosition, table.RATINGDATE, false); } else { bool canAddPhotos = false; if (_currentPosition != null) { double distance = CommonStaffUtils.GetDistance(_issoLatitude, _issoLongitude, _currentPosition.Latitude, _currentPosition.Longitude, _length); if (distance < 100 + _currentPosition.Accuracy) { canAddPhotos = true; } } page = new AddNewRating(_cIsso, _currentRating, table.CURRENTRATING, TypeNewRating.IsEditable, _currentPosition, table.RATINGDATE, canAddPhotos); } Navigation.PushAsync(page); ((ListView)sender).SelectedItem = null; }
private bool CheckGps() { if (_currentPosition == null) { DisplayAlert("", "Нет данных о Вашем местоположении", "OK"); return(false); } if (_currentPosition.Accuracy > MaximumAccuracy) { DisplayAlert("", $"Недопустимая точность положения. Текущая погрешность : {_currentPosition.Accuracy:F1} м.", "OK"); return(false); } double dist = CommonStaffUtils.GetDistance(_issoLatitude, _issoLongitude, _currentPosition.Latitude, _currentPosition.Longitude, _length); if (dist > (100 + _currentPosition.Accuracy)) { DisplayAlert("", "Вы должны находиться на этом сооружении, чтобы иметь возможность вносить сведения", "OK"); return(false); } return(true); }
/// <summary> /// Handler при изменении текущих координат /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Current_PositionChanged(object sender, PositionEventArgs e) { _currentPosition = e.Position; _currentLatitude = e.Position.Latitude; _currentLongitude = e.Position.Longitude; status.Text = $"Расстояние до объекта, м: {(Math.Abs(_currentLatitude) < CommonStaffUtils.DoubleTolerance ? "[недоступно]" : $"{CommonStaffUtils.GetDistance(_issoLatitude, _issoLongitude, _currentLatitude, _currentLongitude, _length):F1}")}\nПогрешность GPS, м: {(Math.Abs(_currentLatitude) < CommonStaffUtils.DoubleTolerance ? "[недоступно]" : $"{e.Position.Accuracy:F1}")}"; var dist = CommonStaffUtils.GetDistance(_issoLatitude, _issoLongitude, _currentLatitude, _currentLongitude, _length); imgStatus.Source = dist > (100 + e.Position.Accuracy) ? new FileImageSource { File = CommonStaffUtils.GetFilePath( "marker_noway.png") /*String.Format("{0}{1}", Device.OnPlatform("Icons/", "", "Assets/Icons/"), "marker_noway.png")*/ } : new FileImageSource() { File = CommonStaffUtils.GetFilePath( "marker_ahead.png") /*String.Format("{0}{1}", Device.OnPlatform("Icons/", "", "Assets/Icons/"), "marker_ahead.png")*/ }; }