Пример #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)
                    {
                    }
                }
            }
        }
Пример #2
0
        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (dataGridView1.SelectedItems.Count > 0)
            {
                var mk = (Game.Marker)dataGridView1.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;


                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            import_process = true;
                            UpdateUI();

                            ShowStatus("UPDATE instatfootball.com...", 0);

                            Web.SaveMarker(game, mk);


                            ShowStatus("Success", 0);
                        }
                        catch (Exception ex)
                        {
                            ShowStatus(ex.Message, 1);
                        }
                        finally
                        {
                            import_process = false;
                            ReloadDataGridView();
                            UpdateUI();
                        }
                    });
                }
            }
        }
Пример #3
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && dataGridView1.SelectedItems.Count > 0)
            {
                if (MessageBox.Show(String.Format("Удалить маркеры ({0}) ?", dataGridView1.SelectedItems.Count),
                                    "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                var del = new List <Marker>();

                foreach (ListViewItem row in dataGridView1.SelectedItems)
                {
                    var mk = (Game.Marker)row.Tag;
                    del.Add(mk);
                }

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        import_process = true;
                        UpdateUI();

                        ShowStatus("DELETE from instatfootball.com...", 0);

                        var tasks           = new List <Task>();
                        Exception exception = null;

                        foreach (Game.Marker mk in del)
                        {
                            tasks.Add(Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    var mk1 = new Game.Marker(game);
                                    mk1.Assign(mk);
                                    mk1.FlagDel = !mk.FlagDel;

                                    Web.SaveMarker(game, mk1);

                                    lock (game.Markers)
                                        game.Markers.Remove(mk);
                                }
                                catch (Exception ex)
                                {
                                    exception = ex;
                                }
                            }));
                        }

                        Task.WaitAll(tasks.ToArray <Task>());

                        if (exception != null)
                        {
                            throw exception;
                        }

                        ShowStatus("Success", 0);
                    }
                    catch (Exception ex)
                    {
                        ShowStatus(ex.Message, 1);
                    }
                    finally
                    {
                        import_process = false;
                        ReloadDataGridView();
                        UpdateUI();
                    }
                });
            }
        }
Пример #4
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);
                }
            }
        }