private void OnJockeyClick(object sender, MouseEventArgs e)
        {
            try
            {
                //var f = new JockeyStatisticsForm(_myHorse.CorrespondingBrisHorse.Jockey);

                var f = new ImpactValueForm
                            {
                                ImpactValues = JockeyStatistics.Get(_myHorse.CorrespondingBrisHorse.Jockey).AllStats,
                                Description = _myHorse.CorrespondingBrisHorse.Jockey
                            };

                f.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void OnCellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                if (e.RowIndex >= 0)
                {
                    foreach (DataGridViewRow row in _grid.Rows)
                    {
                        row.Selected = false;
                    }
                    _grid.Rows[e.RowIndex].Selected = true;
                    Rectangle r = _grid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    Horse horse = GetHorseFromRowIndex(e.RowIndex);

                    if (!horse.Scratched)
                    {
                        _popupmenu.Items.Clear();
                        _popupmenu.Items.Add("" + horse.Name);
                        _popupmenu.Items.Add("-");
                        _popupmenu.Items.Add("Scratch", null, OnScratch);
                    }
                    else
                    {
                        _popupmenu.Items.Clear();
                        _popupmenu.Items.Add("" + horse.Name);
                        _popupmenu.Items.Add("-");
                        _popupmenu.Items.Add("Unscratch", null, OnScratch);
                    }

                    if (horse.IsContenter)
                    {
                        _popupmenu.Tag = e.RowIndex;
                        _popupmenu.Items.Add("Is No Contenter", null, OnToggleContenterStatus);
                    }
                    else
                    {
                        _popupmenu.Tag = e.RowIndex;
                        _popupmenu.Items.Add("Is Contenter", null, OnToggleContenterStatus);
                    }

                    if (horse.IsBestBet)
                    {
                        _popupmenu.Tag = e.RowIndex;
                        _popupmenu.Items.Add("Is Not Best Best", null, OnToggleIsBestBetStatus);
                    }
                    else
                    {
                        _popupmenu.Tag = e.RowIndex;
                        _popupmenu.Items.Add("Is Best Best", null, OnToggleIsBestBetStatus);
                    }

                    _popupmenu.Items.Add("-");
                    _popupmenu.Items.Add("Horse Notes", null, OnHorseNotes);
                    _popupmenu.Items.Add("Cynthia Projections", null, OnCynhiaProjections);
                    _popupmenu.Items.Add("-");
                    _popupmenu.Items.Add("Edit Weights", null, OnEditWeights);

                    _popupmenu.Tag = horse;

                    _popupmenu.Show((Control) sender, r.Left + e.X, r.Top + e.Y);
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                int trainerIndex = _grid.Columns["Trainer"].Index;
                int jockeyIndex = _grid.Columns["Jockey"].Index;

                if (e.ColumnIndex == 1 && null != _grid.Rows[e.RowIndex].Tag)
                {
                    OnToggleIsBestBetStatus(null, null);
                }
                else if (e.ColumnIndex == 2 && null != _grid.Rows[e.RowIndex].Tag)
                {
                    ShowHorseDetails(e.RowIndex);
                }
                else if (e.ColumnIndex == trainerIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    try
                    {
                        var h = (Horse) _grid.Rows[e.RowIndex].Tag;
                        string trainer = h.CorrespondingBrisHorse.TrainersFullName;
                        var form = new IndividualTrainerStatsForm(h);
                        form.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                else if (e.ColumnIndex == _valueColumnIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    var horse = _grid.Rows[e.RowIndex].Tag as Horse;
                    horse.ValueIndex = horse.ValueIndex + 1;
                    _grid[_valueColumnIndex, e.RowIndex].Value = horse.ValueIndex;
                }

                else if (e.ColumnIndex == _weightColumnIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    var horse = _grid.Rows[e.RowIndex].Tag as Horse;
                    horse.WeightIndex = horse.WeightIndex + 1;
                    _grid[_weightColumnIndex, e.RowIndex].Value = horse.WeightIndex;
                }

                    /*
                else if (e.ColumnIndex == _votesForOddsColumnIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    try
                    {
                        var f = new ShowVotesForAllOddsCategoriesForm(_grid.Rows[e.RowIndex].Tag as Horse);
                        f.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                     */
                else if (e.ColumnIndex == jockeyIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    try
                    {
                        string jockey = ((Horse)_grid.Rows[e.RowIndex].Tag).CorrespondingBrisHorse.Jockey;

                        var f = new ImpactValueForm
                        {
                            ImpactValues = JockeyStatistics.Get(jockey).AllStats,
                            Description = jockey
                        };

                        //f.ShowDialog();
                        f.Show(this);

                        //var form = new JockeyStatisticsForm(jockey);
                        //form.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (e.ColumnIndex == _oddsColumnIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    Horse horse = GetHorseFromRowIndex(e.RowIndex);

                    try
                    {
                        var f = new RealTimeOddsHistoryForm(horse, _oddsRetriever.ExactaPayouts);
                        f.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (e.ColumnIndex == 0 && null != _grid.Rows[e.RowIndex].Tag)
                {
                    Horse horse = GetHorseFromRowIndex(e.RowIndex);
                    if (null != horse)
                    {
                        if (_currentHorse != horse)
                        {
                            ShowHorseDetails(e.RowIndex);
                        }

                        var f = new IndividualHorsePastPerformancesForm(horse);
                        f.Show();
                    }
                    else
                    {
                        MessageBox.Show("Sorry, something is wrong with this horse!\nPlease check its program number");
                    }
                }
                else if (e.ColumnIndex == _donkeyColumnIndex && null != _grid.Rows[e.RowIndex].Tag)
                {
                    Horse horse = GetHorseFromRowIndex(e.RowIndex);
                    if (null != horse)
                    {

                        var location = Cursor.Position;
                        var l2 = this.PointToClient(location);

                        var f = new HorseFiguresForm(horse);
                        f.Location = location;

                        f.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Sorry, something is wrong with this horse!\nPlease check its program number");
                    }
                }
            }
        }