/// <summary>
        ///    Проверка спутников на столкновения с землей и друг с другом
        /// </summary>
        /// <returns>true, если столкновений не будет, false в противном случае</returns>
        private bool VerifyDistances()
        {
            if (_motionParams.Count == 0)
            {
                return(true);
            }

#pragma warning disable 618
            var earth     = Resources.GetDrawable(Resource.Drawable.globe);
            var satellite = Resources.GetDrawable(Resource.Drawable.action_satellite);
#pragma warning restore 618
            var maxEarth     = Math.Max(earth.IntrinsicWidth, earth.IntrinsicHeight);
            var maxSatellite = Math.Max(satellite.IntrinsicWidth, satellite.IntrinsicHeight);

            _motionParams.Sort(
                (satellite1, satellite2) =>
                Float.FloatToIntBits(satellite1.Distance) - Float.FloatToIntBits(satellite2.Distance));

            var satObject         = _motionParams[0];
            var thresholdDistance = Math.Sqrt(2) / 2 * (maxEarth + maxSatellite);
            if (satObject.Distance < thresholdDistance) // Спутник столкнется с землей
            {
                var errorMessage = String.Format(Resources.GetString(Resource.String.EarthCollideError),
                                                 thresholdDistance);
                AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                return(false);
            }

            for (var i = 1; i < _motionParams.Count; i++)
            {
                var currentSatellite = _motionParams[i];
                var prevSatellite    = _motionParams[i - 1];
                var diffDistance     = currentSatellite.Distance - prevSatellite.Distance;
                if (diffDistance < MinimumDistanceBetween)
                {
                    // Расстояние между спутниками меньше минимально допустимого
                    var errorMessage = String.Format(Resources.GetString(Resource.String.SatelliteCollideError),
                                                     currentSatellite.Distance, prevSatellite.Distance, MinimumDistanceBetween);
                    AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        ///    Установка кнопки сохранения данных таблицы
        /// </summary>
        private void SetupSaveButton()
        {
            var saveButton = FindViewById <Button>(Resource.Id.SaveButtonId);

            saveButton.Click += (sender, args) =>
            {
                if (_motionParams.Count > 0)
                {
                    _motionParams.Clear();
                }

                // Сбор информации из текстовых полей ввода
                for (var i = 0; i < _settingsTable.ChildCount; i++)
                {
                    var tableRow = _settingsTable.GetChildAt(i) as TableRow;
                    if (tableRow == null)
                    {
                        continue;
                    }

                    long  currentTime     = -1;
                    float currentDistance = -1;

                    for (var j = 0; j < tableRow.ChildCount; j++)
                    {
                        var currentView = tableRow.GetChildAt(j);
                        if (!(currentView is EditText))
                        {
                            goto nextTableRow;
                        }

                        var editText    = (EditText)currentView;
                        var editTextId  = editText.Id;
                        var currentText = editText.Text.Trim();
                        if (currentText.Length == 0)
                        {
                            goto nextTableRow;
                        }

                        if (editTextId % 2 != 0)
                        {
                            if (!long.TryParse(currentText, out currentTime) || currentTime <= 0)
                            {
                                var errorMessage = Resources.GetString(Resource.String.NegativeTimeError);
                                AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                                editText.RequestFocus();
                                return;
                            }
                        }
                        else
                        {
                            if (!float.TryParse(currentText, out currentDistance) || !(currentDistance > 0))
                            {
                                var errorMessage = Resources.GetString(Resource.String.NegativeTimeError);
                                AlertDialogUtil.ShowSimpleDialog(this, errorMessage);
                                editText.RequestFocus();
                                return;
                            }
                        }
                    }

                    _motionParams.Add(new Satellite(currentTime, currentDistance));

nextTableRow:
                    ;
                }

                if (VerifyDistances())
                {
                    SaveSettings(SettingsFileName);
                }

                StartActivity(new Intent(this, typeof(StartScreenActivity)));
            };
        }