Exemple #1
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            var index      = Convert.ToInt32(JumperDataGrid.SelectedRows[0].Cells[0].Value);
            var thisJumper = JumperList.First(x => x.Number == index);

            JumperList.Remove(thisJumper);

            JumperDataGrid.Rows.RemoveAt(JumperDataGrid.SelectedRows[0].Index);
        }
Exemple #2
0
        public void CalculateScore()
        {
            try
            {
                _jumpLength        = double.Parse(jumpLength.Text);
                _criticalPoint     = double.Parse(criticalPoint.Text);
                _levelCompensation = double.Parse(levelCompensation.Text);
                _platformChange    = double.Parse(levelChange.Text);
                _windChance1       = double.Parse(windCheck1.Text);
                _windChance2       = double.Parse(windCheck2.Text);
                _windChance3       = double.Parse(windCheck3.Text);
                _windChance4       = double.Parse(windCheck4.Text);
                _windChance5       = double.Parse(windCheck5.Text);
                _stylePoints1      = double.Parse(stylePoints1.Text);
                _stylePoints2      = double.Parse(stylePoints2.Text);
                _stylePoints3      = double.Parse(stylePoints3.Text);
                _stylePoints4      = double.Parse(stylePoints4.Text);
                _stylePoints5      = double.Parse(stylePoints5.Text);

                if (nameComboBox.SelectedIndex == -1 || _jumpLength == 0 || _criticalPoint == 0 || _levelCompensation == 0)
                {
                    MessageBox.Show("Please, fill in all jump specs!");
                }
                else
                {
                    _windCompensation = countWindEffect(_criticalPoint, _windChance1, _windChance2, _windChance3,
                                                        _windChance4, _windChance5);
                    _jumpScore   = countLengthScore(_jumpLength, _criticalPoint, _windCompensation);
                    _stylePoints = countStylePoints(_stylePoints1, _stylePoints2, _stylePoints3, _stylePoints4,
                                                    _stylePoints5);
                    _platformCompensation = countPlatformCompensation(_criticalPoint, _platformChange, _levelCompensation);
                    _score = _windCompensation + _jumpScore + _stylePoints + _platformCompensation;

                    if (_error != true)
                    {
                        var thisJumper = JumperList.FirstOrDefault(x => x.Number == _number);

                        var scoreExist = ResultList.FirstOrDefault(x => x.Number == _number);
                        if (scoreExist != null)
                        {
                            double total = scoreExist.Score;
                            scoreExist.Score = _score + total;
                            JumperList.Remove(thisJumper);
                        }
                        else
                        {
                            ResultList.Add(new Result(_number, thisJumper.Name, thisJumper.Country, _score));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #3
0
        private void AddJumperButton_Click(object sender, EventArgs e)
        {
            try
            {
                int jumperNumber = 0;
                if (JumperList.Count > 0)
                {
                    jumperNumber = JumperList[JumperList.Count - 1].Number;
                }
                int    _number  = jumperNumber + 1;
                string _name    = nameInput.Text.ToString();
                string _country = countryInput.Text.ToString();

                JumperList.Add(new Jumper(_number, _name, _country));
                object[] row = { _number.ToString(), _name, _country };
                JumperDataGrid.Rows.Add(row);
                nameInput.Clear();
                countryInput.Clear();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }