Exemplo n.º 1
0
        private void EditPropertiesMarker(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedItems.Count == 1 &&
                GetDataGrid().SelectedItems[0].Tag is Game.Marker)
            {
                Marker mk  = (Game.Marker)GetDataGrid().SelectedItems[0].Tag;
                var    mke = new Game.Marker(game);
                mke.Assign(mk);
                var mef = new MarkerEditForm();
                mef.Edit(mke);
                if (mef.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    mk.Assign(mke);
                    mk.FlagUpdate = true;
                    UpdateGridView((Game.Marker)mk);

                    try
                    {
                        game.SaveLocal();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void CorrectMarkerChangedPlayers(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedItems.Count == 1 &&
                GetDataGrid().SelectedItems[0].Tag is Game.Marker &&
                ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).ActionId == 14 &&
                ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Player1 != null &&
                ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Player2 != null)
            {
                Marker mk  = (Game.Marker)GetDataGrid().SelectedItems[0].Tag;
                Marker mki = new Game.Marker(game);
                mki.Assign(mk);

                Marker mk1 = null;
                if (mk.player2_id > 0 && game.Markers.Any(o =>
                                                          !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo < mk.TimeVideo &&
                                                          o.ActionId == 14 && o.player1_id == mk.player2_id))
                {
                    mk1 = game.Markers.Where(o =>
                                             !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo < mk.TimeVideo &&
                                             o.ActionId == 14 && o.player1_id == mk.player2_id)
                          .OrderByDescending(o => o.TimeVideo).First();
                }

                Marker mk2 = null;
                if (mk.player1_id > 0 && game.Markers.Any(o =>
                                                          !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo > mk.TimeVideo &&
                                                          o.ActionId == 14 && o.player2_id == mk.player1_id))
                {
                    mk2 = game.Markers.Where(o =>
                                             !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo > mk.TimeVideo &&
                                             o.ActionId == 14 && o.player2_id == mk.player1_id)
                          .OrderBy(o => o.TimeVideo).First();
                }

                var form = new CorrectChangedPlayersMarkerForm(game, mki, mk1, mk2);
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Log.Write("MANUAL CORRECT BEFORE " + mk.ToString());

                    var time_up = mki.TimeVideo != mk.TimeVideo;

                    var team = mk.Player1 != null
                        ? mk.Team1 : mk.Team2;;

                    if (mk1 != null)
                    {
                        if (mk1.Player1 != mki.Player2)
                        {
                            mk1.Player1       = mki.Player2;
                            mk1.FlagUpdate    = true;
                            mk1.FlagGuiUpdate = true;
                            UpdateGridView((Game.Marker)mk1);
                        }
                    }

                    if (mk2 != null)
                    {
                        if (mk2.Player2 != mki.Player1)
                        {
                            mk2.Player2       = mki.Player1;
                            mk2.FlagUpdate    = true;
                            mk2.FlagGuiUpdate = true;
                            UpdateGridView((Game.Marker)mk2);
                        }
                    }

                    mk.Assign(mki);
                    mk.FlagUpdate    = true;
                    mk.FlagGuiUpdate = true;
                    UpdateGridView((Game.Marker)mk);

                    Log.Write("MANUAL CORRECT AFTER " + mk.ToString());

                    if (time_up)
                    {
                        ReloadDataGridView(true);
                    }

                    lock (game.Markers)
                        MarkerList.SaveToFile(game.Match.Id, game.Markers);
                }
            }
        }